-
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
Bind allows
constraint clause
#72386
Bind allows
constraint clause
#72386
Conversation
} | ||
} | ||
|
||
continue; |
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.
Can we get here if hasRefStructConstraint
is false
and if so, should we report an error? #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.
Can we get here if
hasRefStructConstraint
isfalse
and if so, should we report an error?
I do not think it is possible to get such a tree from the parser. The syntax node description requires at least one item in the list. So, if someone somehow manages to create an allows
clause with an empty list of constraints, that is on them and I am very comfortable to not report any errors about that. We generally do not guard against shapes that cannot come from our parser.
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.
Makes sense, thanks. We probably don't want to have an assert here either, since one could create the tree manually, right?
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.
We probably don't want to have an assert here either, since one could create the tree manually, right?
Right. The code is not making an assumption that the list is not empty. Therefore, having the assert is probably inappropriate.
{ | ||
if (inherited) | ||
{ | ||
Location location = typeParameter.GetFirstLocation(); |
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 got the impression that getting location unnecessarily might be expensive - if that's true, could we pass typeParameter to the diagnostics instead? #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.
I got the impression that getting location unnecessarily might be expensive - if that's true, could we pass typeParameter to the diagnostics instead?
There is no overload that takes TypeParameterSymbol. A couple of conditions should be met before we get here. I don't think the situation is going to be very common and I prefer to not complicate the code until we have data indicating that there is a problem to fix.
@cston, @dotnet/roslyn-compiler For the second review |
<value>Target runtime doesn't support by-ref-like generics.</value> | ||
</data> | ||
<data name="ERR_RefStructConstraintAlreadySpecified" xml:space="preserve"> | ||
<value>The 'ref struct' is already specified.</value> |
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.
{ | ||
} | ||
|
||
public class C1 {} |
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 removing unused type, in this test and the following test. #Pending
Assert.Equal("C1", t.ConstraintTypesNoUseSiteDiagnostics.Single().ToTestDisplayString()); | ||
|
||
Assert.True(t.AllowByRefLike); | ||
} |
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.
ac9b1c2
into
dotnet:features/RefStructInterfaces
No description provided.