From 070feb0d21c975a744c70b31a9b41511f894dc10 Mon Sep 17 00:00:00 2001 From: Mykola Balakin Date: Fri, 18 Jun 2021 17:33:01 +0300 Subject: [PATCH] Calculate TypeParameterKind based on the container type (#54104) --- .../Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs | 2 ++ .../ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs | 2 +- .../ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs index f4b779867241c..56979139e7487 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs @@ -30,6 +30,8 @@ public override bool IsImplicitlyDeclared get { return true; } } + public override TypeParameterKind TypeParameterKind => ContainingSymbol is MethodSymbol ? TypeParameterKind.Method : TypeParameterKind.Type; + internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder attributes) { base.AddSynthesizedAttributes(moduleBuilder, ref attributes); diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs index ae8dfb748892c..604bfbce2c7b8 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs @@ -45,7 +45,7 @@ public override int Ordinal public override TypeParameterKind TypeParameterKind { - get { return TypeParameterKind.Type; } + get { return ContainingSymbol is MethodSymbol ? TypeParameterKind.Method : TypeParameterKind.Type; } } public override bool HasConstructorConstraint diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb index 21c13af768ac3..19b822a4c7a74 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb @@ -42,7 +42,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Public Overrides ReadOnly Property TypeParameterKind As TypeParameterKind Get - Return TypeParameterKind.Type + Return If(TypeOf Me.ContainingSymbol Is MethodSymbol, TypeParameterKind.Method, TypeParameterKind.Type) End Get End Property