[Fact]
public void TestErrorsImplementingGenericNestedInterfaces_Explicit()
{
var text = @"
using System.Collections.Generic;
class Outer<T>
{
internal class Inner<U>
{
protected internal interface Interface<V, W>
{
T Property { set; }
void Method<Z>(T a, U[] b, List<V> c, Dictionary<W, Z> d);
}
internal class Derived4
{
internal class Derived5 : Outer<T>.Inner<U>.Interface<U, T>
{
T Outer<T>.Inner<U>.Interface<U, T>.Property
{
set { }
}
void Inner<U>.Interface<U, T>.Method<K>(T a, U[] b, List<U> c, Dictionary<K, T> D)
{
}
}
internal class Derived6 : Outer<T>.Inner<U>.Interface<U, T>
{
T Outer<T>.Inner<U>.Interface<U, T>.Property
{
set { }
}
void Inner<U>.Interface<U, T>.Method<K>(T a, U[] b, List<U> c, Dictionary<T, K> D)
{
}
}
}
}
}
";
// The following error is unexpected:
// (24,39): error CS0535: 'Outer<T>.Inner<U>.Derived4.Derived6' does not implement interface member 'Outer<T>.Inner<U>.Interface<U, T>.Method<Z>(T, U[], List<U>, Dictionary<T, Z>)'
CreateCompilation(text, options: WithNonNullTypesTrue()).VerifyDiagnostics(
// (14,39): error CS0535: 'Outer<T>.Inner<U>.Derived4.Derived5' does not implement interface member 'Outer<T>.Inner<U>.Interface<U, T>.Method<Z>(T, U[], List<U>, Dictionary<T, Z>)'
// internal class Derived5 : Outer<T>.Inner<U>.Interface<U, T>
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Outer<T>.Inner<U>.Interface<U, T>").WithArguments("Outer<T>.Inner<U>.Derived4.Derived5", "Outer<T>.Inner<U>.Interface<U, T>.Method<Z>(T, U[], System.Collections.Generic.List<U>, System.Collections.Generic.Dictionary<T, Z>)").WithLocation(14, 39),
// (20,47): error CS0539: 'Outer<T>.Inner<U>.Derived4.Derived5.Method<K>(T, U[], List<U>, Dictionary<K, T>)' in explicit interface declaration is not a member of interface
// void Inner<U>.Interface<U, T>.Method<K>(T a, U[] b, List<U> c, Dictionary<K, T> D)
Diagnostic(ErrorCode.ERR_InterfaceMemberNotFound, "Method").WithArguments("Outer<T>.Inner<U>.Derived4.Derived5.Method<K>(T, U[], System.Collections.Generic.List<U>, System.Collections.Generic.Dictionary<K, T>)").WithLocation(20, 47),
// (24,39): error CS0535: 'Outer<T>.Inner<U>.Derived4.Derived6' does not implement interface member 'Outer<T>.Inner<U>.Interface<U, T>.Method<Z>(T, U[], List<U>, Dictionary<T, Z>)'
// internal class Derived6 : Outer<T>.Inner<U>.Interface<U, T>
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Outer<T>.Inner<U>.Interface<U, T>").WithArguments("Outer<T>.Inner<U>.Derived4.Derived6", "Outer<T>.Inner<U>.Interface<U, T>.Method<Z>(T, U[], System.Collections.Generic.List<U>, System.Collections.Generic.Dictionary<T, Z>)").WithLocation(24, 39)
);
}
[Fact]
public void TestErrorsImplementingGenericNestedInterfaces_Explicit_IncorrectPartialQualification()
{
var source = @"
using System.Collections.Generic;
class Outer<T>
{
internal class Inner<U>
{
protected internal interface Interface<V, W>
{
T Property { set; }
void Method<Z>(T a, U[] b, List<V> c, Dictionary<W, Z> d);
}
internal class Derived3 : Interface<long, string>
{
T Interface<long, string>.Property
{
set { }
}
void Inner<U>.Interface<long, string>.Method<K>(T a, U[] B, List<long> C, Dictionary<string, K> d)
{
}
}
}
}
";
// The following error is unexpected:
CreateCompilation(source, options: WithNonNullTypesTrue()).VerifyDiagnostics(
// (12,35): error CS0535: 'Outer<T>.Inner<U>.Derived3' does not implement interface member 'Outer<T>.Inner<U>.Interface<long, string>.Method<Z>(T, U[], List<long>, Dictionary<string, Z>)'
// internal class Derived3 : Interface<long, string>
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface<long, string>").WithArguments("Outer<T>.Inner<U>.Derived3", "Outer<T>.Inner<U>.Interface<long, string>.Method<Z>(T, U[], System.Collections.Generic.List<long>, System.Collections.Generic.Dictionary<string, Z>)").WithLocation(12, 35)
);
}