Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
941a08f2
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,发现更多精彩内容 >>
提交
941a08f2
编写于
12月 22, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move diagnostic from parser to later phase.
上级
07dc0b23
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
17 deletion
+36
-17
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
+6
-14
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
...ers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
+2
-0
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
...Sharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
+8
-3
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
...s/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
+9
-0
src/Compilers/CSharp/Portable/Symbols/Symbol.cs
src/Compilers/CSharp/Portable/Symbols/Symbol.cs
+11
-0
未找到文件。
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
浏览文件 @
941a08f2
...
...
@@ -1604,7 +1604,6 @@ private TypeDeclarationSyntax ParseClassOrStructOrInterfaceDeclaration(SyntaxLis
var
typeParameters
=
this
.
ParseTypeParameterList
(
allowVariance
:
classOrStructOrInterface
.
Kind
==
SyntaxKind
.
InterfaceKeyword
);
_termState
=
saveTerm
;
bool
hasTypeParams
=
typeParameters
!=
null
;
var
baseList
=
this
.
ParseBaseList
();
// Parse class body
...
...
@@ -1616,7 +1615,7 @@ private TypeDeclarationSyntax ParseClassOrStructOrInterfaceDeclaration(SyntaxLis
if
(
this
.
CurrentToken
.
ContextualKind
==
SyntaxKind
.
WhereKeyword
)
{
constraints
=
_pool
.
Allocate
<
TypeParameterConstraintClauseSyntax
>();
this
.
ParseTypeParameterConstraintClauses
(
hasTypeParams
,
constraints
);
this
.
ParseTypeParameterConstraintClauses
(
constraints
);
}
var
openBrace
=
this
.
EatToken
(
SyntaxKind
.
OpenBraceToken
);
...
...
@@ -1916,18 +1915,11 @@ private bool IsPossibleTypeParameterConstraintClauseStart()
this
.
PeekToken
(
2
).
Kind
==
SyntaxKind
.
ColonToken
;
}
private
void
ParseTypeParameterConstraintClauses
(
bool
isAllowed
,
SyntaxListBuilder
list
)
private
void
ParseTypeParameterConstraintClauses
(
SyntaxListBuilder
list
)
{
while
(
this
.
CurrentToken
.
ContextualKind
==
SyntaxKind
.
WhereKeyword
)
{
var
constraint
=
this
.
ParseTypeParameterConstraintClause
();
if
(!
isAllowed
)
{
constraint
=
this
.
AddErrorToFirstToken
(
constraint
,
ErrorCode
.
ERR_ConstraintOnlyAllowedOnGenericDecl
);
isAllowed
=
true
;
// silence any further errors
}
list
.
Add
(
constraint
);
list
.
Add
(
this
.
ParseTypeParameterConstraintClause
());
}
}
...
...
@@ -2945,7 +2937,7 @@ private bool IsEndOfNameInExplicitInterface()
if
(
this
.
CurrentToken
.
ContextualKind
==
SyntaxKind
.
WhereKeyword
)
{
constraints
=
_pool
.
Allocate
<
TypeParameterConstraintClauseSyntax
>();
this
.
ParseTypeParameterConstraintClauses
(
typeParameterList
!=
null
,
constraints
);
this
.
ParseTypeParameterConstraintClauses
(
constraints
);
}
else
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
ColonToken
)
{
...
...
@@ -5103,7 +5095,7 @@ private DelegateDeclarationSyntax ParseDelegateDeclaration(SyntaxListBuilder<Att
if
(
this
.
CurrentToken
.
ContextualKind
==
SyntaxKind
.
WhereKeyword
)
{
constraints
=
_pool
.
Allocate
<
TypeParameterConstraintClauseSyntax
>();
this
.
ParseTypeParameterConstraintClauses
(
typeParameters
!=
null
,
constraints
);
this
.
ParseTypeParameterConstraintClauses
(
constraints
);
}
_termState
=
saveTerm
;
...
...
@@ -8885,7 +8877,7 @@ private static bool IsAccessibilityModifier(SyntaxKind kind)
if
(
this
.
CurrentToken
.
ContextualKind
==
SyntaxKind
.
WhereKeyword
)
{
constraints
=
_pool
.
Allocate
<
TypeParameterConstraintClauseSyntax
>();
this
.
ParseTypeParameterConstraintClauses
(
typeParameterListOpt
!=
null
,
constraints
);
this
.
ParseTypeParameterConstraintClauses
(
constraints
);
forceLocalFunc
=
true
;
}
...
...
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
浏览文件 @
941a08f2
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
...
...
@@ -90,6 +91,7 @@ internal ReturnTypeAndDiagnostics(TypeSymbol returnType, ImmutableArray<Diagnost
else
{
_typeParameters
=
ImmutableArray
<
TypeParameterSymbol
>.
Empty
;
ReportErrorIfHasConstraints
(
_syntax
.
ConstraintClauses
,
diagnostics
);
}
if
(
IsExtensionMethod
)
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
浏览文件 @
941a08f2
...
...
@@ -95,9 +95,14 @@ internal sealed class SourceMemberMethodSymbol : SourceMethodSymbol
this
.
MakeFlags
(
methodKind
,
declarationModifiers
,
returnsVoid
,
isExtensionMethod
,
isMetadataVirtualIgnoringModifiers
);
_typeParameters
=
(
syntax
.
Arity
==
0
)
?
ImmutableArray
<
TypeParameterSymbol
>.
Empty
:
MakeTypeParameters
(
syntax
,
diagnostics
);
_typeParameters
=
syntax
.
Arity
==
0
?
ImmutableArray
<
TypeParameterSymbol
>.
Empty
:
MakeTypeParameters
(
syntax
,
diagnostics
);
if
(
syntax
.
Arity
==
0
)
{
ReportErrorIfHasConstraints
(
syntax
.
ConstraintClauses
,
diagnostics
);
}
bool
hasBlockBody
=
syntax
.
Body
!=
null
;
_isExpressionBodied
=
!
hasBlockBody
&&
syntax
.
ExpressionBody
!=
null
;
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
浏览文件 @
941a08f2
...
...
@@ -118,6 +118,15 @@ private ImmutableArray<TypeParameterSymbol> MakeTypeParameters(DiagnosticBag dia
{
if
(
declaration
.
Arity
==
0
)
{
if
(
declaration
.
Kind
!=
DeclarationKind
.
Enum
)
{
foreach
(
var
syntaxRef
in
this
.
SyntaxReferences
)
{
var
constraintClauses
=
GetConstraintClauses
((
CSharpSyntaxNode
)
syntaxRef
.
GetSyntax
());
ReportErrorIfHasConstraints
(
constraintClauses
,
diagnostics
);
}
}
return
ImmutableArray
<
TypeParameterSymbol
>.
Empty
;
}
...
...
src/Compilers/CSharp/Portable/Symbols/Symbol.cs
浏览文件 @
941a08f2
...
...
@@ -1089,6 +1089,17 @@ public ImmutableArray<SymbolDisplayPart> ToDisplayParts(SymbolDisplayFormat form
return
SymbolDisplay
.
ToMinimalDisplayParts
(
this
,
semanticModel
,
position
,
format
);
}
protected
static
void
ReportErrorIfHasConstraints
(
SyntaxList
<
TypeParameterConstraintClauseSyntax
>
constraintClauses
,
DiagnosticBag
diagnostics
)
{
if
(
constraintClauses
.
Count
>
0
)
{
diagnostics
.
Add
(
ErrorCode
.
ERR_ConstraintOnlyAllowedOnGenericDecl
,
constraintClauses
[
0
].
WhereKeyword
.
GetLocation
());
}
}
#
region
ISymbol
Members
SymbolKind
ISymbol
.
Kind
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录