Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
787ebc2a
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
787ebc2a
编写于
2月 16, 2017
作者:
C
Charles Stoner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ignore non-delegate types binding lambda arguments for error recovery
上级
4fa6e3fe
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
84 addition
and
7 deletion
+84
-7
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
+2
-1
src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs
src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs
+82
-3
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Scope.cs
...arp/Test/Semantic/Semantics/PatternMatchingTests_Scope.cs
+0
-3
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
浏览文件 @
787ebc2a
...
@@ -1181,7 +1181,8 @@ private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedA
...
@@ -1181,7 +1181,8 @@ private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedA
foreach
(
var
parameterList
in
parameterListList
)
foreach
(
var
parameterList
in
parameterListList
)
{
{
var
parameterType
=
GetCorrespondingParameterType
(
analyzedArguments
,
i
,
parameterList
);
var
parameterType
=
GetCorrespondingParameterType
(
analyzedArguments
,
i
,
parameterList
);
if
(
parameterType
?.
Kind
==
SymbolKind
.
NamedType
)
if
(
parameterType
?.
Kind
==
SymbolKind
.
NamedType
&&
(
object
)
parameterType
.
GetDelegateType
()
!=
null
)
{
{
var
discarded
=
unboundArgument
.
Bind
((
NamedTypeSymbol
)
parameterType
);
var
discarded
=
unboundArgument
.
Bind
((
NamedTypeSymbol
)
parameterType
);
}
}
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs
浏览文件 @
787ebc2a
...
@@ -10925,9 +10925,6 @@ static bool TakeOutParam<T>(T y, out T x)
...
@@ -10925,9 +10925,6 @@ static bool TakeOutParam<T>(T y, out T x)
// (115,15): error CS0103: The name 'u9' does not exist in the current context
// (115,15): error CS0103: The name 'u9' does not exist in the current context
// Dummy(u9);
// Dummy(u9);
Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(115, 15),
Diagnostic(ErrorCode.ERR_NameNotInContext, "u9").WithArguments("u9").WithLocation(115, 15),
// (108,66): error CS0165: Use of unassigned local variable 'z9'
// group x > y9 && TakeOutParam(1, out var z9) && z9 ==
Diagnostic(ErrorCode.ERR_UseDefViolation, "z9").WithArguments("z9").WithLocation(108, 66),
// (121,24): error CS1931: The range variable 'y10' conflicts with a previous declaration of 'y10'
// (121,24): error CS1931: The range variable 'y10' conflicts with a previous declaration of 'y10'
// from y10 in new[] { 1 }
// from y10 in new[] { 1 }
Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "y10").WithArguments("y10").WithLocation(121, 24),
Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "y10").WithArguments("y10").WithLocation(121, 24),
...
@@ -28973,6 +28970,88 @@ public static void Main(int arg)
...
@@ -28973,6 +28970,88 @@ public static void Main(int arg)
Assert.Equal("System.Int32", symbol.Type.ToTestDisplayString());
Assert.Equal("System.Int32", symbol.Type.ToTestDisplayString());
}
}
}
}
[Fact]
[WorkItem(17208, "https://github.com/dotnet/roslyn/issues/17208")]
public void ErrorRecoveryShouldIgnoreNonDelegates()
{
var source =
@"using System;
class C
{
static void Main()
{
G(x => x > 0 && F(out var y) && y > 0);
}
static bool F(out int i)
{
i = 0;
return true;
}
static void G(Func<int, bool> f, object o) { }
static void G(C c, object o) { }
}";
var comp = CreateCompilationWithMscorlibAndSystemCore(source);
comp.VerifyDiagnostics(
// (6,9): error CS1501: No overload for method 'G' takes 1 arguments
// G(x => x > 0 && F(out var y) && y > 0);
Diagnostic(ErrorCode.ERR_BadArgCount, "G").WithArguments("G", "1").WithLocation(6, 9));
}
[Fact]
[WorkItem(17208, "https://github.com/dotnet/roslyn/issues/17208")]
public void ErrorRecoveryShouldIgnoreNonDelegates_Expression()
{
var source =
@"using System;
using System.Linq.Expressions;
class C
{
static void Main()
{
G(x => x > 0 && F(out var y) && y > 0);
}
static bool F(out int i)
{
i = 0;
return true;
}
static void G(Expression<Func<int, bool>> f, object o) { }
static void G(C c, object o) { }
}";
var comp = CreateCompilationWithMscorlibAndSystemCore(source);
comp.VerifyDiagnostics(
// (7,9): error CS1501: No overload for method 'G' takes 1 arguments
// G(x => x > 0 && F(out var y) && y > 0);
Diagnostic(ErrorCode.ERR_BadArgCount, "G").WithArguments("G", "1").WithLocation(7, 9));
}
[Fact]
[WorkItem(17208, "https://github.com/dotnet/roslyn/issues/17208")]
public void ErrorRecoveryShouldIgnoreNonDelegates_Query()
{
var source =
@"using System.Linq;
class C
{
static void M()
{
var c = from x in new[] { 1, 2, 3 }
group x > 1 && F(out var y) && y == null
by x;
}
static bool F(out object o)
{
o = null;
return true;
}
}";
var comp = CreateCompilationWithMscorlibAndSystemCore(source);
comp.VerifyDiagnostics(
// (7,38): error CS8201: Out variable and pattern variable declarations are not allowed within a query clause.
// group x > 1 && F(out var y) && y == null
Diagnostic(ErrorCode.ERR_ExpressionVariableInQueryClause, "y").WithLocation(7, 38));
}
}
}
internal static class OutVarTestsExtensions
internal static class OutVarTestsExtensions
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Scope.cs
浏览文件 @
787ebc2a
...
@@ -1787,9 +1787,6 @@ void Test11()
...
@@ -1787,9 +1787,6 @@ void Test11()
// (115,15): error CS0103: The name 'u9' does not exist in the current context
// (115,15): error CS0103: The name 'u9' does not exist in the current context
// Dummy(u9);
// Dummy(u9);
Diagnostic
(
ErrorCode
.
ERR_NameNotInContext
,
"u9"
).
WithArguments
(
"u9"
).
WithLocation
(
115
,
15
),
Diagnostic
(
ErrorCode
.
ERR_NameNotInContext
,
"u9"
).
WithArguments
(
"u9"
).
WithLocation
(
115
,
15
),
// (108,50): error CS0165: Use of unassigned local variable 'z9'
// group x > y9 && 1 is var z9 && z9 ==
Diagnostic
(
ErrorCode
.
ERR_UseDefViolation
,
"z9"
).
WithArguments
(
"z9"
).
WithLocation
(
108
,
50
),
// (121,24): error CS1931: The range variable 'y10' conflicts with a previous declaration of 'y10'
// (121,24): error CS1931: The range variable 'y10' conflicts with a previous declaration of 'y10'
// from y10 in new[] { 1 }
// from y10 in new[] { 1 }
Diagnostic
(
ErrorCode
.
ERR_QueryRangeVariableOverrides
,
"y10"
).
WithArguments
(
"y10"
).
WithLocation
(
121
,
24
),
Diagnostic
(
ErrorCode
.
ERR_QueryRangeVariableOverrides
,
"y10"
).
WithArguments
(
"y10"
).
WithLocation
(
121
,
24
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录