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

Use discarded use site info for LookupSymbols scenario #67935

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ private ImmutableArray<ISymbol> LookupSymbolsInternal(
TypeSymbol containingType = (TypeSymbol)container;
foreach (MethodSymbol extensionMethod in lookupResult.Symbols)
{
var reduced = extensionMethod.ReduceExtensionMethod(containingType, Compilation);
var reduced = extensionMethod.ReduceExtensionMethod(containingType, Compilation, discardUseSiteInfo: true);
if ((object)reduced != null)
{
results.Add(reduced.GetPublicSymbol());
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ public override TResult Accept<TResult>(CSharpSymbolVisitor<TResult> visitor)
/// <param name="compilation">The compilation in which constraints should be checked.
/// Should not be null, but if it is null we treat constraints as we would in the latest
/// language version.</param>
public MethodSymbol ReduceExtensionMethod(TypeSymbol receiverType, CSharpCompilation compilation)
public MethodSymbol ReduceExtensionMethod(TypeSymbol receiverType, CSharpCompilation compilation, bool discardUseSiteInfo = false)
{
if ((object)receiverType == null)
{
Expand All @@ -750,7 +750,7 @@ public MethodSymbol ReduceExtensionMethod(TypeSymbol receiverType, CSharpCompila
return null;
}

return ReducedExtensionMethodSymbol.Create(this, receiverType, compilation);
return ReducedExtensionMethodSymbol.Create(this, receiverType, compilation, discardUseSiteInfo);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ internal sealed class ReducedExtensionMethodSymbol : MethodSymbol
/// </summary>
/// <param name="compilation">Compilation used to check constraints.
/// The latest language version is assumed if this is null.</param>
public static MethodSymbol Create(MethodSymbol method, TypeSymbol receiverType, CSharpCompilation compilation)
public static MethodSymbol Create(MethodSymbol method, TypeSymbol receiverType, CSharpCompilation compilation, bool discardUseSiteInfo = false)
{
Debug.Assert(method.IsExtensionMethod && method.MethodKind != MethodKind.ReducedExtension);
Debug.Assert(method.ParameterCount > 0);
Debug.Assert((object)receiverType != null);

var useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.DiscardedDependencies;
var useSiteInfo = discardUseSiteInfo
? CompoundUseSiteInfo<AssemblySymbol>.Discarded
: CompoundUseSiteInfo<AssemblySymbol>.DiscardedDependencies;
Comment on lines +43 to +45
Copy link
Member Author

Choose a reason for hiding this comment

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

This may have a behavioral change, but let's see if it will be captured by tests and check whether it's an important scenario for LookupSymbols or not.


method = InferExtensionMethodTypeArguments(method, receiverType, compilation, ref useSiteInfo);
if ((object)method == null)
Expand Down