Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
2b80c8cb
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,发现更多精彩内容 >>
未验证
提交
2b80c8cb
编写于
1月 13, 2020
作者:
F
Fredric Silberberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Annotate more of the binder
上级
ad8ec29f
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
172 addition
and
156 deletion
+172
-156
src/Compilers/CSharp/Portable/Binder/Binder.cs
src/Compilers/CSharp/Portable/Binder/Binder.cs
+3
-3
src/Compilers/CSharp/Portable/Binder/Binder_AnonymousTypes.cs
...Compilers/CSharp/Portable/Binder/Binder_AnonymousTypes.cs
+13
-10
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
+52
-45
src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
+28
-23
src/Compilers/CSharp/Portable/Binder/Binder_Constraints.cs
src/Compilers/CSharp/Portable/Binder/Binder_Constraints.cs
+16
-15
src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
+46
-46
src/Compilers/CSharp/Portable/Binder/BuckStopsHereBinder.cs
src/Compilers/CSharp/Portable/Binder/BuckStopsHereBinder.cs
+1
-1
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
...ompilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+4
-4
src/Compilers/CSharp/Portable/Symbols/SymbolExtensions.cs
src/Compilers/CSharp/Portable/Symbols/SymbolExtensions.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
...mpilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
+6
-6
src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
...Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
+2
-2
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder.cs
浏览文件 @
2b80c8cb
...
@@ -674,7 +674,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
...
@@ -674,7 +674,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
internal
static
bool
IsSymbolAccessibleConditional
(
internal
static
bool
IsSymbolAccessibleConditional
(
Symbol
symbol
,
Symbol
symbol
,
AssemblySymbol
within
,
AssemblySymbol
within
,
ref
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
)
ref
HashSet
<
DiagnosticInfo
>
?
useSiteDiagnostics
)
{
{
return
AccessCheck
.
IsSymbolAccessible
(
symbol
,
within
,
ref
useSiteDiagnostics
);
return
AccessCheck
.
IsSymbolAccessible
(
symbol
,
within
,
ref
useSiteDiagnostics
);
}
}
...
@@ -682,7 +682,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
...
@@ -682,7 +682,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
internal
bool
IsSymbolAccessibleConditional
(
internal
bool
IsSymbolAccessibleConditional
(
Symbol
symbol
,
Symbol
symbol
,
NamedTypeSymbol
within
,
NamedTypeSymbol
within
,
ref
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
,
ref
HashSet
<
DiagnosticInfo
>
?
useSiteDiagnostics
,
TypeSymbol
?
throughTypeOpt
=
null
)
TypeSymbol
?
throughTypeOpt
=
null
)
{
{
return
this
.
Flags
.
Includes
(
BinderFlags
.
IgnoreAccessibility
)
||
AccessCheck
.
IsSymbolAccessible
(
symbol
,
within
,
ref
useSiteDiagnostics
,
throughTypeOpt
);
return
this
.
Flags
.
Includes
(
BinderFlags
.
IgnoreAccessibility
)
||
AccessCheck
.
IsSymbolAccessible
(
symbol
,
within
,
ref
useSiteDiagnostics
,
throughTypeOpt
);
...
@@ -693,7 +693,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
...
@@ -693,7 +693,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
NamedTypeSymbol
within
,
NamedTypeSymbol
within
,
TypeSymbol
throughTypeOpt
,
TypeSymbol
throughTypeOpt
,
out
bool
failedThroughTypeCheck
,
out
bool
failedThroughTypeCheck
,
ref
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
,
ref
HashSet
<
DiagnosticInfo
>
?
useSiteDiagnostics
,
ConsList
<
TypeSymbol
>?
basesBeingResolved
=
null
)
ConsList
<
TypeSymbol
>?
basesBeingResolved
=
null
)
{
{
if
(
this
.
Flags
.
Includes
(
BinderFlags
.
IgnoreAccessibility
))
if
(
this
.
Flags
.
Includes
(
BinderFlags
.
IgnoreAccessibility
))
...
...
src/Compilers/CSharp/Portable/Binder/Binder_AnonymousTypes.cs
浏览文件 @
2b80c8cb
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Diagnostics
;
...
@@ -8,6 +9,7 @@
...
@@ -8,6 +9,7 @@
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CSharp
namespace
Microsoft.CodeAnalysis.CSharp
{
{
...
@@ -40,7 +42,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
...
@@ -40,7 +42,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
for
(
int
i
=
0
;
i
<
fieldCount
;
i
++)
for
(
int
i
=
0
;
i
<
fieldCount
;
i
++)
{
{
AnonymousObjectMemberDeclaratorSyntax
fieldInitializer
=
initializers
[
i
];
AnonymousObjectMemberDeclaratorSyntax
fieldInitializer
=
initializers
[
i
];
NameEqualsSyntax
nameEquals
=
fieldInitializer
.
NameEquals
;
NameEqualsSyntax
?
nameEquals
=
fieldInitializer
.
NameEquals
;
ExpressionSyntax
expression
=
fieldInitializer
.
Expression
;
ExpressionSyntax
expression
=
fieldInitializer
.
Expression
;
SyntaxToken
nameToken
=
default
(
SyntaxToken
);
SyntaxToken
nameToken
=
default
(
SyntaxToken
);
...
@@ -63,11 +65,11 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
...
@@ -63,11 +65,11 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
boundExpressions
[
i
]
=
BindRValueWithoutTargetType
(
expression
,
diagnostics
);
boundExpressions
[
i
]
=
BindRValueWithoutTargetType
(
expression
,
diagnostics
);
// check the name to be unique
// check the name to be unique
string
fieldName
=
null
;
string
?
fieldName
=
null
;
if
(
nameToken
.
Kind
()
==
SyntaxKind
.
IdentifierToken
)
if
(
nameToken
.
Kind
()
==
SyntaxKind
.
IdentifierToken
)
{
{
fieldName
=
nameToken
.
ValueText
;
fieldName
=
nameToken
.
ValueText
;
if
(!
uniqueFieldNames
.
Add
(
fieldName
))
if
(!
uniqueFieldNames
.
Add
(
fieldName
!
))
{
{
// name duplication
// name duplication
Error
(
diagnostics
,
ErrorCode
.
ERR_AnonymousTypeDuplicatePropertyName
,
fieldInitializer
);
Error
(
diagnostics
,
ErrorCode
.
ERR_AnonymousTypeDuplicatePropertyName
,
fieldInitializer
);
...
@@ -85,7 +87,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
...
@@ -85,7 +87,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
TypeSymbol
fieldType
=
GetAnonymousTypeFieldType
(
boundExpressions
[
i
],
fieldInitializer
,
diagnostics
,
ref
hasError
);
TypeSymbol
fieldType
=
GetAnonymousTypeFieldType
(
boundExpressions
[
i
],
fieldInitializer
,
diagnostics
,
ref
hasError
);
// build anonymous type field descriptor
// build anonymous type field descriptor
fieldSyntaxNodes
[
i
]
=
(
nameToken
.
Kind
()
==
SyntaxKind
.
IdentifierToken
)
?
(
CSharpSyntaxNode
)
nameToken
.
Parent
:
fieldInitializer
;
fieldSyntaxNodes
[
i
]
=
(
nameToken
.
Kind
()
==
SyntaxKind
.
IdentifierToken
)
?
(
CSharpSyntaxNode
)
nameToken
.
Parent
!
:
fieldInitializer
;
fields
[
i
]
=
new
AnonymousTypeField
(
fields
[
i
]
=
new
AnonymousTypeField
(
fieldName
==
null
?
"$"
+
i
.
ToString
()
:
fieldName
,
fieldName
==
null
?
"$"
+
i
.
ToString
()
:
fieldName
,
fieldSyntaxNodes
[
i
].
Location
,
fieldSyntaxNodes
[
i
].
Location
,
...
@@ -107,7 +109,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
...
@@ -107,7 +109,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
ArrayBuilder
<
BoundAnonymousPropertyDeclaration
>.
GetInstance
();
ArrayBuilder
<
BoundAnonymousPropertyDeclaration
>.
GetInstance
();
for
(
int
i
=
0
;
i
<
fieldCount
;
i
++)
for
(
int
i
=
0
;
i
<
fieldCount
;
i
++)
{
{
NameEqualsSyntax
explicitName
=
initializers
[
i
].
NameEquals
;
NameEqualsSyntax
?
explicitName
=
initializers
[
i
].
NameEquals
;
if
(
explicitName
!=
null
)
if
(
explicitName
!=
null
)
{
{
AnonymousTypeField
field
=
fields
[
i
];
AnonymousTypeField
field
=
fields
[
i
];
...
@@ -178,7 +180,7 @@ private static bool IsAnonymousTypeMemberExpression(ExpressionSyntax expr)
...
@@ -178,7 +180,7 @@ private static bool IsAnonymousTypeMemberExpression(ExpressionSyntax expr)
private
bool
IsAnonymousTypesAllowed
()
private
bool
IsAnonymousTypesAllowed
()
{
{
var
member
=
this
.
ContainingMemberOrLambda
;
var
member
=
this
.
ContainingMemberOrLambda
;
if
(
(
object
)
member
==
null
)
if
(
member
is
null
)
{
{
return
false
;
return
false
;
}
}
...
@@ -205,13 +207,14 @@ private bool IsAnonymousTypesAllowed()
...
@@ -205,13 +207,14 @@ private bool IsAnonymousTypesAllowed()
/// </summary>
/// </summary>
private
TypeSymbol
GetAnonymousTypeFieldType
(
BoundExpression
expression
,
CSharpSyntaxNode
errorSyntax
,
DiagnosticBag
diagnostics
,
ref
bool
hasError
)
private
TypeSymbol
GetAnonymousTypeFieldType
(
BoundExpression
expression
,
CSharpSyntaxNode
errorSyntax
,
DiagnosticBag
diagnostics
,
ref
bool
hasError
)
{
{
object
errorArg
=
null
;
object
?
errorArg
=
null
;
TypeSymbol
expressionType
=
expression
.
Type
;
TypeSymbol
?
expressionType
=
expression
.
Type
;
if
(!
expression
.
HasAnyErrors
)
if
(!
expression
.
HasAnyErrors
)
{
{
if
(
expression
.
HasExpressionType
())
if
(
expression
.
HasExpressionType
())
{
{
RoslynDebug
.
Assert
(
expressionType
is
object
);
if
(
expressionType
.
IsVoidType
())
if
(
expressionType
.
IsVoidType
())
{
{
errorArg
=
expressionType
;
errorArg
=
expressionType
;
...
@@ -233,7 +236,7 @@ private TypeSymbol GetAnonymousTypeFieldType(BoundExpression expression, CSharpS
...
@@ -233,7 +236,7 @@ private TypeSymbol GetAnonymousTypeFieldType(BoundExpression expression, CSharpS
}
}
}
}
if
(
(
object
)
expressionType
==
null
)
if
(
expressionType
is
null
)
{
{
expressionType
=
CreateErrorType
(
"error"
);
expressionType
=
CreateErrorType
(
"error"
);
}
}
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
浏览文件 @
2b80c8cb
此差异已折叠。
点击以展开。
src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
浏览文件 @
2b80c8cb
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.Diagnostics.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CSharp
namespace
Microsoft.CodeAnalysis.CSharp
{
{
...
@@ -45,15 +48,15 @@ internal void ReportBadAwaitDiagnostics(SyntaxNode node, Location location, Diag
...
@@ -45,15 +48,15 @@ internal void ReportBadAwaitDiagnostics(SyntaxNode node, Location location, Diag
hasErrors
|=
ReportBadAwaitContext
(
node
,
location
,
diagnostics
);
hasErrors
|=
ReportBadAwaitContext
(
node
,
location
,
diagnostics
);
}
}
internal
BoundAwaitableInfo
BindAwaitInfo
(
BoundAwaitableValuePlaceholder
placeholder
,
SyntaxNode
node
,
DiagnosticBag
diagnostics
,
ref
bool
hasErrors
,
BoundExpression
expressionOpt
=
null
)
internal
BoundAwaitableInfo
BindAwaitInfo
(
BoundAwaitableValuePlaceholder
placeholder
,
SyntaxNode
node
,
DiagnosticBag
diagnostics
,
ref
bool
hasErrors
,
BoundExpression
?
expressionOpt
=
null
)
{
{
bool
hasGetAwaitableErrors
=
!
GetAwaitableExpressionInfo
(
bool
hasGetAwaitableErrors
=
!
GetAwaitableExpressionInfo
(
expressionOpt
??
placeholder
,
expressionOpt
??
placeholder
,
placeholder
,
placeholder
,
out
bool
isDynamic
,
out
bool
isDynamic
,
out
BoundExpression
getAwaiter
,
out
BoundExpression
?
getAwaiter
,
out
PropertySymbol
isCompleted
,
out
PropertySymbol
?
isCompleted
,
out
MethodSymbol
getResult
,
out
MethodSymbol
?
getResult
,
getAwaiterGetResultCall
:
out
_
,
getAwaiterGetResultCall
:
out
_
,
node
,
node
,
diagnostics
);
diagnostics
);
...
@@ -78,7 +81,7 @@ private bool CouldBeAwaited(BoundExpression expression)
...
@@ -78,7 +81,7 @@ private bool CouldBeAwaited(BoundExpression expression)
}
}
var
type
=
expression
.
Type
;
var
type
=
expression
.
Type
;
if
((
(
object
)
type
==
null
)
||
if
((
type
is
null
)
||
type
.
IsDynamic
()
||
type
.
IsDynamic
()
||
(
type
.
IsVoidType
()))
(
type
.
IsVoidType
()))
{
{
...
@@ -101,7 +104,7 @@ private bool CouldBeAwaited(BoundExpression expression)
...
@@ -101,7 +104,7 @@ private bool CouldBeAwaited(BoundExpression expression)
// Finally, if we're in an async method, and the expression could be awaited, report that it is instead discarded.
// Finally, if we're in an async method, and the expression could be awaited, report that it is instead discarded.
var
containingMethod
=
this
.
ContainingMemberOrLambda
as
MethodSymbol
;
var
containingMethod
=
this
.
ContainingMemberOrLambda
as
MethodSymbol
;
if
(
(
object
)
containingMethod
==
null
||
!
containingMethod
.
IsAsync
)
if
(
containingMethod
is
null
||
!
containingMethod
.
IsAsync
)
{
{
return
false
;
return
false
;
}
}
...
@@ -136,9 +139,9 @@ private bool ContextForbidsAwait
...
@@ -136,9 +139,9 @@ private bool ContextForbidsAwait
/// <returns>True if the expression contains errors.</returns>
/// <returns>True if the expression contains errors.</returns>
private
bool
ReportBadAwaitWithoutAsync
(
Location
location
,
DiagnosticBag
diagnostics
)
private
bool
ReportBadAwaitWithoutAsync
(
Location
location
,
DiagnosticBag
diagnostics
)
{
{
DiagnosticInfo
info
=
null
;
DiagnosticInfo
?
info
=
null
;
var
containingMemberOrLambda
=
this
.
ContainingMemberOrLambda
;
var
containingMemberOrLambda
=
this
.
ContainingMemberOrLambda
;
if
(
(
object
)
containingMemberOrLambda
!=
null
)
if
(
containingMemberOrLambda
is
object
)
{
{
switch
(
containingMemberOrLambda
.
Kind
)
switch
(
containingMemberOrLambda
.
Kind
)
{
{
...
@@ -230,7 +233,7 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
...
@@ -230,7 +233,7 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
/// <returns>True if the expression is awaitable; false otherwise.</returns>
/// <returns>True if the expression is awaitable; false otherwise.</returns>
internal
bool
GetAwaitableExpressionInfo
(
internal
bool
GetAwaitableExpressionInfo
(
BoundExpression
expression
,
BoundExpression
expression
,
out
BoundExpression
getAwaiterGetResultCall
,
[
NotNullWhen
(
true
)]
out
BoundExpression
?
getAwaiterGetResultCall
,
SyntaxNode
node
,
SyntaxNode
node
,
DiagnosticBag
diagnostics
)
DiagnosticBag
diagnostics
)
{
{
...
@@ -241,10 +244,10 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
...
@@ -241,10 +244,10 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
BoundExpression
expression
,
BoundExpression
expression
,
BoundExpression
getAwaiterArgument
,
BoundExpression
getAwaiterArgument
,
out
bool
isDynamic
,
out
bool
isDynamic
,
out
BoundExpression
getAwaiter
,
out
BoundExpression
?
getAwaiter
,
out
PropertySymbol
isCompleted
,
out
PropertySymbol
?
isCompleted
,
out
MethodSymbol
getResult
,
out
MethodSymbol
?
getResult
,
out
BoundExpression
getAwaiterGetResultCall
,
out
BoundExpression
?
getAwaiterGetResultCall
,
SyntaxNode
node
,
SyntaxNode
node
,
DiagnosticBag
diagnostics
)
DiagnosticBag
diagnostics
)
{
{
...
@@ -272,10 +275,10 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
...
@@ -272,10 +275,10 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
return
false
;
return
false
;
}
}
TypeSymbol
awaiterType
=
getAwaiter
.
Type
;
TypeSymbol
awaiterType
=
getAwaiter
.
Type
!
;
return
GetIsCompletedProperty
(
awaiterType
,
node
,
expression
.
Type
,
diagnostics
,
out
isCompleted
)
return
GetIsCompletedProperty
(
awaiterType
,
node
,
expression
.
Type
!
,
diagnostics
,
out
isCompleted
)
&&
AwaiterImplementsINotifyCompletion
(
awaiterType
,
node
,
diagnostics
)
&&
AwaiterImplementsINotifyCompletion
(
awaiterType
,
node
,
diagnostics
)
&&
GetGetResultMethod
(
getAwaiter
,
node
,
expression
.
Type
,
diagnostics
,
out
getResult
,
out
getAwaiterGetResultCall
);
&&
GetGetResultMethod
(
getAwaiter
,
node
,
expression
.
Type
!
,
diagnostics
,
out
getResult
,
out
getAwaiterGetResultCall
);
}
}
/// <summary>
/// <summary>
...
@@ -289,7 +292,7 @@ private static bool ValidateAwaitedExpression(BoundExpression expression, Syntax
...
@@ -289,7 +292,7 @@ private static bool ValidateAwaitedExpression(BoundExpression expression, Syntax
return
false
;
return
false
;
}
}
if
(
(
object
)
expression
.
Type
==
null
)
if
(
expression
.
Type
is
null
)
{
{
Error
(
diagnostics
,
ErrorCode
.
ERR_BadAwaitArgIntrinsic
,
node
,
expression
.
Display
);
Error
(
diagnostics
,
ErrorCode
.
ERR_BadAwaitArgIntrinsic
,
node
,
expression
.
Display
);
return
false
;
return
false
;
...
@@ -309,8 +312,9 @@ private static bool ValidateAwaitedExpression(BoundExpression expression, Syntax
...
@@ -309,8 +312,9 @@ private static bool ValidateAwaitedExpression(BoundExpression expression, Syntax
/// NOTE: this is an error in the spec. An extension method of the form
/// NOTE: this is an error in the spec. An extension method of the form
/// Awaiter<T> GetAwaiter<T>(this Task<T>) may be used.
/// Awaiter<T> GetAwaiter<T>(this Task<T>) may be used.
/// </remarks>
/// </remarks>
private
bool
GetGetAwaiterMethod
(
BoundExpression
expression
,
SyntaxNode
node
,
DiagnosticBag
diagnostics
,
out
BoundExpression
getAwaiterCall
)
private
bool
GetGetAwaiterMethod
(
BoundExpression
expression
,
SyntaxNode
node
,
DiagnosticBag
diagnostics
,
[
NotNullWhen
(
true
)]
out
BoundExpression
?
getAwaiterCall
)
{
{
RoslynDebug
.
Assert
(
expression
.
Type
is
object
);
if
(
expression
.
Type
.
IsVoidType
())
if
(
expression
.
Type
.
IsVoidType
())
{
{
Error
(
diagnostics
,
ErrorCode
.
ERR_BadAwaitArgVoidCall
,
node
);
Error
(
diagnostics
,
ErrorCode
.
ERR_BadAwaitArgVoidCall
,
node
);
...
@@ -352,7 +356,7 @@ private bool GetGetAwaiterMethod(BoundExpression expression, SyntaxNode node, Di
...
@@ -352,7 +356,7 @@ private bool GetGetAwaiterMethod(BoundExpression expression, SyntaxNode node, Di
/// Spec 7.7.7.1:
/// Spec 7.7.7.1:
/// An Awaiter A has an accessible, readable instance property IsCompleted of type bool.
/// An Awaiter A has an accessible, readable instance property IsCompleted of type bool.
/// </remarks>
/// </remarks>
private
bool
GetIsCompletedProperty
(
TypeSymbol
awaiterType
,
SyntaxNode
node
,
TypeSymbol
awaitedExpressionType
,
DiagnosticBag
diagnostics
,
out
PropertySymbol
isCompletedProperty
)
private
bool
GetIsCompletedProperty
(
TypeSymbol
awaiterType
,
SyntaxNode
node
,
TypeSymbol
awaitedExpressionType
,
DiagnosticBag
diagnostics
,
[
NotNullWhen
(
true
)]
out
PropertySymbol
?
isCompletedProperty
)
{
{
var
receiver
=
new
BoundLiteral
(
node
,
ConstantValue
.
Null
,
awaiterType
);
var
receiver
=
new
BoundLiteral
(
node
,
ConstantValue
.
Null
,
awaiterType
);
var
name
=
WellKnownMemberNames
.
IsCompleted
;
var
name
=
WellKnownMemberNames
.
IsCompleted
;
...
@@ -398,7 +402,7 @@ private bool GetIsCompletedProperty(TypeSymbol awaiterType, SyntaxNode node, Typ
...
@@ -398,7 +402,7 @@ private bool GetIsCompletedProperty(TypeSymbol awaiterType, SyntaxNode node, Typ
private
bool
AwaiterImplementsINotifyCompletion
(
TypeSymbol
awaiterType
,
SyntaxNode
node
,
DiagnosticBag
diagnostics
)
private
bool
AwaiterImplementsINotifyCompletion
(
TypeSymbol
awaiterType
,
SyntaxNode
node
,
DiagnosticBag
diagnostics
)
{
{
var
INotifyCompletion
=
GetWellKnownType
(
WellKnownType
.
System_Runtime_CompilerServices_INotifyCompletion
,
diagnostics
,
node
);
var
INotifyCompletion
=
GetWellKnownType
(
WellKnownType
.
System_Runtime_CompilerServices_INotifyCompletion
,
diagnostics
,
node
);
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
=
null
;
HashSet
<
DiagnosticInfo
>
?
useSiteDiagnostics
=
null
;
var
conversion
=
this
.
Conversions
.
ClassifyImplicitConversionFromType
(
awaiterType
,
INotifyCompletion
,
ref
useSiteDiagnostics
);
var
conversion
=
this
.
Conversions
.
ClassifyImplicitConversionFromType
(
awaiterType
,
INotifyCompletion
,
ref
useSiteDiagnostics
);
if
(!
conversion
.
IsImplicit
)
if
(!
conversion
.
IsImplicit
)
...
@@ -419,7 +423,7 @@ private bool AwaiterImplementsINotifyCompletion(TypeSymbol awaiterType, SyntaxNo
...
@@ -419,7 +423,7 @@ private bool AwaiterImplementsINotifyCompletion(TypeSymbol awaiterType, SyntaxNo
/// Spec 7.7.7.1:
/// Spec 7.7.7.1:
/// An Awaiter A has an accessible instance method GetResult with no parameters and no type parameters.
/// An Awaiter A has an accessible instance method GetResult with no parameters and no type parameters.
/// </remarks>
/// </remarks>
private
bool
GetGetResultMethod
(
BoundExpression
awaiterExpression
,
SyntaxNode
node
,
TypeSymbol
awaitedExpressionType
,
DiagnosticBag
diagnostics
,
out
MethodSymbol
getResultMethod
,
out
BoundExpression
getAwaiterGetResultCall
)
private
bool
GetGetResultMethod
(
BoundExpression
awaiterExpression
,
SyntaxNode
node
,
TypeSymbol
awaitedExpressionType
,
DiagnosticBag
diagnostics
,
out
MethodSymbol
?
getResultMethod
,
[
NotNullWhen
(
true
)]
out
BoundExpression
?
getAwaiterGetResultCall
)
{
{
var
awaiterType
=
awaiterExpression
.
Type
;
var
awaiterType
=
awaiterExpression
.
Type
;
getAwaiterGetResultCall
=
MakeInvocationExpression
(
node
,
awaiterExpression
,
WellKnownMemberNames
.
GetResult
,
ImmutableArray
<
BoundExpression
>.
Empty
,
diagnostics
);
getAwaiterGetResultCall
=
MakeInvocationExpression
(
node
,
awaiterExpression
,
WellKnownMemberNames
.
GetResult
,
ImmutableArray
<
BoundExpression
>.
Empty
,
diagnostics
);
...
@@ -430,6 +434,7 @@ private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode no
...
@@ -430,6 +434,7 @@ private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode no
return
false
;
return
false
;
}
}
RoslynDebug
.
Assert
(
awaiterType
is
object
);
if
(
getAwaiterGetResultCall
.
Kind
!=
BoundKind
.
Call
)
if
(
getAwaiterGetResultCall
.
Kind
!=
BoundKind
.
Call
)
{
{
Error
(
diagnostics
,
ErrorCode
.
ERR_NoSuchMember
,
node
,
awaiterType
,
WellKnownMemberNames
.
GetResult
);
Error
(
diagnostics
,
ErrorCode
.
ERR_NoSuchMember
,
node
,
awaiterType
,
WellKnownMemberNames
.
GetResult
);
...
@@ -461,7 +466,7 @@ private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode no
...
@@ -461,7 +466,7 @@ private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode no
private
static
bool
HasOptionalOrVariableParameters
(
MethodSymbol
method
)
private
static
bool
HasOptionalOrVariableParameters
(
MethodSymbol
method
)
{
{
Debug
.
Assert
(
method
!=
null
);
Roslyn
Debug
.
Assert
(
method
!=
null
);
if
(
method
.
ParameterCount
!=
0
)
if
(
method
.
ParameterCount
!=
0
)
{
{
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Constraints.cs
浏览文件 @
2b80c8cb
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
...
@@ -30,7 +31,7 @@ internal partial class Binder
...
@@ -30,7 +31,7 @@ internal partial class Binder
bool
isForOverride
=
false
)
bool
isForOverride
=
false
)
{
{
Debug
.
Assert
(
this
.
Flags
.
Includes
(
BinderFlags
.
GenericConstraintsClause
));
Debug
.
Assert
(
this
.
Flags
.
Includes
(
BinderFlags
.
GenericConstraintsClause
));
Debug
.
Assert
((
object
)
containingSymbol
!=
null
);
Roslyn
Debug
.
Assert
((
object
)
containingSymbol
!=
null
);
Debug
.
Assert
((
containingSymbol
.
Kind
==
SymbolKind
.
NamedType
)
||
(
containingSymbol
.
Kind
==
SymbolKind
.
Method
));
Debug
.
Assert
((
containingSymbol
.
Kind
==
SymbolKind
.
NamedType
)
||
(
containingSymbol
.
Kind
==
SymbolKind
.
Method
));
Debug
.
Assert
(
typeParameters
.
Length
>
0
);
Debug
.
Assert
(
typeParameters
.
Length
>
0
);
Debug
.
Assert
(
clauses
.
Count
>
0
);
Debug
.
Assert
(
clauses
.
Count
>
0
);
...
@@ -51,20 +52,20 @@ internal partial class Binder
...
@@ -51,20 +52,20 @@ internal partial class Binder
}
}
// An array of constraint clauses, one for each type parameter, indexed by ordinal.
// An array of constraint clauses, one for each type parameter, indexed by ordinal.
var
results
=
ArrayBuilder
<
TypeParameterConstraintClause
>.
GetInstance
(
n
,
fillWithValue
:
null
);
var
results
=
ArrayBuilder
<
TypeParameterConstraintClause
?
>.
GetInstance
(
n
,
fillWithValue
:
null
);
var
syntaxNodes
=
ArrayBuilder
<
ArrayBuilder
<
TypeConstraintSyntax
>>.
GetInstance
(
n
,
fillWithValue
:
null
);
var
syntaxNodes
=
ArrayBuilder
<
ArrayBuilder
<
TypeConstraintSyntax
>
?
>.
GetInstance
(
n
,
fillWithValue
:
null
);
// Bind each clause and add to the results.
// Bind each clause and add to the results.
foreach
(
var
clause
in
clauses
)
foreach
(
var
clause
in
clauses
)
{
{
var
name
=
clause
.
Name
.
Identifier
.
ValueText
;
var
name
=
clause
.
Name
.
Identifier
.
ValueText
;
int
ordinal
;
int
ordinal
;
if
(
names
.
TryGetValue
(
name
,
out
ordinal
))
if
(
names
.
TryGetValue
(
name
!
,
out
ordinal
))
{
{
Debug
.
Assert
(
ordinal
>=
0
);
Debug
.
Assert
(
ordinal
>=
0
);
Debug
.
Assert
(
ordinal
<
n
);
Debug
.
Assert
(
ordinal
<
n
);
(
TypeParameterConstraintClause
constraintClause
,
ArrayBuilder
<
TypeConstraintSyntax
>
typeConstraintNodes
)
=
this
.
BindTypeParameterConstraints
(
typeParameterList
.
Parameters
[
ordinal
],
clause
,
isForOverride
,
diagnostics
);
(
TypeParameterConstraintClause
constraintClause
,
ArrayBuilder
<
TypeConstraintSyntax
>
?
typeConstraintNodes
)
=
this
.
BindTypeParameterConstraints
(
typeParameterList
.
Parameters
[
ordinal
],
clause
,
isForOverride
,
diagnostics
);
if
(
results
[
ordinal
]
==
null
)
if
(
results
[
ordinal
]
==
null
)
{
{
results
[
ordinal
]
=
constraintClause
;
results
[
ordinal
]
=
constraintClause
;
...
@@ -100,7 +101,7 @@ internal partial class Binder
...
@@ -100,7 +101,7 @@ internal partial class Binder
TypeParameterConstraintClause
.
AdjustConstraintTypes
(
containingSymbol
,
typeParameters
,
results
,
ref
isValueTypeOverride
);
TypeParameterConstraintClause
.
AdjustConstraintTypes
(
containingSymbol
,
typeParameters
,
results
,
ref
isValueTypeOverride
);
RemoveInvalidConstraints
(
typeParameters
,
results
,
syntaxNodes
,
diagnostics
);
RemoveInvalidConstraints
(
typeParameters
,
results
!
,
syntaxNodes
,
diagnostics
);
foreach
(
var
typeConstraintsSyntaxes
in
syntaxNodes
)
foreach
(
var
typeConstraintsSyntaxes
in
syntaxNodes
)
{
{
...
@@ -109,17 +110,17 @@ internal partial class Binder
...
@@ -109,17 +110,17 @@ internal partial class Binder
syntaxNodes
.
Free
();
syntaxNodes
.
Free
();
return
results
.
ToImmutableAndFree
();
return
results
.
ToImmutableAndFree
()
!
;
}
}
/// <summary>
/// <summary>
/// Bind and return a single type parameter constraint clause along with syntax nodes corresponding to type constraints.
/// Bind and return a single type parameter constraint clause along with syntax nodes corresponding to type constraints.
/// </summary>
/// </summary>
private
(
TypeParameterConstraintClause
,
ArrayBuilder
<
TypeConstraintSyntax
>)
BindTypeParameterConstraints
(
TypeParameterSyntax
typeParameterSyntax
,
TypeParameterConstraintClauseSyntax
constraintClauseSyntax
,
bool
isForOverride
,
DiagnosticBag
diagnostics
)
private
(
TypeParameterConstraintClause
,
ArrayBuilder
<
TypeConstraintSyntax
>
?
)
BindTypeParameterConstraints
(
TypeParameterSyntax
typeParameterSyntax
,
TypeParameterConstraintClauseSyntax
constraintClauseSyntax
,
bool
isForOverride
,
DiagnosticBag
diagnostics
)
{
{
var
constraints
=
TypeParameterConstraintKind
.
None
;
var
constraints
=
TypeParameterConstraintKind
.
None
;
ArrayBuilder
<
TypeWithAnnotations
>
constraintTypes
=
null
;
ArrayBuilder
<
TypeWithAnnotations
>
?
constraintTypes
=
null
;
ArrayBuilder
<
TypeConstraintSyntax
>
syntaxBuilder
=
null
;
ArrayBuilder
<
TypeConstraintSyntax
>
?
syntaxBuilder
=
null
;
SeparatedSyntaxList
<
TypeParameterConstraintSyntax
>
constraintsSyntax
=
constraintClauseSyntax
.
Constraints
;
SeparatedSyntaxList
<
TypeParameterConstraintSyntax
>
constraintsSyntax
=
constraintClauseSyntax
.
Constraints
;
Debug
.
Assert
(!
InExecutableBinder
);
// Cannot eagerly report diagnostics handled by LazyMissingNonNullTypesContextDiagnosticInfo
Debug
.
Assert
(!
InExecutableBinder
);
// Cannot eagerly report diagnostics handled by LazyMissingNonNullTypesContextDiagnosticInfo
bool
hasTypeLikeConstraint
=
false
;
bool
hasTypeLikeConstraint
=
false
;
...
@@ -258,7 +259,7 @@ internal partial class Binder
...
@@ -258,7 +259,7 @@ internal partial class Binder
}
}
constraintTypes
.
Add
(
type
);
constraintTypes
.
Add
(
type
);
syntaxBuilder
.
Add
(
typeConstraintSyntax
);
syntaxBuilder
!
.
Add
(
typeConstraintSyntax
);
}
}
continue
;
continue
;
default
:
default
:
...
@@ -309,7 +310,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
...
@@ -309,7 +310,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
private
static
void
RemoveInvalidConstraints
(
private
static
void
RemoveInvalidConstraints
(
ImmutableArray
<
TypeParameterSymbol
>
typeParameters
,
ImmutableArray
<
TypeParameterSymbol
>
typeParameters
,
ArrayBuilder
<
TypeParameterConstraintClause
>
constraintClauses
,
ArrayBuilder
<
TypeParameterConstraintClause
>
constraintClauses
,
ArrayBuilder
<
ArrayBuilder
<
TypeConstraintSyntax
>>
syntaxNodes
,
ArrayBuilder
<
ArrayBuilder
<
TypeConstraintSyntax
>
?
>
syntaxNodes
,
DiagnosticBag
diagnostics
)
DiagnosticBag
diagnostics
)
{
{
Debug
.
Assert
(
typeParameters
.
Length
>
0
);
Debug
.
Assert
(
typeParameters
.
Length
>
0
);
...
@@ -324,7 +325,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
...
@@ -324,7 +325,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
private
static
TypeParameterConstraintClause
RemoveInvalidConstraints
(
private
static
TypeParameterConstraintClause
RemoveInvalidConstraints
(
TypeParameterSymbol
typeParameter
,
TypeParameterSymbol
typeParameter
,
TypeParameterConstraintClause
constraintClause
,
TypeParameterConstraintClause
constraintClause
,
ArrayBuilder
<
TypeConstraintSyntax
>
syntaxNodesOpt
,
ArrayBuilder
<
TypeConstraintSyntax
>
?
syntaxNodesOpt
,
DiagnosticBag
diagnostics
)
DiagnosticBag
diagnostics
)
{
{
if
(
syntaxNodesOpt
!=
null
)
if
(
syntaxNodesOpt
!=
null
)
...
@@ -367,7 +368,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
...
@@ -367,7 +368,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
TypeWithAnnotations
constraintType
,
TypeWithAnnotations
constraintType
,
DiagnosticBag
diagnostics
)
DiagnosticBag
diagnostics
)
{
{
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
=
null
;
HashSet
<
DiagnosticInfo
>
?
useSiteDiagnostics
=
null
;
if
(!
containingSymbol
.
IsNoMoreVisibleThan
(
constraintType
,
ref
useSiteDiagnostics
))
if
(!
containingSymbol
.
IsNoMoreVisibleThan
(
constraintType
,
ref
useSiteDiagnostics
))
{
{
// "Inconsistent accessibility: constraint type '{1}' is less accessible than '{0}'"
// "Inconsistent accessibility: constraint type '{1}' is less accessible than '{0}'"
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
浏览文件 @
2b80c8cb
此差异已折叠。
点击以展开。
src/Compilers/CSharp/Portable/Binder/BuckStopsHereBinder.cs
浏览文件 @
2b80c8cb
...
@@ -60,7 +60,7 @@ internal override Imports GetImports(ConsList<TypeSymbol> basesBeingResolved)
...
@@ -60,7 +60,7 @@ internal override Imports GetImports(ConsList<TypeSymbol> basesBeingResolved)
protected
override
bool
InExecutableBinder
=>
false
;
protected
override
bool
InExecutableBinder
=>
false
;
internal
override
bool
IsAccessibleHelper
(
Symbol
symbol
,
TypeSymbol
accessThroughType
,
out
bool
failedThroughTypeCheck
,
ref
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
,
ConsList
<
TypeSymbol
>
basesBeingResolved
)
internal
override
bool
IsAccessibleHelper
(
Symbol
symbol
,
TypeSymbol
accessThroughType
,
out
bool
failedThroughTypeCheck
,
ref
HashSet
<
DiagnosticInfo
>
?
useSiteDiagnostics
,
ConsList
<
TypeSymbol
>
basesBeingResolved
)
{
{
failedThroughTypeCheck
=
false
;
failedThroughTypeCheck
=
false
;
return
IsSymbolAccessibleConditional
(
symbol
,
Compilation
.
Assembly
,
ref
useSiteDiagnostics
);
return
IsSymbolAccessibleConditional
(
symbol
,
Compilation
.
Assembly
,
ref
useSiteDiagnostics
);
...
...
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
浏览文件 @
2b80c8cb
...
@@ -1783,11 +1783,11 @@ internal bool ReturnsAwaitableToVoidOrInt(MethodSymbol method, DiagnosticBag dia
...
@@ -1783,11 +1783,11 @@ internal bool ReturnsAwaitableToVoidOrInt(MethodSymbol method, DiagnosticBag dia
var
syntax
=
method
.
ExtractReturnTypeSyntax
();
var
syntax
=
method
.
ExtractReturnTypeSyntax
();
var
dumbInstance
=
new
BoundLiteral
(
syntax
,
ConstantValue
.
Null
,
namedType
);
var
dumbInstance
=
new
BoundLiteral
(
syntax
,
ConstantValue
.
Null
,
namedType
);
var
binder
=
GetBinder
(
syntax
);
var
binder
=
GetBinder
(
syntax
);
BoundExpression
result
;
BoundExpression
?
result
;
var
success
=
binder
.
GetAwaitableExpressionInfo
(
dumbInstance
,
out
result
,
syntax
,
diagnostics
);
var
success
=
binder
.
GetAwaitableExpressionInfo
(
dumbInstance
,
out
result
,
syntax
,
diagnostics
);
return
success
&&
return
success
&&
(
result
.
Type
!.
IsVoidType
()
||
result
.
Type
!.
SpecialType
==
SpecialType
.
System_Int32
);
(
result
!
.
Type
!.
IsVoidType
()
||
result
.
Type
!.
SpecialType
==
SpecialType
.
System_Int32
);
}
}
/// <summary>
/// <summary>
...
@@ -3168,7 +3168,7 @@ protected override IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol
...
@@ -3168,7 +3168,7 @@ protected override IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol
return
NamedTypeSymbol
.
CreateTuple
(
return
NamedTypeSymbol
.
CreateTuple
(
locationOpt
:
null
,
// no location for the type declaration
locationOpt
:
null
,
// no location for the type declaration
elementTypesWithAnnotations
:
typesBuilder
.
ToImmutableAndFree
(),
elementTypesWithAnnotations
:
typesBuilder
.
ToImmutableAndFree
(),
elementLocations
:
elementLocations
,
elementLocations
:
elementLocations
!
,
elementNames
:
elementNames
,
elementNames
:
elementNames
,
compilation
:
this
,
compilation
:
this
,
shouldCheckConstraints
:
false
,
shouldCheckConstraints
:
false
,
...
@@ -3194,7 +3194,7 @@ protected override IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol
...
@@ -3194,7 +3194,7 @@ protected override IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol
CheckTupleElementNullableAnnotations
(
cardinality
,
elementNullableAnnotations
);
CheckTupleElementNullableAnnotations
(
cardinality
,
elementNullableAnnotations
);
var
tupleType
=
NamedTypeSymbol
.
CreateTuple
(
var
tupleType
=
NamedTypeSymbol
.
CreateTuple
(
csharpUnderlyingTuple
,
elementNames
,
elementLocations
:
elementLocations
);
csharpUnderlyingTuple
,
elementNames
,
elementLocations
:
elementLocations
!
);
if
(!
elementNullableAnnotations
.
IsDefault
)
if
(!
elementNullableAnnotations
.
IsDefault
)
{
{
tupleType
=
tupleType
.
WithElementTypes
(
tupleType
=
tupleType
.
WithElementTypes
(
...
...
src/Compilers/CSharp/Portable/Symbols/SymbolExtensions.cs
浏览文件 @
2b80c8cb
...
@@ -91,7 +91,7 @@ public static bool IsNoMoreVisibleThan(this Symbol symbol, TypeSymbol type, ref
...
@@ -91,7 +91,7 @@ public static bool IsNoMoreVisibleThan(this Symbol symbol, TypeSymbol type, ref
return
type
.
IsAtLeastAsVisibleAs
(
symbol
,
ref
useSiteDiagnostics
);
return
type
.
IsAtLeastAsVisibleAs
(
symbol
,
ref
useSiteDiagnostics
);
}
}
public
static
bool
IsNoMoreVisibleThan
(
this
Symbol
symbol
,
TypeWithAnnotations
type
,
ref
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
)
public
static
bool
IsNoMoreVisibleThan
(
this
Symbol
symbol
,
TypeWithAnnotations
type
,
ref
HashSet
<
DiagnosticInfo
>
?
useSiteDiagnostics
)
{
{
return
type
.
IsAtLeastAsVisibleAs
(
symbol
,
ref
useSiteDiagnostics
);
return
type
.
IsAtLeastAsVisibleAs
(
symbol
,
ref
useSiteDiagnostics
);
}
}
...
...
src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
浏览文件 @
2b80c8cb
...
@@ -29,7 +29,7 @@ internal abstract partial class NamedTypeSymbol
...
@@ -29,7 +29,7 @@ internal abstract partial class NamedTypeSymbol
internal
static
NamedTypeSymbol
CreateTuple
(
internal
static
NamedTypeSymbol
CreateTuple
(
Location
?
locationOpt
,
Location
?
locationOpt
,
ImmutableArray
<
TypeWithAnnotations
>
elementTypesWithAnnotations
,
ImmutableArray
<
TypeWithAnnotations
>
elementTypesWithAnnotations
,
ImmutableArray
<
Location
>
elementLocations
,
ImmutableArray
<
Location
?
>
elementLocations
,
ImmutableArray
<
string
?>
elementNames
,
ImmutableArray
<
string
?>
elementNames
,
CSharpCompilation
compilation
,
CSharpCompilation
compilation
,
bool
shouldCheckConstraints
,
bool
shouldCheckConstraints
,
...
@@ -104,7 +104,7 @@ static NamedTypeSymbol getTupleUnderlyingType(ImmutableArray<TypeWithAnnotations
...
@@ -104,7 +104,7 @@ static NamedTypeSymbol getTupleUnderlyingType(ImmutableArray<TypeWithAnnotations
NamedTypeSymbol
tupleCompatibleType
,
NamedTypeSymbol
tupleCompatibleType
,
ImmutableArray
<
string
?>
elementNames
=
default
,
ImmutableArray
<
string
?>
elementNames
=
default
,
ImmutableArray
<
bool
>
errorPositions
=
default
,
ImmutableArray
<
bool
>
errorPositions
=
default
,
ImmutableArray
<
Location
>
elementLocations
=
default
,
ImmutableArray
<
Location
?
>
elementLocations
=
default
,
ImmutableArray
<
Location
>
locations
=
default
)
ImmutableArray
<
Location
>
locations
=
default
)
{
{
Debug
.
Assert
(
tupleCompatibleType
.
IsTupleType
);
Debug
.
Assert
(
tupleCompatibleType
.
IsTupleType
);
...
@@ -162,7 +162,7 @@ internal NamedTypeSymbol WithElementTypes(ImmutableArray<TypeWithAnnotations> ne
...
@@ -162,7 +162,7 @@ internal NamedTypeSymbol WithElementTypes(ImmutableArray<TypeWithAnnotations> ne
/// Drops the inferred positions.
/// Drops the inferred positions.
/// </summary>
/// </summary>
internal
NamedTypeSymbol
WithElementNames
(
ImmutableArray
<
string
?>
newElementNames
,
internal
NamedTypeSymbol
WithElementNames
(
ImmutableArray
<
string
?>
newElementNames
,
ImmutableArray
<
Location
>
newElementLocations
,
ImmutableArray
<
Location
?
>
newElementLocations
,
ImmutableArray
<
bool
>
errorPositions
,
ImmutableArray
<
bool
>
errorPositions
,
ImmutableArray
<
Location
>
locations
)
ImmutableArray
<
Location
>
locations
)
{
{
...
@@ -555,7 +555,7 @@ public sealed override bool IsTupleType
...
@@ -555,7 +555,7 @@ public sealed override bool IsTupleType
private
ImmutableArray
<
bool
>
TupleErrorPositions
private
ImmutableArray
<
bool
>
TupleErrorPositions
=>
_lazyTupleData
is
null
?
default
:
_lazyTupleData
.
ErrorPositions
;
=>
_lazyTupleData
is
null
?
default
:
_lazyTupleData
.
ErrorPositions
;
private
ImmutableArray
<
Location
>
TupleElementLocations
private
ImmutableArray
<
Location
?
>
TupleElementLocations
=>
_lazyTupleData
is
null
?
default
:
_lazyTupleData
.
ElementLocations
;
=>
_lazyTupleData
is
null
?
default
:
_lazyTupleData
.
ElementLocations
;
public
sealed
override
ImmutableArray
<
TypeWithAnnotations
>
TupleElementTypesWithAnnotations
public
sealed
override
ImmutableArray
<
TypeWithAnnotations
>
TupleElementTypesWithAnnotations
...
@@ -898,7 +898,7 @@ internal sealed class TupleExtraData
...
@@ -898,7 +898,7 @@ internal sealed class TupleExtraData
/// Declaration locations for individual elements, if provided.
/// Declaration locations for individual elements, if provided.
/// Declaration location for this tuple type symbol
/// Declaration location for this tuple type symbol
/// </summary>
/// </summary>
internal
ImmutableArray
<
Location
>
ElementLocations
{
get
;
}
internal
ImmutableArray
<
Location
?
>
ElementLocations
{
get
;
}
/// <summary>
/// <summary>
/// Which element names were inferred and therefore cannot be used.
/// Which element names were inferred and therefore cannot be used.
...
@@ -933,7 +933,7 @@ internal TupleExtraData(NamedTypeSymbol underlyingType)
...
@@ -933,7 +933,7 @@ internal TupleExtraData(NamedTypeSymbol underlyingType)
}
}
internal
TupleExtraData
(
NamedTypeSymbol
underlyingType
,
ImmutableArray
<
string
?>
elementNames
,
internal
TupleExtraData
(
NamedTypeSymbol
underlyingType
,
ImmutableArray
<
string
?>
elementNames
,
ImmutableArray
<
Location
>
elementLocations
,
ImmutableArray
<
bool
>
errorPositions
,
ImmutableArray
<
Location
>
locations
)
ImmutableArray
<
Location
?
>
elementLocations
,
ImmutableArray
<
bool
>
errorPositions
,
ImmutableArray
<
Location
>
locations
)
:
this
(
underlyingType
)
:
this
(
underlyingType
)
{
{
ElementNames
=
elementNames
;
ElementNames
=
elementNames
;
...
...
src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
浏览文件 @
2b80c8cb
...
@@ -488,9 +488,9 @@ public static MethodSymbol DelegateInvokeMethod(this TypeSymbol type)
...
@@ -488,9 +488,9 @@ public static MethodSymbol DelegateInvokeMethod(this TypeSymbol type)
return
null
;
return
null
;
}
}
public
static
SpecialType
GetSpecialTypeSafe
(
this
TypeSymbol
type
)
public
static
SpecialType
GetSpecialTypeSafe
(
this
TypeSymbol
?
type
)
{
{
return
(
object
)
type
!=
null
?
type
.
SpecialType
:
SpecialType
.
None
;
return
type
is
object
?
type
.
SpecialType
:
SpecialType
.
None
;
}
}
public
static
bool
IsAtLeastAsVisibleAs
(
this
TypeSymbol
type
,
Symbol
sym
,
ref
HashSet
<
DiagnosticInfo
>?
useSiteDiagnostics
)
public
static
bool
IsAtLeastAsVisibleAs
(
this
TypeSymbol
type
,
Symbol
sym
,
ref
HashSet
<
DiagnosticInfo
>?
useSiteDiagnostics
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录