Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e36c388c
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,发现更多精彩内容 >>
提交
e36c388c
编写于
5月 22, 2017
作者:
G
Gen Lu
提交者:
GitHub
5月 22, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19674 from genlu/arglistFix
Fix crash when creating IArgument for `__arglist` argument
上级
cd2112cb
57033165
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
5 deletion
+63
-5
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
...arp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
+24
-5
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs
...arp/Test/Semantic/IOperation/IOperationTests_IArgument.cs
+39
-0
未找到文件。
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
浏览文件 @
e36c388c
...
...
@@ -515,12 +515,31 @@ private static bool IsSafeForReordering(BoundExpression expression, RefKind kind
//
// If neither of those are the case then we can just take an early out.
if
(
CanSkipRewriting
(
arguments
,
methodOrIndexer
,
expanded
,
argsToParamsOpt
,
invokedAsExtensionMethod
,
out
var
isComReceiver
))
{
if
(
CanSkipRewriting
(
arguments
,
methodOrIndexer
,
expanded
,
argsToParamsOpt
,
invokedAsExtensionMethod
,
out
var
_
))
{
// In this case, the invocation is not in expanded form and there's no named argument provided.
// So we just return list of arguments as is.
return
arguments
.
ZipAsArray
(
methodOrIndexer
.
GetParameters
(),
(
a
,
p
)
=>
BoundCall
.
CreateArgumentOperation
(
ArgumentKind
.
Explicit
,
p
,
a
));
ImmutableArray
<
ParameterSymbol
>
parameters
=
methodOrIndexer
.
GetParameters
();
ArrayBuilder
<
IArgument
>
argumentsBuilder
=
ArrayBuilder
<
IArgument
>.
GetInstance
(
arguments
.
Length
);
int
i
=
0
;
for
(;
i
<
parameters
.
Length
;
++
i
)
{
argumentsBuilder
.
Add
(
BoundCall
.
CreateArgumentOperation
(
ArgumentKind
.
Explicit
,
parameters
[
i
],
arguments
[
i
]));
}
// TODO: In case of __arglist, we will have more arguments than parameters,
// set the parameter to null for __arglist argument for now.
// https://github.com/dotnet/roslyn/issues/19673
for
(;
i
<
arguments
.
Length
;
++
i
)
{
argumentsBuilder
.
Add
(
BoundCall
.
CreateArgumentOperation
(
ArgumentKind
.
Explicit
,
null
,
arguments
[
i
]));
}
Debug
.
Assert
(
methodOrIndexer
.
GetIsVararg
()
^
parameters
.
Length
==
arguments
.
Length
);
return
argumentsBuilder
.
ToImmutableAndFree
();
}
return
BuildArgumentsInEvaluationOrder
(
syntax
,
...
...
@@ -558,7 +577,7 @@ private static bool IsSafeForReordering(BoundExpression expression, RefKind kind
((
MethodSymbol
)
methodOrIndexer
).
Parameters
[
0
].
Type
as
NamedTypeSymbol
:
methodOrIndexer
.
ContainingType
;
isComReceiver
=
(
object
)
receiverNamedType
!=
null
&&
receiverNamedType
.
IsComImport
;
isComReceiver
=
(
object
)
receiverNamedType
!=
null
&&
receiverNamedType
.
IsComImport
;
return
rewrittenArguments
.
Length
==
methodOrIndexer
.
GetParameterCount
()
&&
argsToParamsOpt
.
IsDefault
&&
...
...
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs
浏览文件 @
e36c388c
...
...
@@ -990,6 +990,45 @@ void M2(string x )
VerifyOperationTreeAndDiagnosticsForTest
<
InvocationExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
Fact
]
public
void
VarArgsCall
()
{
string
source
=
@"
using System;
public class P
{
void M()
{
/*<bind>*/Console.Write(""{0} {1} {2} {3} {4}"", 1, 2, 3, 4, __arglist(5))/*</bind>*/;
}
}
"
;
string
expectedOperationTree
=
@"
IInvocationExpression (static void System.Console.Write(System.String format, System.Object arg0, System.Object arg1, System.Object arg2, System.Object arg3, __arglist)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... arglist(5))')
Arguments(6): IArgument (ArgumentKind.Explicit, Matching Parameter: format) (OperationKind.Argument) (Syntax: '""{0} {1} {2} {3} {4}""')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: ""{0} {1} {2} {3} {4}"") (Syntax: '""{0} {1} {2} {3} {4}""')
IArgument (ArgumentKind.Explicit, Matching Parameter: arg0) (OperationKind.Argument) (Syntax: '1')
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: '1')
ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1')
IArgument (ArgumentKind.Explicit, Matching Parameter: arg1) (OperationKind.Argument) (Syntax: '2')
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: '2')
ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2')
IArgument (ArgumentKind.Explicit, Matching Parameter: arg2) (OperationKind.Argument) (Syntax: '3')
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: '3')
ILiteralExpression (Text: 3) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 3) (Syntax: '3')
IArgument (ArgumentKind.Explicit, Matching Parameter: arg3) (OperationKind.Argument) (Syntax: '4')
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: '4')
ILiteralExpression (Text: 4) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 4) (Syntax: '4')
IArgument (ArgumentKind.Explicit, Matching Parameter: null) (OperationKind.Argument, IsInvalid) (Syntax: '__arglist(5)')
IOperation: (OperationKind.None) (Syntax: '__arglist(5)')
Children(1): ILiteralExpression (Text: 5) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 5) (Syntax: '5')
"
;
var
expectedDiagnostics
=
DiagnosticDescription
.
None
;
VerifyOperationTreeAndDiagnosticsForTest
<
InvocationExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
Fact
]
public
void
InvalidConversionForDefaultArgument_InSource
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录