Replies: 1 comment 2 replies
-
This won't work.
This requires dotnet/csharplang#6308 , to treat |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
This proposal suggests removing restrictions for operators
is
andas
on generic arguments withallows ref struct
anti-constraint. This changes should allows to escape constraints, applied by modifiersscoped
andallows ref struct
, in methods and types with generic arguments, and do, for example, async processing arguments if they aren'tref struct
(see below).Considerations
Since
ref struct
don't participate in type casting, should be safety to returnfalse
as result of type check, even forobject
at right side. Same for casting -ref struct
may not be casted to any other type, sonull
is expected.It's true for all variations except when right side is same type as type of processed value.
Example code
Actual behaivor
Code will not compile because of operator
is
don't account possibility of generic parameterV
to be a notref struct
type.Proposed behaivor of operator
is
This also not optimal quickfix of actual behaivor.
Using
Is<TIn, TOut>
instead of operatoris
in sample above allows it to compile.Beta Was this translation helpful? Give feedback.
All reactions