Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e6475bc8
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,发现更多精彩内容 >>
未验证
提交
e6475bc8
编写于
9月 15, 2020
作者:
R
Rikki Gibson
提交者:
GitHub
9月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename in CheckValidNullableMethodOverride (#47718)
上级
3ff2738a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
39 deletion
+39
-39
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol_ImplementationChecks.cs
...ource/SourceMemberContainerSymbol_ImplementationChecks.cs
+39
-39
未找到文件。
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol_ImplementationChecks.cs
浏览文件 @
e6475bc8
...
...
@@ -1176,53 +1176,53 @@ private bool IsValidOverrideReturnType(Symbol overridingSymbol, TypeWithAnnotati
internal
static
void
CheckValidNullableMethodOverride
<
TArg
>(
CSharpCompilation
compilation
,
MethodSymbol
overridden
Method
,
MethodSymbol
overrid
ing
Method
,
MethodSymbol
base
Method
,
MethodSymbol
overrid
e
Method
,
DiagnosticBag
diagnostics
,
ReportMismatchInReturnType
<
TArg
>
reportMismatchInReturnType
,
ReportMismatchInParameterType
<
TArg
>
reportMismatchInParameterType
,
TArg
extraArgument
,
bool
invokedAsExtensionMethod
=
false
)
{
if
(!
PerformValidNullableOverrideCheck
(
compilation
,
overriddenMethod
,
overriding
Method
))
if
(!
PerformValidNullableOverrideCheck
(
compilation
,
baseMethod
,
override
Method
))
{
return
;
}
if
((
overridden
Method
.
FlowAnalysisAnnotations
&
FlowAnalysisAnnotations
.
DoesNotReturn
)
==
FlowAnalysisAnnotations
.
DoesNotReturn
&&
(
overrid
ing
Method
.
FlowAnalysisAnnotations
&
FlowAnalysisAnnotations
.
DoesNotReturn
)
!=
FlowAnalysisAnnotations
.
DoesNotReturn
)
if
((
base
Method
.
FlowAnalysisAnnotations
&
FlowAnalysisAnnotations
.
DoesNotReturn
)
==
FlowAnalysisAnnotations
.
DoesNotReturn
&&
(
overrid
e
Method
.
FlowAnalysisAnnotations
&
FlowAnalysisAnnotations
.
DoesNotReturn
)
!=
FlowAnalysisAnnotations
.
DoesNotReturn
)
{
diagnostics
.
Add
(
ErrorCode
.
WRN_DoesNotReturnMismatch
,
overrid
ingMethod
.
Locations
[
0
],
new
FormattedSymbol
(
overriding
Method
,
SymbolDisplayFormat
.
MinimallyQualifiedFormat
));
diagnostics
.
Add
(
ErrorCode
.
WRN_DoesNotReturnMismatch
,
overrid
eMethod
.
Locations
[
0
],
new
FormattedSymbol
(
override
Method
,
SymbolDisplayFormat
.
MinimallyQualifiedFormat
));
}
var
conversions
=
compilation
.
Conversions
.
WithNullability
(
true
);
var
overriddenParameters
=
overridden
Method
.
Parameters
;
var
overrid
ingParameters
=
overriding
Method
.
Parameters
;
var
overrid
ingMethod
Offset
=
invokedAsExtensionMethod
?
1
:
0
;
Debug
.
Assert
(
overriddenMethod
.
ParameterCount
==
overridingMethod
.
ParameterCount
-
overridingMethod
Offset
);
var
baseParameters
=
base
Method
.
Parameters
;
var
overrid
eParameters
=
override
Method
.
Parameters
;
var
overrid
eParameter
Offset
=
invokedAsExtensionMethod
?
1
:
0
;
Debug
.
Assert
(
baseMethod
.
ParameterCount
==
overrideMethod
.
ParameterCount
-
overrideParameter
Offset
);
if
(
reportMismatchInReturnType
!=
null
)
{
var
overrid
ingReturnType
=
getNotNullIfNotNullOutputType
(
overridingMethod
.
ReturnTypeWithAnnotations
,
overriding
Method
.
ReturnNotNullIfParameterNotNull
);
var
overrid
eReturnType
=
getNotNullIfNotNullOutputType
(
overrideMethod
.
ReturnTypeWithAnnotations
,
override
Method
.
ReturnNotNullIfParameterNotNull
);
// check nested nullability
if
(!
isValidNullableConversion
(
conversions
,
overrid
ing
Method
.
RefKind
,
overrid
ing
ReturnType
.
Type
,
overridden
Method
.
ReturnTypeWithAnnotations
.
Type
))
overrid
e
Method
.
RefKind
,
overrid
e
ReturnType
.
Type
,
base
Method
.
ReturnTypeWithAnnotations
.
Type
))
{
reportMismatchInReturnType
(
diagnostics
,
overriddenMethod
,
overriding
Method
,
false
,
extraArgument
);
reportMismatchInReturnType
(
diagnostics
,
baseMethod
,
override
Method
,
false
,
extraArgument
);
return
;
}
// check top-level nullability including flow analysis annotations
if
(!
NullableWalker
.
AreParameterAnnotationsCompatible
(
overrid
ing
Method
.
RefKind
==
RefKind
.
Ref
?
RefKind
.
Ref
:
RefKind
.
Out
,
overridden
Method
.
ReturnTypeWithAnnotations
,
overridden
Method
.
ReturnTypeFlowAnalysisAnnotations
,
overrid
ing
ReturnType
,
overrid
ing
Method
.
ReturnTypeFlowAnalysisAnnotations
))
overrid
e
Method
.
RefKind
==
RefKind
.
Ref
?
RefKind
.
Ref
:
RefKind
.
Out
,
base
Method
.
ReturnTypeWithAnnotations
,
base
Method
.
ReturnTypeFlowAnalysisAnnotations
,
overrid
e
ReturnType
,
overrid
e
Method
.
ReturnTypeFlowAnalysisAnnotations
))
{
reportMismatchInReturnType
(
diagnostics
,
overriddenMethod
,
overriding
Method
,
true
,
extraArgument
);
reportMismatchInReturnType
(
diagnostics
,
baseMethod
,
override
Method
,
true
,
extraArgument
);
return
;
}
}
...
...
@@ -1232,30 +1232,30 @@ private bool IsValidOverrideReturnType(Symbol overridingSymbol, TypeWithAnnotati
return
;
}
for
(
int
i
=
0
;
i
<
overridden
Parameters
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
base
Parameters
.
Length
;
i
++)
{
var
overriddenParameter
=
overridden
Parameters
[
i
];
var
overriddenParameterType
=
overridden
Parameter
.
TypeWithAnnotations
;
var
overrid
ingParameter
=
overridingParameters
[
i
+
overridingMethod
Offset
];
var
overrid
ingParameterType
=
getNotNullIfNotNullOutputType
(
overridingParameter
.
TypeWithAnnotations
,
overriding
Parameter
.
NotNullIfParameterNotNull
);
var
baseParameter
=
base
Parameters
[
i
];
var
baseParameterType
=
base
Parameter
.
TypeWithAnnotations
;
var
overrid
eParameter
=
overrideParameters
[
i
+
overrideParameter
Offset
];
var
overrid
eParameterType
=
getNotNullIfNotNullOutputType
(
overrideParameter
.
TypeWithAnnotations
,
override
Parameter
.
NotNullIfParameterNotNull
);
// check nested nullability
if
(!
isValidNullableConversion
(
conversions
,
overrid
ing
Parameter
.
RefKind
,
overridden
ParameterType
.
Type
,
overrid
ing
ParameterType
.
Type
))
overrid
e
Parameter
.
RefKind
,
base
ParameterType
.
Type
,
overrid
e
ParameterType
.
Type
))
{
reportMismatchInParameterType
(
diagnostics
,
overriddenMethod
,
overridingMethod
,
overriding
Parameter
,
false
,
extraArgument
);
reportMismatchInParameterType
(
diagnostics
,
baseMethod
,
overrideMethod
,
override
Parameter
,
false
,
extraArgument
);
}
// check top-level nullability including flow analysis annotations
else
if
(!
NullableWalker
.
AreParameterAnnotationsCompatible
(
overrid
ing
Parameter
.
RefKind
,
overridden
ParameterType
,
overridden
Parameter
.
FlowAnalysisAnnotations
,
overrid
ing
ParameterType
,
overrid
ing
Parameter
.
FlowAnalysisAnnotations
))
overrid
e
Parameter
.
RefKind
,
base
ParameterType
,
base
Parameter
.
FlowAnalysisAnnotations
,
overrid
e
ParameterType
,
overrid
e
Parameter
.
FlowAnalysisAnnotations
))
{
reportMismatchInParameterType
(
diagnostics
,
overriddenMethod
,
overridingMethod
,
overriding
Parameter
,
true
,
extraArgument
);
reportMismatchInParameterType
(
diagnostics
,
baseMethod
,
overrideMethod
,
override
Parameter
,
true
,
extraArgument
);
}
}
...
...
@@ -1263,10 +1263,10 @@ TypeWithAnnotations getNotNullIfNotNullOutputType(TypeWithAnnotations outputType
{
if
(!
notNullIfParameterNotNull
.
IsEmpty
)
{
for
(
var
i
=
0
;
i
<
overridden
Parameters
.
Length
;
i
++)
for
(
var
i
=
0
;
i
<
base
Parameters
.
Length
;
i
++)
{
var
overrid
ingParam
=
overridingParameters
[
i
+
overridingMethod
Offset
];
if
(
notNullIfParameterNotNull
.
Contains
(
overrid
ingParam
.
Name
)
&&
!
overridden
Parameters
[
i
].
TypeWithAnnotations
.
NullableAnnotation
.
IsAnnotated
())
var
overrid
eParam
=
overrideParameters
[
i
+
overrideParameter
Offset
];
if
(
notNullIfParameterNotNull
.
Contains
(
overrid
eParam
.
Name
)
&&
!
base
Parameters
[
i
].
TypeWithAnnotations
.
NullableAnnotation
.
IsAnnotated
())
{
return
outputType
.
AsNotAnnotated
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录