Skip to content

Conversation

@AlekseyTs
Copy link
Contributor

Closes #35227.

@AlekseyTs AlekseyTs requested a review from agocke June 21, 2019 17:32
@AlekseyTs AlekseyTs requested a review from a team as a code owner June 21, 2019 17:32
@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented Jun 21, 2019

@agocke, @dotnet/roslyn-compiler Please review. #Closed

@jcouv jcouv added this to the 16.2.P4 milestone Jun 21, 2019
{
implementedMember = interfaceMember;
}
Action<DiagnosticBag, MethodSymbol, MethodSymbol, (TypeSymbol implementingType, bool isExplicit)> reportMismatchInReturnType =
Copy link
Member

@333fred 333fred Jun 21, 2019

Choose a reason for hiding this comment

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

Consider making these local functions so we can make them static and easily verify that they are not capturing. #ByDesign

Copy link
Member

Choose a reason for hiding this comment

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

+1 on that


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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Delegates for lambdas are cached automatically.


In reply to: 296389943 [](ancestors = 296389943,296380417)

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, for me it's less about caching and more about readability.


In reply to: 296390411 [](ancestors = 296390411,296389943,296380417)

checkParameters: overridingProperty.SetMethod is null);
checkParameters: overridingProperty.SetMethod is null ||
overriddenGetMethod?.AssociatedSymbol != overriddenProperty ||
overriddenProperty.GetOwnOrInheritedSetMethod()?.AssociatedSymbol != overriddenProperty);
Copy link
Member

@333fred 333fred Jun 21, 2019

Choose a reason for hiding this comment

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

Could consider extracting this check to a helper, as we use it in multiple places. #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could consider extracting this check to a helper, as we use it in multiple places.

I do not believe it is worth doing just for portion of the condition, the entire condition is different.


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

}
CheckValidNullableMethodOverride(overridingMethod.DeclaringCompilation, overriddenMethod, overridingMethod, diagnostics,
checkReturnType ?
(diagnostics, overriddenMethod, overridingMethod, location) => diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInReturnTypeOnOverride, location) :
Copy link
Member

@333fred 333fred Jun 21, 2019

Choose a reason for hiding this comment

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

overriddenMethod, overridingMethod [](start = 66, length = 34)

Consider using _ for ignored parameter. #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider using _ for ignored parameter.

I see no point in doing this, it is not hard for me to type the names and it is better for readability in my opinion. Also, I do not think both parameters can be named _.


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

(diagnostics, overriddenMethod, overridingMethod, location) => diagnostics.Add(ErrorCode.WRN_NullabilityMismatchInReturnTypeOnOverride, location) :
(Action<DiagnosticBag, MethodSymbol, MethodSymbol, Location>)null,
checkParameters ?
(diagnostics, overriddenMethod, overridingMethod, overridingParameter, location) =>
Copy link
Member

@jcouv jcouv Jun 21, 2019

Choose a reason for hiding this comment

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

(diagnostics, overriddenMethod, overridingMethod, overridingParameter, location) => [](start = 53, length = 83)

nit: consider using a local function for those funcs in various invocations of CheckValidNullableEventOverride #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: consider using a local function for those funcs in various invocations of CheckValidNullableEventOverride

Lambdas are used intentionally to take advantage of automatic caching.


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

return;
}

if (reportMismatchInParameterType == null)
Copy link
Member

@333fred 333fred Jun 21, 2019

Choose a reason for hiding this comment

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

Consider moving this if before the previous one, and removing the reportMismatchInParameterType != null check from that one. #Closed

Copy link
Member

Choose a reason for hiding this comment

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

Wait, ignore. Misread parameter for return.


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

}
}

private static bool CheckValidNullableOverride(
Copy link
Member

@jcouv jcouv Jun 21, 2019

Choose a reason for hiding this comment

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

CheckValidNullableOverride [](start = 28, length = 26)

nit: name of the method is a bit misleading as it doesn't actually perform a check. Maybe ShouldCheck...? #Resolved

Symbol overriddenMember,
Symbol overridingMember)
{
if (overriddenMember is null ||
Copy link
Member

@333fred 333fred Jun 21, 2019

Choose a reason for hiding this comment

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

Nit: you could just return ! this condition. #Resolved

@333fred
Copy link
Member

333fred commented Jun 21, 2019

Done review pass (commit 2). Mostly looks good, just a couple of small formatting suggestions. #Resolved

@jcouv
Copy link
Member

jcouv commented Jun 21, 2019

public abstract event System.Action<string> E1; 

If not covered elsewhere, consider extending this test to add event Action<string?> in the base which is overridden with event Action<string>. Should produce no warning. #Resolved


Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs:11173 in aff03fd. [](commit_id = aff03fd, deletion_comment = False)

@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented Jun 21, 2019

public abstract event System.Action<string> E1; 

If not covered elsewhere, consider extending this test to add event Action<string?> in the base which is overridden with event Action. Should produce no warning.

I find existing coverage sufficient.


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


Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs:11173 in aff03fd. [](commit_id = aff03fd, deletion_comment = False)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 2)

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 3)

@AlekseyTs AlekseyTs merged commit d16d3a5 into dotnet:master Jun 24, 2019
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.

Support nullable variance in interface implementation

3 participants