未验证 提交 7b359804 编写于 作者: C Charles Stoner 提交者: GitHub

Pass basesBeingResolved to BindTupleType (#44098)

上级 9e10e607
......@@ -441,7 +441,7 @@ internal NamespaceOrTypeOrAliasSymbolWithAnnotations BindNamespaceOrTypeOrAliasS
case SyntaxKind.TupleType:
{
var tupleTypeSyntax = (TupleTypeSyntax)syntax;
return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(tupleTypeSyntax.CloseParenToken), BindTupleType(tupleTypeSyntax, diagnostics));
return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(tupleTypeSyntax.CloseParenToken), BindTupleType(tupleTypeSyntax, diagnostics, basesBeingResolved));
}
case SyntaxKind.RefType:
......@@ -596,7 +596,7 @@ NamespaceOrTypeOrAliasSymbolWithAnnotations bindPointer()
return type;
}
private TypeSymbol BindTupleType(TupleTypeSyntax syntax, DiagnosticBag diagnostics)
private TypeSymbol BindTupleType(TupleTypeSyntax syntax, DiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved)
{
int numElements = syntax.Elements.Count;
var types = ArrayBuilder<TypeWithAnnotations>.GetInstance(numElements);
......@@ -611,7 +611,7 @@ private TypeSymbol BindTupleType(TupleTypeSyntax syntax, DiagnosticBag diagnosti
{
var argumentSyntax = syntax.Elements[i];
var argumentType = BindType(argumentSyntax.Type, diagnostics);
var argumentType = BindType(argumentSyntax.Type, diagnostics, basesBeingResolved);
types.Add(argumentType);
string name = null;
......
......@@ -2301,5 +2301,58 @@ class F : A<D*>.B { }
// class E : A<C*>.B { }
Diagnostic(ErrorCode.ERR_ManagedAddr, "E").WithArguments("Base.C").WithLocation(12, 11));
}
[Fact]
[WorkItem(1107185, "https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1107185")]
public void Tuple_MissingNestedTypeArgument_01()
{
var source =
@"interface I<T>
{
}
class A : I<(object, A.B)>
{
}";
var comp = CreateCompilation(source);
comp.VerifyDiagnostics(
// (4,24): error CS0146: Circular base class dependency involving 'A' and 'A'
// class A : I<(object, A.B)>
Diagnostic(ErrorCode.ERR_CircularBase, "B").WithArguments("A", "A").WithLocation(4, 24));
}
[Fact]
[WorkItem(1107185, "https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1107185")]
public void Tuple_MissingNestedTypeArgument_02()
{
var source =
@"class A<T>
{
}
class B : A<(object, B.C)>
{
}";
var comp = CreateCompilation(source);
comp.VerifyDiagnostics(
// (4,24): error CS0146: Circular base class dependency involving 'B' and 'B'
// class B : A<(object, B.C)>
Diagnostic(ErrorCode.ERR_CircularBase, "C").WithArguments("B", "B").WithLocation(4, 24));
}
[Fact]
public void Tuple_MissingNestedTypeArgument_03()
{
var source =
@"interface I<T>
{
}
class A : I<System.ValueTuple<object, A.B>>
{
}";
var comp = CreateCompilation(source);
comp.VerifyDiagnostics(
// (4,41): error CS0146: Circular base class dependency involving 'A' and 'A'
// class A : I<System.ValueTuple<object, A.B>>
Diagnostic(ErrorCode.ERR_CircularBase, "B").WithArguments("A", "A").WithLocation(4, 41));
}
}
}
......@@ -2434,6 +2434,54 @@ BC30296: Interface 'A(Of T)' cannot inherit from itself:
]]></errors>)
End Sub
<Fact>
Public Sub Tuple_MissingNestedTypeArgument_01()
Dim source =
"Interface I(Of T)
End Interface
Class A
Implements I(Of (Object, A.B))
End Class"
Dim comp = CreateCompilation(source)
comp.AssertTheseDiagnostics(<errors><![CDATA[
BC30002: Type 'A.B' is not defined.
Implements I(Of (Object, A.B))
~~~
]]></errors>)
End Sub
<Fact>
Public Sub Tuple_MissingNestedTypeArgument_02()
Dim source =
"Class A(Of T)
End Class
Class B
Inherits A(Of (Object, B.C))
End Class"
Dim comp = CreateCompilation(source)
comp.AssertTheseDiagnostics(<errors><![CDATA[
BC30002: Type 'B.C' is not defined.
Inherits A(Of (Object, B.C))
~~~
]]></errors>)
End Sub
<Fact>
Public Sub Tuple_MissingNestedTypeArgument_03()
Dim source =
"Interface I(Of T)
End Interface
Class A
Implements I(Of System.ValueTuple(Of Object, A.B))
End Class"
Dim comp = CreateCompilation(source)
comp.AssertTheseDiagnostics(<errors><![CDATA[
BC30002: Type 'A.B' is not defined.
Implements I(Of System.ValueTuple(Of Object, A.B))
~~~
]]></errors>)
End Sub
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册