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

VB: Check overload resolution priority for basic scenarios involving methods #75862

Conversation

AlekseyTs
Copy link
Contributor

@AlekseyTs AlekseyTs commented Nov 11, 2024

Speclet - dotnet/vblang#627

@AlekseyTs
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jaredpar jaredpar added this to the 17.13 milestone Nov 13, 2024
@jaredpar jaredpar removed the untriaged Issues and PRs which have not yet been triaged by a lead label Nov 13, 2024
@AlekseyTs AlekseyTs requested a review from cston November 13, 2024 14:06
candidateInfoByDeclaringType.Free()
End Sub

Private Shared Sub ApplyTieBreakingRulesSkippedByCombineCandidates(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ApplyTieBreakingRulesSkippedByCombineCandidates

Effect of changes to CombineCandidates with this fixup was tested across all unit-tests that we have right now - #75792.

@arunchndr arunchndr modified the milestones: 17.13, 17.13 P2 Nov 13, 2024
@AlekseyTs
Copy link
Contributor Author

@333fred, @cston, @dotnet/roslyn-compiler Please review

@AlekseyTs
Copy link
Contributor Author

@333fred, @cston, @dotnet/roslyn-compiler Please review

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.

Done review pass

@AlekseyTs
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@AlekseyTs
Copy link
Contributor Author

@cston, @dotnet/roslyn-compiler For the second review

1 similar comment
@AlekseyTs
Copy link
Contributor Author

@cston, @dotnet/roslyn-compiler For the second review


Public Overrides ReadOnly Property OverloadResolutionPriority As Integer
Get
Return m_Method.OriginalDefinition.OverloadResolutionPriority
Copy link
Member

@cston cston Nov 15, 2024

Choose a reason for hiding this comment

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

OriginalDefinition

Are we testing cases that require OriginalDefinition in OverloadResolutionPriority or GetOverloadResolutionPriorityInfo()? #Resolved

Copy link
Contributor Author

@AlekseyTs AlekseyTs Nov 15, 2024

Choose a reason for hiding this comment

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

This is not required for correctness. The effect is not observable, other than us doing less work.


Public Overrides ReadOnly Property OverloadResolutionPriority As Integer
Get
Return _property.OriginalDefinition.OverloadResolutionPriority
Copy link
Member

@cston cston Nov 15, 2024

Choose a reason for hiding this comment

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

OriginalDefinition

Are we testing cases that require OriginalDefinition in OverloadResolutionPriority or GetOverloadResolutionPriorityInfo()? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not required for correctness. The effect is not observable, other than us doing less work.

@@ -1187,6 +1275,254 @@ ResolutionComplete:
Return New OverloadResolutionResult(candidates.ToImmutable(), resolutionIsLateBound, narrowingCandidatesRemainInTheSet, asyncLambdaSubToFunctionMismatch)
End Function

Private Shared ReadOnly s_poolInstance As ObjectPool(Of PooledDictionary(Of NamedTypeSymbol, NamedTypeSymbol)) =
Copy link
Member

@cston cston Nov 15, 2024

Choose a reason for hiding this comment

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

s_poolInstance

Is this used? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this used?

Thanks for catching this. It is meant to be used for candidateInfoByDeclaringType in the method below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wouldn't affect the result though since we are comparing definitions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in #75941

@@ -4080,15 +4400,17 @@ Bailout:
' This rule also applies to the types that extension methods are defined on.
'7.2. If M and N are extension methods and the target type of M is a class or
' structure and the target type of N is an interface, eliminate N from the set.
If ShadowBasedOnReceiverType(existingCandidate, newCandidate, existingWins, newWins, useSiteInfo) Then
If (Not someCandidatesHaveOverloadResolutionPriority OrElse
(signatureMatch AndAlso Not (existingCandidate.Candidate.IsExtensionMethod OrElse newCandidate.Candidate.IsExtensionMethod))) AndAlso
Copy link
Member

@cston cston Nov 15, 2024

Choose a reason for hiding this comment

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

What effect does this OrElse clause have, and are we testing it? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What effect does this OrElse clause have, and are we testing it?

EarlyFilteringOnReceiverType_01 fails if we remove it. The meaning of it is pretty much similar to what the comment before the previous If says. I.e. priority filtering for extension methods must come before filtering by receiver. Because for extension methods the filtering by receiver is not about shadowing by signature between methods declared in base and derived types.

Copy link
Member

@cston cston Nov 15, 2024

Choose a reason for hiding this comment

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

It looks like EarlyFilteringOnReceiverType_01 still passes if the entire OrElse ... clause is removed.

Copy link
Contributor Author

@AlekseyTs AlekseyTs Nov 15, 2024

Choose a reason for hiding this comment

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

I am not sure what you did, but when I remove AndAlso Not (existingCandidate.Candidate.IsExtensionMethod OrElse newCandidate.Candidate.IsExtensionMethod) part, the test fails for me. Perhaps that should be taken offline.

Copy link
Member

Choose a reason for hiding this comment

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

As we discussed, I was referring to the entire OrElse (signatureMatch AndAlso Not (...)).

333fred added a commit to 333fred/roslyn that referenced this pull request Nov 15, 2024
@@ -45,6 +46,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Private _lazyObsoleteAttributeData As ObsoleteAttributeData = ObsoleteAttributeData.Uninitialized

Private _lazyIsRequired As ThreeState = ThreeState.Unknown
Private _lazyOverloadResolutionPriority As StrongBox(Of Integer)
Copy link
Member

@cston cston Nov 15, 2024

Choose a reason for hiding this comment

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

StrongBox

Should we add an UncommonFields class to hold most of the _lazy* fields? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we have to, and I decided against doing this work under umbrella of this feature.

333fred added a commit that referenced this pull request Nov 15, 2024
End Sub

<Fact>
Public Sub DefaultProperty_01()
Copy link
Member

@cston cston Nov 16, 2024

Choose a reason for hiding this comment

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

DefaultProperty_01

Is this test affected by the compiler change? Should Main() contain a call to the default property? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this test affected by the compiler change?

No. But the test demonstrates that there are no interesting scenarios when parameter-less property is marked default

Should Main() contain a call to the default property?

I do not find it interesting, given the declaration error

End Sub

<Fact>
Public Sub DefaultProperty_02()
Copy link
Member

@cston cston Nov 16, 2024

Choose a reason for hiding this comment

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

DefaultProperty_02

Is this test affected by the compiler change? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this test affected by the compiler change?

No. But the test demonstrates that there are no interesting scenarios when a parameter-less property is overloaded with default property

@AlekseyTs AlekseyTs merged commit b5f6a24 into dotnet:features/VBOverloadResolutionPriority Nov 16, 2024
28 of 31 checks passed
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.

5 participants