Skip to content
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

Compare constraints lazily across partial type declarations #34850

Merged
merged 2 commits into from
Apr 9, 2019

Conversation

cston
Copy link
Member

@cston cston commented Apr 8, 2019

Fixes #34841.

@cston cston requested a review from a team as a code owner April 8, 2019 23:16
{
var typeParameters = TypeParameters;

if (constraintClauses.Length > 0)
Copy link
Contributor

@AlekseyTs AlekseyTs Apr 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (constraintClauses.Length > 0) [](start = 12, length = 33)

Is this check redundant? #Closed

private ImmutableArray<TypeParameterConstraintClause> MakeTypeParameterConstraintsLate(
ImmutableArray<TypeParameterConstraintClause> constraintClauses,
DiagnosticBag diagnostics)
{
Copy link
Contributor

@AlekseyTs AlekseyTs Apr 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ [](start = 8, length = 1)

Consider adding an assert constraintClauses.IsEarly() #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Apr 8, 2019

Could you provide some details on what was the root cause of the stack overflow? #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Apr 8, 2019

Done with review pass (iteration 1) #Closed

@cston
Copy link
Member Author

cston commented Apr 9, 2019

HaveSameConstraints() compares IEquatable<T> with IEquatable<T>. The comparison calls TypeWithAnnotations.Equals() with T and T which calls IsValueType on each TypeParameter, and IsValueType requires the constraints.


In reply to: 481044805 [](ancestors = 481044805)

@cston
Copy link
Member Author

cston commented Apr 9, 2019

@dotnet/roslyn-compiler please review.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (iteration 2)

}";
var comp = CreateCompilation(new[] { source1, source2 });
comp.VerifyDiagnostics(
// (3,15): error CS0265: Partial declarations of 'C<T>' have inconsistent constraints for type parameter 'T'
Copy link
Member

@333fred 333fred Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably unrelated, but this is a terrible error message. We should say what the inconsistencies are. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like #30229 is tracking this diagnostic.


In reply to: 273679942 [](ancestors = 273679942)

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (commit 2). I do wish that the error message there was better though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants