Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4e5a2294
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,发现更多精彩内容 >>
未验证
提交
4e5a2294
编写于
4月 08, 2020
作者:
C
Charles Stoner
提交者:
GitHub
4月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce stack frame size of CheckConstraints (#43094)
上级
9e21d4d1
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
144 addition
and
95 deletion
+144
-95
src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs
src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs
+1
-1
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
...Binder/Semantics/OverloadResolution/OverloadResolution.cs
+0
-1
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs
.../Semantics/OverloadResolution/OverloadResolutionResult.cs
+1
-1
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
+1
-2
src/Compilers/CSharp/Portable/Symbols/ConstraintsHelper.cs
src/Compilers/CSharp/Portable/Symbols/ConstraintsHelper.cs
+91
-82
src/Compilers/CSharp/Portable/Symbols/ReducedExtensionMethodSymbol.cs
...s/CSharp/Portable/Symbols/ReducedExtensionMethodSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourceTypeParameterSymbol.cs
...harp/Portable/Symbols/Source/SourceTypeParameterSymbol.cs
+3
-6
src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
...mpilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
+1
-1
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
+45
-0
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs
浏览文件 @
4e5a2294
...
...
@@ -495,7 +495,7 @@ NamespaceOrTypeOrAliasSymbolWithAnnotations bindNullable()
ReportUseSiteDiagnostics
(
constructedType
.
Type
.
OriginalDefinition
,
diagnostics
,
syntax
);
var
type
=
(
NamedTypeSymbol
)
constructedType
.
Type
;
var
location
=
syntax
.
Location
;
type
.
CheckConstraints
(
this
.
Compilation
,
this
.
Conversions
,
includeNullability
:
true
,
location
,
diagnostics
);
type
.
CheckConstraints
(
new
ConstraintsHelper
.
CheckConstraintsArgs
(
this
.
Compilation
,
this
.
Conversions
,
includeNullability
:
true
,
location
,
diagnostics
)
);
}
else
if
(
constructedType
.
Type
.
IsTypeParameterDisallowingAnnotation
())
{
...
...
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
浏览文件 @
4e5a2294
...
...
@@ -386,7 +386,6 @@ private bool FailsConstraintChecks(MethodSymbol method, out ArrayBuilder<TypePar
bool
constraintsSatisfied
=
ConstraintsHelper
.
CheckMethodConstraints
(
method
,
this
.
Conversions
,
includeNullability
:
false
,
this
.
Compilation
,
diagnosticsBuilder
,
nullabilityDiagnosticsBuilderOpt
:
null
,
...
...
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs
浏览文件 @
4e5a2294
...
...
@@ -981,7 +981,7 @@ private void ReportDuplicateNamedArgument(MemberResolutionResult<TMember> result
// formal parameter type.
TypeSymbol
formalParameterType
=
method
.
GetParameterType
(
result
.
Result
.
BadParameter
);
formalParameterType
.
CheckAllConstraints
(
(
CSharpCompilation
)
compilation
,
conversions
,
includeNullability
:
false
,
location
,
diagnostics
);
formalParameterType
.
CheckAllConstraints
(
new
ConstraintsHelper
.
CheckConstraintsArgs
((
CSharpCompilation
)
compilation
,
conversions
,
includeNullability
:
false
,
location
,
diagnostics
)
);
return
true
;
}
...
...
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
浏览文件 @
4e5a2294
...
...
@@ -5354,7 +5354,6 @@ private void CheckMethodConstraints(SyntaxNode syntax, MethodSymbol method)
ConstraintsHelper
.
CheckMethodConstraints
(
method
,
_conversions
,
includeNullability
:
true
,
compilation
,
diagnosticsBuilder
,
nullabilityBuilder
,
...
...
@@ -5719,7 +5718,7 @@ private void VisitTupleExpression(BoundTupleExpression node)
if
(!
_disableDiagnostics
)
{
var
locations
=
tupleOpt
.
TupleElements
.
SelectAsArray
((
element
,
location
)
=>
element
.
Locations
.
FirstOrDefault
()
??
location
,
node
.
Syntax
.
Location
);
tupleOpt
.
CheckConstraints
(
_conversions
,
includeNullability
:
true
,
typeSyntax
:
node
.
Syntax
,
locations
,
currentCompilation
:
compilation
,
diagnosticsOpt
:
null
,
nullabilityDiagnosticsOpt
:
Diagnostics
);
tupleOpt
.
CheckConstraints
(
_conversions
,
typeSyntax
:
node
.
Syntax
,
locations
,
currentCompilation
:
compilation
,
diagnosticsOpt
:
null
,
nullabilityDiagnosticsOpt
:
Diagnostics
);
}
SetResultType
(
node
,
TypeWithState
.
Create
(
tupleOpt
,
NullableFlowState
.
NotNull
));
...
...
src/Compilers/CSharp/Portable/Symbols/ConstraintsHelper.cs
浏览文件 @
4e5a2294
此差异已折叠。
点击以展开。
src/Compilers/CSharp/Portable/Symbols/ReducedExtensionMethodSymbol.cs
浏览文件 @
4e5a2294
...
...
@@ -198,7 +198,7 @@ private static MethodSymbol InferExtensionMethodTypeArguments(MethodSymbol metho
var
diagnosticsBuilder
=
ArrayBuilder
<
TypeParameterDiagnosticInfo
>.
GetInstance
();
var
substitution
=
new
TypeMap
(
typeParams
,
typeArgsForConstraintsCheck
);
ArrayBuilder
<
TypeParameterDiagnosticInfo
>
useSiteDiagnosticsBuilder
=
null
;
var
success
=
method
.
CheckConstraints
(
conversions
,
includeNullability
:
false
,
substitution
,
typeParams
,
typeArgsForConstraintsCheck
,
compilation
,
diagnosticsBuilder
,
nullabilityDiagnosticsBuilderOpt
:
null
,
ref
useSiteDiagnosticsBuilder
,
var
success
=
method
.
CheckConstraints
(
conversions
,
substitution
,
typeParams
,
typeArgsForConstraintsCheck
,
compilation
,
diagnosticsBuilder
,
nullabilityDiagnosticsBuilderOpt
:
null
,
ref
useSiteDiagnosticsBuilder
,
ignoreTypeConstraintsDependentOnTypeParametersOpt
:
notInferredTypeParameters
.
Count
>
0
?
notInferredTypeParameters
:
null
);
diagnosticsBuilder
.
Free
();
notInferredTypeParameters
.
Free
();
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceTypeParameterSymbol.cs
浏览文件 @
4e5a2294
...
...
@@ -256,18 +256,15 @@ private void CheckConstraintTypeConstraints(DiagnosticBag diagnostics)
return
;
}
var
corLibrary
=
this
.
ContainingAssembly
.
CorLibrary
;
var
conversions
=
new
TypeConversions
(
corLibrary
);
var
location
=
_locations
[
0
];
var
args
=
new
ConstraintsHelper
.
CheckConstraintsArgs
(
DeclaringCompilation
,
new
TypeConversions
(
ContainingAssembly
.
CorLibrary
),
_locations
[
0
],
diagnostics
);
foreach
(
var
constraintType
in
constraintTypes
)
{
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
=
null
;
constraintType
.
Type
.
AddUseSiteDiagnostics
(
ref
useSiteDiagnostics
);
if
(!
diagnostics
.
Add
(
l
ocation
,
useSiteDiagnostics
))
if
(!
diagnostics
.
Add
(
args
.
L
ocation
,
useSiteDiagnostics
))
{
constraintType
.
Type
.
CheckAllConstraints
(
DeclaringCompilation
,
conversions
,
location
,
diagnostic
s
);
constraintType
.
Type
.
CheckAllConstraints
(
arg
s
);
}
}
}
...
...
src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
浏览文件 @
4e5a2294
...
...
@@ -67,7 +67,7 @@ internal abstract partial class NamedTypeSymbol
var
constructedType
=
CreateTuple
(
underlyingType
,
elementNames
,
errorPositions
,
elementLocations
,
locations
);
if
(
shouldCheckConstraints
&&
diagnostics
!=
null
)
{
constructedType
.
CheckConstraints
(
compilation
.
Conversions
,
includeNullability
,
syntax
,
elementLocations
,
compilation
,
diagnostics
,
diagnostics
);
constructedType
.
CheckConstraints
(
compilation
.
Conversions
,
syntax
,
elementLocations
,
compilation
,
diagnosticsOpt
:
diagnostics
,
nullabilityDiagnosticsOpt
:
includeNullability
?
diagnostics
:
null
);
}
return
constructedType
;
...
...
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
浏览文件 @
4e5a2294
...
...
@@ -8,6 +8,8 @@
using
Xunit
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.PooledObjects
;
namespace
Microsoft.CodeAnalysis.CSharp.UnitTests.Emit
{
...
...
@@ -267,5 +269,48 @@ static void Main()
});
}
}
[WorkItem(42361, "
https
:
//github.com/dotnet/roslyn/issues/42361")]
[
ConditionalFact
(
typeof
(
WindowsOnly
))]
public
void
Constraints
()
{
int
n
=
(
ExecutionConditionUtil
.
Architecture
,
ExecutionConditionUtil
.
Configuration
)
switch
{
(
ExecutionArchitecture
.
x86
,
ExecutionConfiguration
.
Debug
)
=>
420
,
(
ExecutionArchitecture
.
x86
,
ExecutionConfiguration
.
Release
)
=>
1100
,
(
ExecutionArchitecture
.
x64
,
ExecutionConfiguration
.
Debug
)
=>
200
,
(
ExecutionArchitecture
.
x64
,
ExecutionConfiguration
.
Release
)
=>
520
,
_
=>
throw
new
Exception
(
$"Unexpected configuration
{
ExecutionConditionUtil
.
Architecture
}
{
ExecutionConditionUtil
.
Configuration
}
"
)
};
RunTest
(
n
,
runTest
);
static
void
runTest
(
int
n
)
{
// class C0<T> where T : C1<T> { }
// class C1<T> where T : C2<T> { }
// ...
// class CN<T> where T : C0<T> { }
var
sourceBuilder
=
new
StringBuilder
();
var
diagnosticsBuilder
=
ArrayBuilder
<
DiagnosticDescription
>.
GetInstance
();
for
(
int
i
=
0
;
i
<=
n
;
i
++)
{
int
next
=
(
i
==
n
)
?
0
:
i
+
1
;
sourceBuilder
.
AppendLine
(
$"class C
{
i
}
<T> where T : C
{
next
}
<T>
{{
}}
"
);
diagnosticsBuilder
.
Add
(
Diagnostic
(
ErrorCode
.
ERR_GenericConstraintNotSatisfiedRefType
,
"T"
).
WithArguments
(
$"C
{
i
}
<T>"
,
$"C
{
next
}
<T>"
,
"T"
,
"T"
));
}
var
source
=
sourceBuilder
.
ToString
();
var
diagnostics
=
diagnosticsBuilder
.
ToArrayAndFree
();
RunInThread
(()
=>
{
var
comp
=
CreateCompilation
(
source
);
var
type
=
comp
.
GetMember
<
NamedTypeSymbol
>(
"C0"
);
var
typeParameter
=
type
.
TypeParameters
[
0
];
Assert
.
True
(
typeParameter
.
IsReferenceType
);
comp
.
VerifyDiagnostics
(
diagnostics
);
});
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录