Skip to content

Commit

Permalink
Test with inaccessible method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Jun 13, 2016
1 parent 0e0bda3 commit bc3bd43
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,36 @@ static void Main()
);
}

[Fact]
public void DeconstructMethodInaccessible()
{
string source = @"
class C
{
static void Main()
{
int x;
string y;
(x, y) = new C1();
}
}
class C1
{
protected void Deconstruct(out int a, out string b) { a = 1; b = ""hello""; }
}
";
var comp = CreateCompilationWithMscorlib(source, references: new[] { ValueTupleRef, SystemRuntimeFacadeRef }, parseOptions: TestOptions.Regular.WithTuplesFeature());
comp.VerifyDiagnostics(
// (9,18): error CS0122: 'C1.Deconstruct(out int, out string)' is inaccessible due to its protection level
// (x, y) = new C1();
Diagnostic(ErrorCode.ERR_BadAccess, "new C1()").WithArguments("C1.Deconstruct(out int, out string)").WithLocation(9, 18),
// (9,18): error CS8206: No Deconstruct instance or extension method was found for type 'C1', with 2 out parameters.
// (x, y) = new C1();
Diagnostic(ErrorCode.ERR_MissingDeconstruct, "new C1()").WithArguments("C1", "2").WithLocation(9, 18)
);
}

[Fact]
public void StaticDeconstruct()
{
Expand Down

0 comments on commit bc3bd43

Please sign in to comment.