提交 851fa0c3 编写于 作者: C Charles Stoner

Handle MissingPredefinedMember in AsyncRewriter

上级 80e8a77c
......@@ -206,7 +206,7 @@ internal void GenerateMoveNext(BoundStatement body, MethodSymbol moveNextMethod)
F.SequencePoint(
body.Syntax,
F.Block(
locals.ToImmutableAndFree(),
locals.ToImmutableAndFree(),
newStatements));
if (rootScopeHoistedLocals.Length > 0)
......
......@@ -62,7 +62,15 @@ internal partial class AsyncRewriter : StateMachineRewriter
return body;
}
return rewriter.Rewrite();
try
{
return rewriter.Rewrite();
}
catch (SyntheticBoundNodeFactory.MissingPredefinedMember ex)
{
diagnostics.Add(ex.Diagnostic);
return new BoundBadStatement(body.Syntax, ImmutableArray.Create<BoundNode>(body), hasErrors: true);
}
}
/// <returns>
......
......@@ -590,7 +590,7 @@ .maxstack 4
");
}
[WorkItem(217748, "https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=21774")]
[WorkItem(217748, "https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=217748")]
[Fact]
public void BadExpressionConstructor()
{
......
......@@ -15341,6 +15341,48 @@ .maxstack 10
");
}
[Fact]
public void MissingCSharpArgumentInfoCreate()
{
string source =
@"class C
{
static void F(dynamic d)
{
d.F();
}
}";
var comp = CreateCompilationWithMscorlib45(
new[] { DynamicAttributeSource, source },
references: new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929 });
comp.VerifyEmitDiagnostics(
// (5,9): error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
// d.F();
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "d").WithArguments("Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo", "Create").WithLocation(5, 9));
}
[Fact]
[WorkItem(377883, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=377883")]
public void MissingCSharpArgumentInfoCreate_Async()
{
string source =
@"using System.Threading.Tasks;
class C
{
static async Task F(dynamic d)
{
await d;
}
}";
var comp = CreateCompilationWithMscorlib45(
new[] { DynamicAttributeSource, source },
references: new[] { SystemRef_v4_0_30319_17929, SystemCoreRef_v4_0_30319_17929 });
comp.VerifyEmitDiagnostics(
// (6,15): error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
// await d;
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "d").WithArguments("Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo", "Create").WithLocation(6, 15));
}
#endregion
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册