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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
This proposal suggests removing restrictions for operators
isandason generic arguments withallows ref structanti-constraint. This changes should allows to escape constraints, applied by modifiersscopedandallows 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 structdon't participate in type casting, should be safety to returnfalseas result of type check, even forobjectat right side. Same for casting -ref structmay not be casted to any other type, sonullis 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
isdon't account possibility of generic parameterVto be a notref structtype.Proposed behaivor of operator
isThis also not optimal quickfix of actual behaivor.
Using
Is<TIn, TOut>instead of operatorisin sample above allows it to compile.Beta Was this translation helpful? Give feedback.
All reactions