-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Avoid resolving parameter.Type in ReportParameterErrors() #63142
Conversation
@@ -648,7 +648,7 @@ static void addERR_ParamsCantBeWithModifier(BindingDiagnosticBag diagnostics, Sy | |||
diagnostics.Add(ErrorCode.ERR_MethodArgCantBeRefAny, parameterSyntax.Location, parameter.Type); | |||
} | |||
|
|||
if (parameter.Scope == DeclarationScope.ValueScoped && !parameter.Type.IsErrorTypeOrRefLikeType()) | |||
if (parameter.Scope == DeclarationScope.ValueScoped && !parameter.TypeWithAnnotations.IsRefLikeType()) |
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.
Is there a way to also check for the error type case without pulling too aggressively on lazy .Type
? #Closed
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.
Consider adding a comment at the top of this method that pulling on parameter.Type
is cycle-prone.
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.
Is there a way to also check for the error type case without pulling too aggressively on lazy
.Type
?
We could add a similar IsErrorType()
method to TypeWithAnnotations
, but I'm not sure it's worth it. (Should an unresolved type always return false
for IsErrorType()
?)
Consider adding a comment ...
I've added a comment to the method to avoid using parameter.Type
.
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.
Done with review pass (iteration 1)
@@ -648,7 +651,7 @@ static void addERR_ParamsCantBeWithModifier(BindingDiagnosticBag diagnostics, Sy | |||
diagnostics.Add(ErrorCode.ERR_MethodArgCantBeRefAny, parameterSyntax.Location, parameter.Type); |
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.
Is it possible for us to avoid using parameter.Type
here as well?
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.
I think we're ok here because we've already checked that parameter.TypeWithAnnotations
is a restricted type. That means the type is not a type parameter which is the only case where we'd have an unresolved type.
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.
Will this break when we add allow T : ref struct
? No need to adjust the implementation based on something we haven't done yet, but would be good to have a sense of what our path forward would be in that case.
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.
Will this break when we add
allow T : ref struct
?
Yes, this will break when we support ref struct
types as type arguments.
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.
LGTM Thanks (iteration 3) but please hold off merging until after PR #62941 (runtime flag) was merged
Fixes #63140