Skip to content

Commit 3dd27c2

Browse files
Copilotjcouv
andcommitted
Add VerifyDiagnostics checks to all BaseType tests
Restored VerifyDiagnostics() calls to ensure compilations are error-free in all 5 BaseType tests. For the pointer test, added the expected unreferenced field warning diagnostic. Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
1 parent 0e3430a commit 3dd27c2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Compilers/CSharp/Test/Symbol/Symbols/GenericConstraintTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7475,6 +7475,7 @@ class Derived<T> where T : Base
74757475
}
74767476
""";
74777477
var comp = CreateCompilation(source);
7478+
comp.VerifyDiagnostics();
74787479

74797480
var typeParameter = (ITypeParameterSymbol)comp.GetTypeByMetadataName("Derived`1").TypeParameters[0].GetPublicSymbol();
74807481
Assert.Null(typeParameter.BaseType);
@@ -7492,6 +7493,7 @@ void M<T>() where T : class
74927493
}
74937494
""";
74947495
var comp = CreateCompilation(source);
7496+
comp.VerifyDiagnostics();
74957497

74967498
var typeParameter = (ITypeParameterSymbol)comp.GetTypeByMetadataName("C").GetMethod("M").TypeParameters[0].GetPublicSymbol();
74977499
Assert.Null(typeParameter.BaseType);
@@ -7501,6 +7503,7 @@ void M<T>() where T : class
75017503
public void ObjectType_BaseType_ReturnsNull()
75027504
{
75037505
var comp = CreateCompilation("");
7506+
comp.VerifyDiagnostics();
75047507

75057508
var objectType = (INamedTypeSymbol)comp.GetSpecialType(SpecialType.System_Object).GetPublicSymbol();
75067509
Assert.Null(objectType.BaseType);
@@ -7516,6 +7519,7 @@ interface IMyInterface
75167519
}
75177520
""";
75187521
var comp = CreateCompilation(source);
7522+
comp.VerifyDiagnostics();
75197523

75207524
var interfaceType = (INamedTypeSymbol)comp.GetTypeByMetadataName("IMyInterface").GetPublicSymbol();
75217525
Assert.Null(interfaceType.BaseType);
@@ -7531,6 +7535,10 @@ unsafe class C
75317535
}
75327536
""";
75337537
var comp = CreateCompilation(source, options: TestOptions.UnsafeDebugDll);
7538+
comp.VerifyDiagnostics(
7539+
// (3,10): warning CS0169: The field 'C.ptr' is never used
7540+
// int* ptr;
7541+
Diagnostic(ErrorCode.WRN_UnreferencedField, "ptr").WithArguments("C.ptr").WithLocation(3, 10));
75347542

75357543
var pointerType = (IPointerTypeSymbol)comp.GetTypeByMetadataName("C").GetField("ptr").Type.GetPublicSymbol();
75367544
Assert.Null(pointerType.BaseType);

0 commit comments

Comments
 (0)