Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9a600379
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,发现更多精彩内容 >>
提交
9a600379
编写于
4月 04, 2017
作者:
V
vsadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CR feedback
上级
e755fa8b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
9 deletion
+52
-9
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
...ers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
+5
-6
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
...Sharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
...rs/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Syntax/SyntaxNodeExtensions.cs
src/Compilers/CSharp/Portable/Syntax/SyntaxNodeExtensions.cs
+7
-1
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenInParametersTests.cs
...lers/CSharp/Test/Emit/CodeGen/CodeGenInParametersTests.cs
+38
-0
未找到文件。
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
浏览文件 @
9a600379
...
...
@@ -19,12 +19,12 @@ internal sealed class LocalFunctionSymbol : MethodSymbol
private
readonly
Symbol
_containingSymbol
;
private
readonly
DeclarationModifiers
_declarationModifiers
;
private
readonly
ImmutableArray
<
LocalFunctionTypeParameterSymbol
>
_typeParameters
;
private
readonly
RefKind
_refKind
;
private
ImmutableArray
<
ParameterSymbol
>
_lazyParameters
;
private
bool
_lazyIsVarArg
;
private
ImmutableArray
<
TypeParameterConstraintClause
>
_lazyTypeParameterConstraints
;
private
TypeSymbol
_lazyReturnType
;
private
RefKind
_lazyRefKind
;
private
TypeSymbol
_iteratorElementType
;
// Lock for initializing lazy fields and registering their diagnostics
...
...
@@ -73,7 +73,6 @@ internal sealed class LocalFunctionSymbol : MethodSymbol
}
_binder
=
binder
;
_syntax
.
ReturnType
.
SkipRef
(
out
_refKind
);
}
/// <summary>
...
...
@@ -184,7 +183,8 @@ internal override RefKind RefKind
{
get
{
return
_refKind
;
ComputeReturnType
();
return
_lazyRefKind
;
}
}
...
...
@@ -196,8 +196,7 @@ internal void ComputeReturnType()
}
var
diagnostics
=
DiagnosticBag
.
GetInstance
();
RefKind
refKind
;
TypeSyntax
returnTypeSyntax
=
_syntax
.
ReturnType
.
SkipRef
(
out
refKind
);
TypeSyntax
returnTypeSyntax
=
_syntax
.
ReturnType
.
SkipRef
(
out
_lazyRefKind
);
TypeSymbol
returnType
=
_binder
.
BindType
(
returnTypeSyntax
,
diagnostics
);
if
(
IsAsync
&&
returnType
.
SpecialType
!=
SpecialType
.
System_Void
&&
...
...
@@ -208,7 +207,7 @@ internal void ComputeReturnType()
diagnostics
.
Add
(
ErrorCode
.
ERR_BadAsyncReturn
,
this
.
Locations
[
0
]);
}
Debug
.
Assert
(
r
efKind
==
RefKind
.
None
Debug
.
Assert
(
_lazyR
efKind
==
RefKind
.
None
||
returnType
.
SpecialType
!=
SpecialType
.
System_Void
||
returnTypeSyntax
.
HasErrors
);
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
浏览文件 @
9a600379
...
...
@@ -107,7 +107,7 @@ internal sealed class SourceMemberMethodSymbol : SourceMethodSymbol
bool
hasBlockBody
=
syntax
.
Body
!=
null
;
_isExpressionBodied
=
!
hasBlockBody
&&
syntax
.
ExpressionBody
!=
null
;
syntax
.
ReturnType
.
SkipRef
(
out
_refKind
);
_refKind
=
syntax
.
ReturnType
.
GetRefKind
(
);
if
(
hasBlockBody
||
_isExpressionBodied
)
{
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
浏览文件 @
9a600379
...
...
@@ -66,7 +66,7 @@ internal sealed class SourcePropertySymbol : PropertySymbol, IAttributeTargetSym
_location
=
location
;
_containingType
=
containingType
;
_syntaxRef
=
syntax
.
GetReference
();
syntax
.
Type
.
SkipRef
(
out
_refKind
);
_refKind
=
syntax
.
Type
.
GetRefKind
(
);
SyntaxTokenList
modifiers
=
syntax
.
Modifiers
;
bodyBinder
=
bodyBinder
.
WithUnsafeRegionIfNecessary
(
modifiers
);
...
...
src/Compilers/CSharp/Portable/Syntax/SyntaxNodeExtensions.cs
浏览文件 @
9a600379
...
...
@@ -148,6 +148,12 @@ internal static SyntaxToken ExtractAnonymousTypeMemberName(this ExpressionSyntax
}
}
internal
static
RefKind
GetRefKind
(
this
TypeSyntax
syntax
)
{
syntax
.
SkipRef
(
out
var
refKind
);
return
refKind
;
}
internal
static
TypeSyntax
SkipRef
(
this
TypeSyntax
syntax
,
out
RefKind
refKind
)
{
refKind
=
RefKind
.
None
;
...
...
@@ -158,7 +164,7 @@ internal static TypeSyntax SkipRef(this TypeSyntax syntax, out RefKind refKind)
RefKind
.
RefReadOnly
:
RefKind
.
Ref
;
syntax
=
((
RefTypeSyntax
)
syntax
)
.
Type
;
syntax
=
refType
.
Type
;
}
return
syntax
;
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenInParametersTests.cs
浏览文件 @
9a600379
...
...
@@ -578,6 +578,44 @@ .maxstack 1
}"
);
}
[
Fact
,
WorkItem
(
18357
,
"https://github.com/dotnet/roslyn/issues/18357"
)]
public
void
ReadonlyParamCannotReturnByRefNested
()
{
var
text
=
@"
class Program
{
static ref readonly int M(in int arg1, in (int Alice, int Bob) arg2)
{
ref int M1(in int arg11, in (int Alice, int Bob) arg21)
{
bool b = true;
if (b)
{
return ref arg11;
}
else
{
return ref arg21.Alice;
}
}
return ref M1(arg1, arg2);
}
}
"
;
var
comp
=
CreateCompilationWithMscorlib45
(
text
,
new
[]
{
ValueTupleRef
,
SystemRuntimeFacadeRef
});
comp
.
VerifyDiagnostics
(
// (12,28): error CS8406: Cannot use variable 'in int' as a ref or out value because it is a readonly variable
// return ref arg11;
Diagnostic
(
ErrorCode
.
ERR_RefReadonlyNotField
,
"arg11"
).
WithArguments
(
"variable"
,
"in int"
).
WithLocation
(
12
,
28
),
// (16,28): error CS8407: Members of variable 'in (int Alice, int Bob)' cannot be used as a ref or out value because it is a readonly variable
// return ref arg21.Alice;
Diagnostic
(
ErrorCode
.
ERR_RefReadonlyNotField2
,
"arg21.Alice"
).
WithArguments
(
"variable"
,
"in (int Alice, int Bob)"
).
WithLocation
(
16
,
28
)
);
}
[
Fact
]
public
void
ReadonlyParamOptional
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录