-
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
Covariant returns part 3 #43797
Covariant returns part 3 #43797
Conversation
gafter
commented
Apr 29, 2020
•
edited
Loading
edited
- Test that covariant returns are recognized by the compiler from compilation references.
- Test that covariant methods imply metadata newslot and a methodimpl table entry.
- Test the type returned from calling a covariantly overridden method.
- Test that the compiler APIs agree whether viewed from source or metadata.
- Test VB consumption and overriding of covariant return methods declared in C#.
- Read covariant return override information [methodimpl] from metadata.
…e have a place to put necessary support library declarations.
0932ad2
to
2052dca
Compare
@dotnet/roslyn-compiler May I please have a review of these changes for covariant returns? This set of changes focuses on getting things working the same in source, compilation references, and metadata. #Resolved |
src/Compilers/CSharp/Portable/Symbols/OverriddenOrHiddenMembersHelpers.cs
Show resolved
Hide resolved
It doesn't look like metadata encoding is specified in https://github.com/dotnet/csharplang/blob/master/proposals/covariant-returns.md. Is there a different specification for that? #Closed |
@AlekseyTs https://github.com/dotnet/csharplang/blob/master/proposals/covariant-returns.md is a specification of the C# language change. The metadata specification is maintained by the runtime team, and you have been CC'ed on the relevant threads. A runtime design document is under review in dotnet/runtime#35308 and I expect that PR will be extended to include a draft augment for ECMA-335. I think I've responded to all of your comments. Do you have any others? #Resolved |
src/Compilers/CSharp/Portable/Symbols/OverriddenOrHiddenMembersHelpers.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/OverriddenOrHiddenMembersHelpers.cs
Show resolved
Hide resolved
Done reviewing compiler changes (iteration 7), tests are not looked at. #Closed |
@AlekseyTs I believe I've responded to all of your comments. Do you have any others? #Resolved |
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.this[]", "System.String Derived.this[System.Int32 i] { get; }", "System.Object Base.this[System.Int32 i] { get; }"); | ||
VerifyOverride(comp, "Derived.get_Item", "System.String Derived.this[System.Int32 i].get", "System.Object Base.this[System.Int32 i].get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.this[]", "U Derived<T, U>.this[System.Int32 i] { get; }", "T Base<T>.this[System.Int32 i] { get; }"); | ||
VerifyOverride(comp, "Derived.get_Item", "U Derived<T, U>.this[System.Int32 i].get", "T Base<T>.this[System.Int32 i].get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.this[]", "T Derived<T>.this[System.Int32 i] { get; }", "N Base.this[System.Int32 i] { get; }"); | ||
VerifyOverride(comp, "Derived.get_Item", "T Derived<T>.this[System.Int32 i].get", "N Base.this[System.Int32 i].get"); | ||
VerifyAssignments(comp); |
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.
Same question. #Resolved
@@ -387,6 +652,7 @@ static void verify(CSharpCompilation comp) | |||
VerifyOverride(comp, "Derived.P", "System.Func<System.String> Derived.P { get; set; }", "System.Func<System.Object> Base.P { get; set; }"); | |||
VerifyNoOverride(comp, "Derived.set_P"); | |||
VerifyOverride(comp, "Derived.get_P", "System.Func<System.String> Derived.P.get", "System.Func<System.Object> Base.P.get"); | |||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.M", "System.String Derived.M()", "System.Object Base.M()"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.M", "System.String Derived.M { get; }", "System.Object Base.M { get; }"); | ||
VerifyOverride(comp, "Derived.get_M", "System.String Derived.M.get", "System.Object Base.M.get"); | ||
VerifyAssignments(comp); |
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.
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.this[]", "System.String Derived.this[System.Int32 i] { get; }", "System.Object Base.this[System.Int32 i] { get; }"); | ||
VerifyOverride(comp, "Derived.get_Item", "System.String Derived.this[System.Int32 i].get", "System.Object Base.this[System.Int32 i].get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.M", "System.String Derived.M()", "System.Object Base.M()"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
@@ -544,6 +864,7 @@ public class Derived : Base | |||
static void verify(CSharpCompilation comp) | |||
{ | |||
VerifyOverride(comp, "Derived.M", "System.Object Derived.M()", "System.String Base.M()"); | |||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
@@ -605,6 +938,7 @@ static void verify(CSharpCompilation comp) | |||
VerifyNoOverride(comp, "Derived2.M2"); | |||
VerifyNoOverride(comp, "Derived3.M1"); | |||
VerifyNoOverride(comp, "Derived3.M2"); | |||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
VerifyOverride(comp, "Derived2.M3", "Base Derived2.M3 { get; }", "System.String Derived.M3 { get; }"); | ||
VerifyOverride(comp, "Derived2.get_M3", "Base Derived2.M3.get", "System.String Derived.M3.get"); | ||
|
||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
VerifyOverride(comp, "Derived.M2", "IOut<System.String> Derived.M2 { get; }", "IOut<System.Object> Base.M2 { get; }"); | ||
VerifyOverride(comp, "Derived.get_M2", "IOut<System.String> Derived.M2.get", "IOut<System.Object> Base.M2.get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
VerifyOverride(comp, "Derived.M2", "IOut<System.Object> Derived.M2 { get; }", "IOut<System.String> Base.M2 { get; }"); | ||
VerifyOverride(comp, "Derived.get_M2", "IOut<System.Object> Derived.M2.get", "IOut<System.String> Base.M2.get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
VerifyOverride(comp, "Derived.M2", "B Derived.M2 { get; }", "A Base.M2 { get; }"); | ||
VerifyOverride(comp, "Derived.get_M2", "B Derived.M2.get", "A Base.M2.get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.M", "System.String Derived.M { get; }", "System.IComparable Base.M { get; }"); | ||
VerifyOverride(comp, "Derived.get_M", "System.String Derived.M.get", "System.IComparable Base.M.get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
@@ -883,6 +1304,7 @@ static void verify(CSharpCompilation comp) | |||
VerifyNoOverride(comp, "Derived.Base.M2"); | |||
VerifyNoOverride(comp, "C.Base.M1"); | |||
VerifyNoOverride(comp, "C.Base.M2"); | |||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.P", "System.String Derived.P { get; }", "System.Object Base.P { get; set; }"); | ||
VerifyOverride(comp, "Derived.get_P", "System.String Derived.P.get", "System.Object Base.P.get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
@@ -956,6 +1398,7 @@ static void verify(CSharpCompilation comp) | |||
VerifyOverride(comp, "Derived2.P", "System.String Derived2.P { get; set; }", "System.String Derived.P { get; }"); | |||
VerifyOverride(comp, "Derived2.get_P", "System.String Derived2.P.get", "System.String Derived.P.get"); | |||
VerifyNoOverride(comp, "Derived2.set_P"); | |||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
@@ -998,6 +1450,7 @@ static void verify(CSharpCompilation comp) | |||
VerifyOverride(comp, "Derived.get_P", "System.String Derived.P.get", "System.Object Base.P.get"); | |||
VerifyOverride(comp, "Derived2.P", "System.String Derived2.P { set; }", "System.String Derived.P { get; }"); | |||
VerifyNoOverride(comp, "Derived2.set_P"); | |||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
|
||
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.P", "System.IComparable Derived.P { get; }", "System.Object Base.P { get; set; }"); | ||
VerifyOverride(comp, "Derived.get_P", "System.IComparable Derived.P.get", "System.Object Base.P.get"); | ||
VerifyOverride(comp, "Derived2.P", "System.String Derived2.P { get; }", "System.IComparable Derived.P { get; }"); | ||
VerifyOverride(comp, "Derived2.get_P", "System.String Derived2.P.get", "System.IComparable Derived.P.get"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
static void verify(CSharpCompilation comp) | ||
{ | ||
VerifyOverride(comp, "Derived.M", "System.String Derived.M(System.String s)", "System.Object Base<System.String>.M(System.String s)"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
{ | ||
VerifyOverride(comp, "Derived.M", "System.IComparable Derived.M()", "System.Object Base.M()"); | ||
VerifyOverride(comp, "Derived2.M", "System.String Derived2.M()", "System.IComparable Derived.M()"); | ||
VerifyAssignments(comp); |
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.
VerifyAssignments [](start = 16, length = 17)
Same question. #Resolved
count++; | ||
var initialValue = declarator.Initializer.Value; | ||
var typeInfo = model.GetTypeInfo(initialValue); | ||
Assert.True(typeInfo.Type.Equals(typeInfo.ConvertedType, TypeCompareKind.AllIgnoreOptions)); |
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.
Equals [](start = 46, length = 6)
What API is called here? #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.
This is calling Test.Utilities.Equals(this ITypeSymbol first, ITypeSymbol second, Microsoft.CodeAnalysis.TypeCompareKind typeCompareKind)
However, the ignore options aren't needed so this is changed to Assert.Equal(typeInfo.Type, typeInfo.ConvertedType)
in the following PR.
In reply to: 422144339 [](ancestors = 422144339)
Done with review pass (iteration 7) #Closed |
{ | ||
if (IsExplicitClassOverride) | ||
{ | ||
foreach (MethodSymbol method in ExplicitlyOverriddenMethods()) |
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.
ExplicitlyOverriddenMethods [](start = 52, length = 27)
I think it would be good to test scenarios when we fail to successfully resolve a MethodImpl. For example, the method is not found in the type, or the type is not found. Cover scenarios when the type is a class and an interface. Also in presence of other resolvable MethodImpls, from classes and interfaces, all combinations. #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.
@AlekseyTs I believe I've responded to all of your comments. Do you have any others? |
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.
Signing-off on iteration 7 with assumption that feedback is going to be addressed in the next PR, unless tracked by an issue.
You can see the issues already filed as noted and feedback already addressed in #44025 |