-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle ref safety analysis for type parameters with 'allows ref struct' constraint #73281
Handle ref safety analysis for type parameters with 'allows ref struct' constraint #73281
Conversation
1 similar comment
case BoundKind.NewT: | ||
{ | ||
var newT = (BoundNewT)expr; | ||
var constructorSymbol = newT.Constructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -663,7 +663,9 @@ private BoundExpression EvaluateSideEffects(BoundExpression arg, RefKind refKind | |||
|
|||
#if DEBUG | |||
var discardedUseSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded; | |||
Debug.Assert(_compilation.Conversions.ClassifyConversionFromType(rewrittenReceiver.Type, memberSymbol.ContainingType, isChecked: false, ref discardedUseSiteInfo).IsImplicit); | |||
// PROTOTYPE(RefStructInterfaces): Test various flavors of object/collection initializers on a type parameter that allows ref struct | |||
Debug.Assert(_compilation.Conversions.ClassifyConversionFromType(rewrittenReceiver.Type, memberSymbol.ContainingType, isChecked: false, ref discardedUseSiteInfo).IsImplicit || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_compilation.Conversions.ClassifyConversionFromType(rewrittenReceiver.Type, memberSymbol.ContainingType, isChecked: false, ref discardedUseSiteInfo).IsImplicit ||
It looks like this check can be dropped since it is included in HasImplicitConversionToOrImplementsVarianceCompatibleInterface()
. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this check can be dropped since it is included in
HasImplicitConversionToOrImplementsVarianceCompatibleInterface()
.
It actually isn't. HasImplicitConversionToOrImplementsVarianceCompatibleInterface
deals only with interfaces.
|
||
RS M1() | ||
{ | ||
// RSTE of `this` is CurrentMethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
is an interface, not a type parameter withallows ref struct
.
And the point you are trying to make is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test didn't seem particularly interesting to me because this
is an interface and not by-ref-like. But the behavior (no errors reported) looks correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior is different by comparison to the cloned test, but correct. That feels good enough to keep the test.
0433c09
into
dotnet:features/RefStructInterfaces
No description provided.