Skip to content

Commit a835dd8

Browse files
authored
Use NativeIntegerMethodSymbol to represent parameterles constructor. (#56093)
Fixes #49845.
1 parent 7f0d2b6 commit a835dd8

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/Compilers/CSharp/Portable/Symbols/NativeIntegerTypeSymbol.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public override ImmutableArray<Symbol> GetMembers()
7070
ImmutableArray<Symbol> makeMembers(ImmutableArray<Symbol> underlyingMembers)
7171
{
7272
var builder = ArrayBuilder<Symbol>.GetInstance();
73-
builder.Add(new SynthesizedInstanceConstructor(this));
7473
foreach (var underlyingMember in underlyingMembers)
7574
{
7675
Debug.Assert(_underlyingType.Equals(underlyingMember.ContainingSymbol));
@@ -103,6 +102,13 @@ ImmutableArray<Symbol> makeMembers(ImmutableArray<Symbol> underlyingMembers)
103102
break;
104103
}
105104
break;
105+
106+
case MethodKind.Constructor:
107+
if (underlyingMethod.ParameterCount == 0)
108+
{
109+
builder.Add(new NativeIntegerMethodSymbol(this, underlyingMethod, associatedSymbol: null));
110+
}
111+
break;
106112
}
107113
break;
108114
case PropertySymbol underlyingProperty:

src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,8 @@ static TypeSymbol getConstraintType(CSharpCompilation comp) =>
10941094
comp.GetMember<MethodSymbol>("B.F").TypeParameters[0].ConstraintTypesNoUseSiteDiagnostics[0].Type;
10951095
}
10961096

1097-
[ConditionalFact(typeof(NoUsedAssembliesValidation))] // The test hook is blocked by https://github.com/dotnet/roslyn/issues/49845
1097+
[Fact]
1098+
[WorkItem(49845, "https://github.com/dotnet/roslyn/issues/49845")]
10981099
public void Retargeting_06()
10991100
{
11001101
var source1 =
@@ -1108,6 +1109,25 @@ public struct Boolean { }
11081109
public struct Int32 { }
11091110
public class IntPtr { }
11101111
public class UIntPtr { }
1112+
1113+
public class Attribute {}
1114+
1115+
public class Enum {}
1116+
public enum AttributeTargets
1117+
{
1118+
Class = 0x4,
1119+
}
1120+
1121+
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
1122+
public sealed class AttributeUsageAttribute : Attribute
1123+
{
1124+
public bool AllowMultiple {get; set;}
1125+
public bool Inherited {get; set;}
1126+
public AttributeTargets ValidOn => 0;
1127+
public AttributeUsageAttribute(AttributeTargets validOn)
1128+
{
1129+
}
1130+
}
11111131
}";
11121132
var comp = CreateCompilation(new AssemblyIdentity("c804cc09-8f73-44a1-9cfe-9567bed1def6", new Version(1, 0, 0, 0)), new[] { source1 }, references: null);
11131133
var ref1 = comp.EmitToImageReference();
@@ -1117,6 +1137,7 @@ public class UIntPtr { }
11171137
{
11181138
}";
11191139
comp = CreateEmptyCompilation(sourceA, references: new[] { ref1 }, parseOptions: TestOptions.Regular9);
1140+
comp.VerifyEmitDiagnostics();
11201141

11211142
var refA = comp.ToMetadataReference();
11221143
var typeA = comp.GetMember<NamedTypeSymbol>("A").BaseTypeNoUseSiteDiagnostics;

0 commit comments

Comments
 (0)