Skip to content

Commit

Permalink
Empty Display string, test for use-site errors, Visit throws
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Jun 13, 2016
1 parent bc3bd43 commit 3496abb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/Compilers/CSharp/Portable/BoundTree/Formatting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ internal partial class OutDeconstructVarPendingInference
{
public override object Display
{
get
{
return MessageID.IDS_FeatureTuples.Localize();
}
get { return string.Empty; }
}
}
}
6 changes: 6 additions & 0 deletions src/Compilers/CSharp/Portable/FlowAnalysis/DataFlowPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,12 @@ public override BoundNode VisitDeconstructionAssignmentOperator(BoundDeconstruct
return null;
}

public override BoundNode VisitOutDeconstructVarPendingInference(OutDeconstructVarPendingInference node)
{
// OutDeconstructVarPendingInference nodes are only used within initial binding, but don't survive past that stage
throw ExceptionUtilities.Unreachable;
}

public override BoundNode VisitIncrementOperator(BoundIncrementOperator node)
{
base.VisitIncrementOperator(node);
Expand Down
39 changes: 39 additions & 0 deletions src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,45 @@ class C1
);
}

[Fact]
public void DeconstructHasUseSiteError()
{
string libMissingSource = @"public class Missing { }";

string libSource = @"
public class C
{
public void Deconstruct(out Missing a, out Missing b) { a = new Missing(); b = new Missing(); }
}
";

string source = @"
class C1
{
static void Main()
{
object x, y;
(x, y) = new C();
}
}
";
var libMissingComp = CreateCompilationWithMscorlib(new string[] { libMissingSource }, assemblyName: "libMissingComp").VerifyDiagnostics();
var libMissingRef = libMissingComp.EmitToImageReference();

var libComp = CreateCompilationWithMscorlib(new string[] { libSource }, references: new[] { libMissingRef }, parseOptions: TestOptions.Regular.WithTuplesFeature()).VerifyDiagnostics();
var libRef = libComp.EmitToImageReference();

var comp = CreateCompilationWithMscorlib(new string[] { source }, references: new[] { libRef }, parseOptions: TestOptions.Regular.WithTuplesFeature());
comp.VerifyDiagnostics(
// (7,18): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'libMissingComp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// (x, y) = new C();
Diagnostic(ErrorCode.ERR_NoTypeDef, "new C()").WithArguments("Missing", "libMissingComp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 18),
// (7,18): error CS8206: No Deconstruct instance or extension method was found for type 'C', with 2 out parameters.
// (x, y) = new C();
Diagnostic(ErrorCode.ERR_MissingDeconstruct, "new C()").WithArguments("C", "2").WithLocation(7, 18)
);
}

[Fact]
public void StaticDeconstruct()
{
Expand Down

0 comments on commit 3496abb

Please sign in to comment.