Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
402aca3d
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,发现更多精彩内容 >>
提交
402aca3d
编写于
2月 05, 2018
作者:
V
vsadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes:#24627
上级
b410ccf1
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
90 addition
and
40 deletion
+90
-40
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
+41
-30
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
+13
-10
src/Compilers/CSharp/Test/Semantic/Semantics/SpanStackSafetyTests.cs
...rs/CSharp/Test/Semantic/Semantics/SpanStackSafetyTests.cs
+36
-0
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
浏览文件 @
402aca3d
...
...
@@ -3377,7 +3377,9 @@ private static bool IsNegativeConstantForArraySize(BoundExpression expression)
var
refKinds
=
analyzedArguments
.
RefKinds
.
ToImmutableOrNull
();
var
argsToParamsOpt
=
memberResolutionResult
.
Result
.
ArgsToParamsOpt
;
hasErrors
|=
!
CheckInvocationArgMixing
(
if
(!
hasErrors
)
{
hasErrors
=
!
CheckInvocationArgMixing
(
nonNullSyntax
,
resultMember
,
receiver
,
...
...
@@ -3387,6 +3389,7 @@ private static bool IsNegativeConstantForArraySize(BoundExpression expression)
argsToParamsOpt
,
this
.
LocalScopeDepth
,
diagnostics
);
}
return
new
BoundCall
(
nonNullSyntax
,
...
...
@@ -4491,7 +4494,10 @@ private bool IsConstructorAccessible(MethodSymbol constructor, ref HashSet<Diagn
var
arguments
=
analyzedArguments
.
Arguments
.
ToImmutable
();
var
refKinds
=
analyzedArguments
.
RefKinds
.
ToImmutableOrNull
();
var
argToParams
=
memberResolutionResult
.
Result
.
ArgsToParamsOpt
;
hasError
|=
!
CheckInvocationArgMixing
(
if
(!
hasError
)
{
hasError
=
!
CheckInvocationArgMixing
(
node
,
method
,
null
,
...
...
@@ -4501,6 +4507,7 @@ private bool IsConstructorAccessible(MethodSymbol constructor, ref HashSet<Diagn
argToParams
,
this
.
LocalScopeDepth
,
diagnostics
);
}
result
=
new
BoundObjectCreationExpression
(
node
,
...
...
@@ -6816,7 +6823,10 @@ private BoundExpression BindIndexedPropertyAccess(SyntaxNode syntax, BoundExpres
}
var
arguments
=
analyzedArguments
.
Arguments
.
ToImmutable
();
gotError
|=
!
CheckInvocationArgMixing
(
if
(!
gotError
)
{
gotError
=
!
CheckInvocationArgMixing
(
syntax
,
property
,
receiver
,
...
...
@@ -6826,6 +6836,7 @@ private BoundExpression BindIndexedPropertyAccess(SyntaxNode syntax, BoundExpres
argsToParams
,
this
.
LocalScopeDepth
,
diagnostics
);
}
propertyAccess
=
new
BoundIndexerAccess
(
syntax
,
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
浏览文件 @
402aca3d
...
...
@@ -1066,7 +1066,9 @@ private static void CheckRestrictedTypeReceiver(BoundExpression expression, Comp
Debug
.
Assert
(
args
.
IsDefaultOrEmpty
||
(
object
)
receiver
!=
(
object
)
args
[
0
]);
gotError
|=
!
CheckInvocationArgMixing
(
if
(!
gotError
)
{
gotError
=
!
CheckInvocationArgMixing
(
node
,
method
,
receiver
,
...
...
@@ -1076,6 +1078,7 @@ private static void CheckRestrictedTypeReceiver(BoundExpression expression, Comp
argsToParams
,
this
.
LocalScopeDepth
,
diagnostics
);
}
if
((
object
)
delegateTypeOpt
!=
null
)
{
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/SpanStackSafetyTests.cs
浏览文件 @
402aca3d
...
...
@@ -1382,5 +1382,41 @@ void Check()
// public static Point field1;
Diagnostic
(
ErrorCode
.
ERR_FieldAutoPropCantBeByRefLike
,
"Point"
).
WithArguments
(
"Point"
).
WithLocation
(
7
,
19
));
}
[
Fact
]
[
WorkItem
(
24627
,
"https://github.com/dotnet/roslyn/issues/24627"
)]
public
void
ArgMixingBogusInstanceCall
()
{
var
comp
=
CreateCompilationWithMscorlibAndSpan
(
@"
class Program
{
ref struct S1
{
public void Test(int x) => throw null;
public int this[int x] => throw null;
public S1(S1 x, int y) => throw null;
}
static void Main()
{
// these are all errors, we should not be doing escape analysis on them.
S1.Test(1);
var x = S1[1];
var y = new S1(S1, 1);
}
}"
);
comp
.
VerifyDiagnostics
(
// (14,9): error CS0120: An object reference is required for the non-static field, method, or property 'Program.S1.Test(int)'
// S1.Test(1);
Diagnostic
(
ErrorCode
.
ERR_ObjectRequired
,
"S1.Test"
).
WithArguments
(
"Program.S1.Test(int)"
).
WithLocation
(
14
,
9
),
// (15,17): error CS0119: 'Program.S1' is a type, which is not valid in the given context
// var x = S1[1];
Diagnostic
(
ErrorCode
.
ERR_BadSKunknown
,
"S1"
).
WithArguments
(
"Program.S1"
,
"type"
).
WithLocation
(
15
,
17
),
// (16,24): error CS0119: 'Program.S1' is a type, which is not valid in the given context
// var y = new S1(S1, 1);
Diagnostic
(
ErrorCode
.
ERR_BadSKunknown
,
"S1"
).
WithArguments
(
"Program.S1"
,
"type"
).
WithLocation
(
16
,
24
)
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录