-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix GetSymbolInfo on ValueTuple declaration #43467
Changes from 6 commits
c241af8
61ebdde
2d4e9e2
3107fa3
cb36a3c
b5fdc2e
fc40b64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4210,6 +4210,51 @@ public void M2(C c) | |
); | ||
} | ||
|
||
[Fact] | ||
public void TestInConstructorOverloadWithUseSiteError() | ||
{ | ||
var missing = @"public class Missing { }"; | ||
var missingComp = CreateCompilation(missing, assemblyName: "missing"); | ||
|
||
var lib = @" | ||
public class C | ||
{ | ||
public C(Missing m) => throw null; | ||
public C(D d) => throw null; | ||
} | ||
public class D { } | ||
"; | ||
var libComp = CreateCompilation(lib, references: new[] { missingComp.EmitToImageReference() }); | ||
|
||
var source = @" | ||
class D | ||
{ | ||
public void M() | ||
{ | ||
new C(new()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is also not quite the scenario, the errors are not reported due to target typed new. We want the target typed new to be the only source of errors. Here we are mixing too much together. #Closed |
||
new C(default); | ||
new C(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This scenarios are not interesting (were not requested) because they are not using target typed new #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, duh! My bad There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reacted too quickly. This test is testing target-typed new (first scenario) and comparing with I can also test |
||
C c = new(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please add a test for a target typed new as an argument of a call that would assert use-site errors caused by the target typed new. |
||
} | ||
} | ||
"; | ||
var comp = CreateCompilation(source, references: new[] { libComp.EmitToImageReference() }); | ||
comp.VerifyDiagnostics( | ||
// (6,13): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. | ||
// new C(new()); | ||
Diagnostic(ErrorCode.ERR_NoTypeDef, "C").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 13), | ||
// (7,13): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. | ||
// new C(default); | ||
Diagnostic(ErrorCode.ERR_NoTypeDef, "C").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 13), | ||
// (8,13): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. | ||
// new C(null); | ||
Diagnostic(ErrorCode.ERR_NoTypeDef, "C").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(8, 13), | ||
// (9,15): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. | ||
// C c = new(null); | ||
Diagnostic(ErrorCode.ERR_NoTypeDef, "new(null)").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(9, 15) | ||
); | ||
} | ||
|
||
[Fact] | ||
public void UseSiteWarning() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test added to cover changes in MethodCompiler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it covers the handling in
if (fieldSymbol.IsFixedSizeBuffer && compilationState.Emitting)
that is now reachable.