Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -159,11 +159,9 @@ private TypeSymbol DecodeType(TypeSymbol type)
switch (type.Kind)
{
case SymbolKind.ErrorType:
if (type.HasUseSiteError)
{
_foundUsableErrorType = true;
}
_foundUsableErrorType = true;
return type;

case SymbolKind.DynamicType:
case SymbolKind.TypeParameter:
case SymbolKind.PointerType:
Expand Down
30 changes: 30 additions & 0 deletions src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26095,6 +26095,36 @@ public static void Main()
CompileAndVerify(executeComp, expectedOutput: "ran");
}

[Fact]
[WorkItem(41699, "https://github.com/dotnet/roslyn/issues/41699")]
public void MissingBaseType_TupleTypeArgumentWithNames()
{
var sourceA =
@"public class A<T> { }";
var comp = CreateCompilation(sourceA, assemblyName: "A");
var refA = comp.EmitToImageReference();

var sourceB =
@"public class B : A<(object X, B Y)> { }";
comp = CreateCompilation(sourceB, references: new[] { refA });
var refB = comp.EmitToImageReference();

var sourceC =
@"class Program
{
static void Main()
{
var b = new B();
b.ToString();
}
}";
comp = CreateCompilation(sourceC, references: new[] { refB });
comp.VerifyDiagnostics(
// (6,11): error CS0012: The type 'A<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'A, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// b.ToString();
Diagnostic(ErrorCode.ERR_NoTypeDef, "ToString").WithArguments("A<>", "A, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 11));
}

[Fact]
[WorkItem(21727, "https://github.com/dotnet/roslyn/issues/21727")]
public void FailedDecodingOfTupleNamesWhenMissingValueTupleType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Private Function DecodeType(type As TypeSymbol) As TypeSymbol
Select Case type.Kind
Case SymbolKind.ErrorType

If type.GetUseSiteErrorInfo() IsNot Nothing Then
_foundUsableErrorType = True
End If
_foundUsableErrorType = True
Return type

Case SymbolKind.DynamicType,
Expand Down
33 changes: 33 additions & 0 deletions src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb
Original file line number Diff line number Diff line change
Expand Up @@ -22800,6 +22800,39 @@ End Class

End Sub

<Fact>
<WorkItem(41699, "https://github.com/dotnet/roslyn/issues/41699")>
Public Sub MissingBaseType_TupleTypeArgumentWithNames()
Dim sourceA =
"Public Class A(Of T)
End Class"
Dim comp = CreateCompilation(sourceA, assemblyName:="A")
Dim refA = comp.EmitToImageReference()

Dim sourceB =
"Public Class B
Inherits A(Of (X As Object, Y As B))
End Class"
comp = CreateCompilation(sourceB, references:={refA})
Dim refB = comp.EmitToImageReference()

Dim sourceC =
"Module Program
Sub Main()
Dim b = New B()
b.ToString()
End Sub
End Module"
comp = CreateCompilation(sourceC, references:={refB})
comp.AssertTheseDiagnostics(
"BC30456: 'ToString' is not a member of 'B'.
b.ToString()
~~~~~~~~~~
BC30652: Reference required to assembly 'A, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' containing the type 'A(Of )'. Add one to your project.
b.ToString()
~~~~~~~~~~")
End Sub

<Fact>
<WorkItem(41207, "https://github.com/dotnet/roslyn/issues/41207")>
<WorkItem(1056281, "https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1056281")>
Expand Down