Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1993d900
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,发现更多精彩内容 >>
提交
1993d900
编写于
8月 24, 2017
作者:
V
vsadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge from master
上级
e763d1dc
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
37 addition
and
19 deletion
+37
-19
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
...arp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
+37
-19
未找到文件。
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
浏览文件 @
1993d900
...
...
@@ -5,6 +5,7 @@
using
System.Globalization
;
using
System.Linq
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.CSharp.Emit
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.PooledObjects
;
...
...
@@ -108,7 +109,7 @@ internal sealed class SourceOrdinaryMethodSymbol : SourceMemberMethodSymbol
bool
hasBlockBody
=
syntax
.
Body
!=
null
;
_isExpressionBodied
=
!
hasBlockBody
&&
syntax
.
ExpressionBody
!=
null
;
syntax
.
ReturnType
.
SkipRef
(
out
_refKind
);
_refKind
=
syntax
.
ReturnType
.
GetRefKind
(
);
if
(
hasBlockBody
||
_isExpressionBodied
)
{
...
...
@@ -152,6 +153,8 @@ public override bool ReturnsVoid
private
void
MethodChecks
(
MethodDeclarationSyntax
syntax
,
Binder
withTypeParamsBinder
,
DiagnosticBag
diagnostics
)
{
Debug
.
Assert
(
this
.
MethodKind
!=
MethodKind
.
UserDefinedOperator
,
"SourceUserDefinedOperatorSymbolBase overrides this"
);
SyntaxToken
arglistToken
;
// Constraint checking for parameter and return types must be delayed until
...
...
@@ -165,6 +168,7 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
signatureBinder
,
this
,
syntax
.
ParameterList
,
out
arglistToken
,
allowRefOrOut
:
true
,
allowThis
:
true
,
addRefReadOnlyModifier
:
IsVirtual
||
IsAbstract
,
diagnostics
:
diagnostics
);
_lazyIsVararg
=
(
arglistToken
.
Kind
()
==
SyntaxKind
.
ArgListKeyword
);
...
...
@@ -172,7 +176,8 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
var
returnTypeSyntax
=
syntax
.
ReturnType
.
SkipRef
(
out
refKind
);
_lazyReturnType
=
signatureBinder
.
BindType
(
returnTypeSyntax
,
diagnostics
);
if
(
_lazyReturnType
.
IsRestrictedType
())
// span-like types are returnable in general
if
(
_lazyReturnType
.
IsRestrictedType
(
ignoreSpanLikeTypes
:
true
))
{
if
(
_lazyReturnType
.
SpecialType
==
SpecialType
.
System_TypedReference
&&
(
this
.
ContainingType
.
SpecialType
==
SpecialType
.
System_TypedReference
||
this
.
ContainingType
.
SpecialType
==
SpecialType
.
System_ArgIterator
))
...
...
@@ -208,6 +213,7 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
if
(
IsExtensionMethod
)
{
var
parameter0Type
=
this
.
Parameters
[
0
].
Type
;
var
parameter0RefKind
=
this
.
Parameters
[
0
].
RefKind
;
if
(!
parameter0Type
.
IsValidExtensionParameterType
())
{
// Duplicate Dev10 behavior by selecting the parameter type.
...
...
@@ -216,6 +222,14 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
var
loc
=
parameterSyntax
.
Type
.
Location
;
diagnostics
.
Add
(
ErrorCode
.
ERR_BadTypeforThis
,
loc
,
parameter0Type
);
}
else
if
(
parameter0RefKind
==
RefKind
.
Ref
&&
!
parameter0Type
.
IsValueType
)
{
diagnostics
.
Add
(
ErrorCode
.
ERR_RefExtensionMustBeValueTypeOrConstrainedToOne
,
location
,
Name
);
}
else
if
(
parameter0RefKind
==
RefKind
.
RefReadOnly
&&
parameter0Type
.
TypeKind
!=
TypeKind
.
Struct
)
{
diagnostics
.
Add
(
ErrorCode
.
ERR_RefReadOnlyExtensionMustBeValueType
,
location
,
Name
);
}
else
if
((
object
)
ContainingType
.
ContainingType
!=
null
)
{
diagnostics
.
Add
(
ErrorCode
.
ERR_ExtensionMethodsDecl
,
location
,
ContainingType
.
Name
);
...
...
@@ -249,18 +263,7 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
}
}
if
(
this
.
MethodKind
==
MethodKind
.
UserDefinedOperator
)
{
foreach
(
var
p
in
this
.
Parameters
)
{
if
(
p
.
RefKind
!=
RefKind
.
None
)
{
diagnostics
.
Add
(
ErrorCode
.
ERR_IllegalRefParam
,
location
);
break
;
}
}
}
else
if
(
IsPartial
)
if
(
IsPartial
)
{
// check that there are no out parameters in a partial
foreach
(
var
p
in
this
.
Parameters
)
...
...
@@ -333,6 +336,14 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
out
_lazyParameters
,
alsoCopyParamsModifier
:
true
);
}
}
else
if
(
_refKind
==
RefKind
.
RefReadOnly
)
{
var
modifierType
=
withTypeParamsBinder
.
GetWellKnownType
(
WellKnownType
.
System_Runtime_InteropServices_InAttribute
,
diagnostics
,
syntax
.
ReturnType
);
_lazyCustomModifiers
=
CustomModifiersTuple
.
Create
(
typeCustomModifiers
:
ImmutableArray
<
CustomModifier
>.
Empty
,
refCustomModifiers
:
ImmutableArray
.
Create
(
CSharpCustomModifier
.
CreateRequired
(
modifierType
)));
}
}
else
if
((
object
)
_explicitInterfaceType
!=
null
)
{
...
...
@@ -959,9 +970,9 @@ private void CheckModifiers(Location location, DiagnosticBag diagnostics)
}
}
internal
override
void
AddSynthesizedAttributes
(
ModuleCompilationState
compilationState
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
internal
override
void
AddSynthesizedAttributes
(
PEModuleBuilder
moduleBuilder
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
{
base
.
AddSynthesizedAttributes
(
compilationState
,
ref
attributes
);
base
.
AddSynthesizedAttributes
(
moduleBuilder
,
ref
attributes
);
if
(
this
.
IsExtensionMethod
)
{
...
...
@@ -1010,6 +1021,13 @@ internal override void AfterAddingTypeMembersChecks(ConversionsBase conversions,
{
PartialMethodChecks
(
this
,
implementingPart
,
diagnostics
);
}
if
(
_refKind
==
RefKind
.
RefReadOnly
)
{
this
.
DeclaringCompilation
.
EnsureIsReadOnlyAttributeExists
(
diagnostics
,
GetSyntax
().
ReturnType
.
Location
,
modifyCompilationForRefReadOnly
:
true
);
}
ParameterHelpers
.
EnsureIsReadOnlyAttributeExists
(
Parameters
,
diagnostics
,
modifyCompilationForRefReadOnly
:
true
);
}
/// <summary>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录