Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
2ad93d9a
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,发现更多精彩内容 >>
未验证
提交
2ad93d9a
编写于
8月 31, 2018
作者:
C
Charles Stoner
提交者:
GitHub
8月 31, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address some PROTOTYPE comments (#29607)
上级
56eae9f4
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
97 addition
and
88 deletion
+97
-88
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
+0
-2
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
+0
-1
src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs
.../Portable/Binder/Semantics/Conversions/ConversionsBase.cs
+2
-2
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodTypeInference.cs
...inder/Semantics/OverloadResolution/MethodTypeInference.cs
+4
-11
src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
+0
-1
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
+20
-20
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
+4
-3
src/Compilers/CSharp/Portable/Symbols/TypeSymbolWithAnnotations.cs
...lers/CSharp/Portable/Symbols/TypeSymbolWithAnnotations.cs
+2
-3
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
...rp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
+60
-39
src/Compilers/CSharp/Test/Semantic/Semantics/OperatorTests.cs
...Compilers/CSharp/Test/Semantic/Semantics/OperatorTests.cs
+1
-1
src/Compilers/CSharp/Test/Symbol/Symbols/TypeTests.cs
src/Compilers/CSharp/Test/Symbol/Symbols/TypeTests.cs
+3
-3
src/Compilers/Core/Portable/SymbolDisplay/SymbolDisplayMiscellaneousOptions.cs
...rtable/SymbolDisplay/SymbolDisplayMiscellaneousOptions.cs
+1
-1
src/Compilers/Core/Portable/Symbols/TypeCompareKind.cs
src/Compilers/Core/Portable/Symbols/TypeCompareKind.cs
+0
-1
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
浏览文件 @
2ad93d9a
...
...
@@ -1405,7 +1405,6 @@ private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedA
}
else
{
// PROTOTYPE(NullableReferenceTypes): this TypeSymbolWithAnnotations has bad annotation and context
newArguments
[
i
]
=
((
OutVariablePendingInference
)
argument
).
SetInferredType
(
TypeSymbolWithAnnotations
.
Create
(
candidateType
),
null
);
}
}
...
...
@@ -1417,7 +1416,6 @@ private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedA
}
else
{
// PROTOTYPE(NullableReferenceTypes): this TypeSymbolWithAnnotations has bad annotation and context
newArguments
[
i
]
=
((
BoundDiscardExpression
)
argument
).
SetInferredType
(
TypeSymbolWithAnnotations
.
Create
(
candidateType
));
}
}
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
浏览文件 @
2ad93d9a
...
...
@@ -1354,7 +1354,6 @@ private BoundExpression InferTypeForDiscardAssignment(BoundDiscardExpression op1
diagnostics
.
Add
(
ErrorCode
.
ERR_VoidAssignment
,
op1
.
Syntax
.
Location
);
}
// PROTOTYPE(NullableReferenceTypes): this TypeSymbolWithAnnotations has bad annotation and context
return
op1
.
SetInferredType
(
TypeSymbolWithAnnotations
.
Create
(
inferredType
));
}
...
...
src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs
浏览文件 @
2ad93d9a
...
...
@@ -1366,9 +1366,9 @@ private static bool HasIdentityConversionInternal(TypeSymbol type1, TypeSymbol t
Debug
.
Assert
((
object
)
type1
!=
null
);
Debug
.
Assert
((
object
)
type2
!=
null
);
//
PROTOTYPE(NullableReferenceTypes)
: If two types differ only by nullability and
//
https://github.com/dotnet/roslyn/issues/27961
: If two types differ only by nullability and
// one has IsNullable unset and the other doesn't, which do we choose in inference?
// See
test
TypeInference_04.
// See
NullableReferenceTypesTests.
TypeInference_04.
var
compareKind
=
includeNullability
?
TypeCompareKind
.
AllIgnoreOptions
|
TypeCompareKind
.
CompareNullableModifiersForReferenceTypes
|
TypeCompareKind
.
UnknownNullableModifierMatchesAny
:
TypeCompareKind
.
AllIgnoreOptions
;
...
...
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodTypeInference.cs
浏览文件 @
2ad93d9a
...
...
@@ -2474,7 +2474,7 @@ private bool Fix(int iParam, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
// Make a copy; don't modify the collection as we're iterating it.
foreach
(
var
candidate
in
initialCandidates
)
{
if
(!
bound
.
Equals
(
candidate
,
TypeCompareKind
.
AllAspect
s
))
if
(!
bound
.
Equals
(
candidate
,
TypeCompareKind
.
CompareNullableModifiersForReferenceType
s
))
{
if
(!
ImplicitConversionExists
(
bound
,
candidate
,
ref
useSiteDiagnostics
,
conversions
,
includeNullability
))
{
...
...
@@ -2498,7 +2498,7 @@ private bool Fix(int iParam, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
foreach
(
var
candidate
in
initialCandidates
)
{
if
(!
bound
.
Equals
(
candidate
,
TypeCompareKind
.
AllAspect
s
))
if
(!
bound
.
Equals
(
candidate
,
TypeCompareKind
.
CompareNullableModifiersForReferenceType
s
))
{
if
(!
ImplicitConversionExists
(
candidate
,
bound
,
ref
useSiteDiagnostics
,
conversions
,
includeNullability
))
{
...
...
@@ -2524,7 +2524,7 @@ private bool Fix(int iParam, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
foreach
(
var
candidate2
in
initialCandidates
)
{
if
(!
candidate
.
Equals
(
candidate2
,
TypeCompareKind
.
AllAspect
s
)
&&
if
(!
candidate
.
Equals
(
candidate2
,
TypeCompareKind
.
CompareNullableModifiersForReferenceType
s
)
&&
!
ImplicitConversionExists
(
candidate2
,
candidate
,
ref
useSiteDiagnostics
,
conversions
,
includeNullability
))
{
goto
OuterBreak
;
...
...
@@ -2546,7 +2546,7 @@ private bool Fix(int iParam, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
Debug
.
Assert
(!(
best
.
IsObjectType
()
&&
candidate
.
IsDynamic
()));
Debug
.
Assert
(!(
best
.
IsDynamic
()
&&
candidate
.
IsObjectType
()));
best
=
Merge
(
best
,
candidate
,
conversions
.
CorLibrary
);
best
=
Merge
Nullability
(
MergeTupleNames
(
MergeDynamic
(
best
,
candidate
,
conversions
.
CorLibrary
),
candidate
),
candidate
);
}
else
{
...
...
@@ -2580,12 +2580,6 @@ internal static TypeSymbol Merge(TypeSymbol first, TypeSymbol second, AssemblySy
return
MergeNullability
(
MergeTupleNames
(
MergeDynamic
(
firstWithAnnotations
,
secondWithAnnotations
,
corLibrary
),
secondWithAnnotations
),
secondWithAnnotations
).
TypeSymbol
;
}
// PROTOTYPE(NullableReferenceTypes): Remove this overload.
internal
static
TypeSymbolWithAnnotations
Merge
(
TypeSymbolWithAnnotations
first
,
TypeSymbolWithAnnotations
second
,
AssemblySymbol
corLibrary
)
{
return
MergeNullability
(
MergeTupleNames
(
MergeDynamic
(
first
,
second
,
corLibrary
),
second
),
second
);
}
/// <summary>
/// Returns first or a modified version of first with merged dynamic flags from both types.
/// </summary>
...
...
@@ -2678,7 +2672,6 @@ private static bool ImplicitConversionExists(TypeSymbolWithAnnotations sourceWit
return
false
;
}
// PROTOTYPE(NullableReferenceTypes): Pass includeNullability to ClassifyImplicitConversionFromType.
return
conversions
.
ClassifyImplicitConversionFromType
(
source
,
destination
,
ref
useSiteDiagnostics
).
Exists
;
}
...
...
src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
浏览文件 @
2ad93d9a
...
...
@@ -1734,7 +1734,6 @@
</Node>
<!-- Node only used during nullability flow analysis to represent an expression with an updated nullability -->
<!-- PROTOTYPE(NullableReferenceTypes): Derive from BoundValuePlaceholderBase. -->
<Node
Name=
"BoundExpressionWithNullability"
Base=
"BoundExpression"
>
<Field
Name=
"Expression"
Type=
"BoundExpression"
Null=
"disallow"
/>
<Field
Name=
"Type"
Type=
"TypeSymbol"
Override=
"true"
Null=
"allow"
/>
<!-- We use null Type for placeholders representing out vars -->
...
...
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
浏览文件 @
2ad93d9a
...
...
@@ -28,8 +28,8 @@ internal sealed partial class NullableWalker : DataFlowPassBase<NullableWalker.L
/// </summary>
internal
sealed
class
VariableState
{
//
PROTOTYPE(NullableReferenceTypes): Reference the collections directly from the original
//
NullableWalker rather
than coping the collections. (Items are added to the collections
//
Consider referencing the collections directly from the original NullableWalker
//
rather
than coping the collections. (Items are added to the collections
// but never replaced so the collections are lazily populated but otherwise immutable.)
internal
readonly
ImmutableDictionary
<
VariableIdentifier
,
int
>
VariableSlot
;
internal
readonly
ImmutableArray
<
VariableIdentifier
>
VariableBySlot
;
...
...
@@ -1013,7 +1013,7 @@ public override BoundNode VisitLocalDeclaration(BoundLocalDeclaration node)
protected
override
BoundExpression
VisitExpressionWithoutStackGuard
(
BoundExpression
node
)
{
Debug
.
Assert
(!
IsConditionalState
);
_resultType
=
_invalidType
;
// PROTOTYPE(NullableReferenceTypes): Move to `Visit` method?
_resultType
=
_invalidType
;
var
result
=
base
.
VisitExpressionWithoutStackGuard
(
node
);
#if DEBUG
// Verify Visit method set _result.
...
...
@@ -1376,7 +1376,7 @@ private TypeSymbolWithAnnotations InferResultNullability(BinaryOperatorKind oper
// PROTOTYPE(NullableReferenceTypes): Conversions: Lifted operator
return
TypeSymbolWithAnnotations
.
Create
(
resultType
);
}
//
PROTOTYPE(NullableReferenceTypes): Update method based on operand types
.
//
Update method based on operand types: see https://github.com/dotnet/roslyn/issues/29605
.
if
((
object
)
methodOpt
!=
null
&&
methodOpt
.
ParameterCount
==
2
)
{
return
methodOpt
.
ReturnType
;
...
...
@@ -1418,7 +1418,7 @@ private TypeSymbolWithAnnotations InferResultNullability(BinaryOperatorKind oper
protected
override
void
AfterLeftChildHasBeenVisited
(
BoundBinaryOperator
binary
)
{
Debug
.
Assert
(!
IsConditionalState
);
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
TypeSymbolWithAnnotations
leftType
=
_resultType
;
bool
warnOnNullReferenceArgument
=
(
binary
.
OperatorKind
.
IsUserDefined
()
&&
(
object
)
binary
.
MethodOpt
!=
null
&&
binary
.
MethodOpt
.
ParameterCount
==
2
);
...
...
@@ -1897,7 +1897,7 @@ public override BoundNode VisitCall(BoundCall node)
{
VisitRvalue
(
receiverOpt
);
CheckPossibleNullReceiver
(
receiverOpt
);
//
PROTOTYPE(NullableReferenceTypes): Update method based on inferred receiver type
.
//
Update method based on inferred receiver type: see https://github.com/dotnet/roslyn/issues/29605
.
}
// PROTOTYPE(NullableReferenceTypes): Can we handle some error cases?
...
...
@@ -1919,7 +1919,7 @@ public override BoundNode VisitCall(BoundCall node)
ReplayReadsAndWrites
(
localFunc
,
node
.
Syntax
,
writes
:
true
);
}
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
_resultType
=
method
.
ReturnType
;
}
...
...
@@ -3041,7 +3041,7 @@ private static bool HasTopLevelNullabilityConversion(TypeSymbolWithAnnotations s
useLegacyWarnings
,
assignmentKind
);
//
PROTOTYPE(NullableReferenceTypes): Update method based on operandType
//
Update method based on operandType: see https://github.com/dotnet/roslyn/issues/29605.
// (see NullableReferenceTypesTests.ImplicitConversions_07).
var
methodOpt
=
conversion
.
Method
;
Debug
.
Assert
((
object
)
methodOpt
!=
null
);
...
...
@@ -3215,7 +3215,7 @@ public override BoundNode VisitMethodGroup(BoundMethodGroup node)
CheckPossibleNullReceiver
(
receiverOpt
);
}
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
_resultType
=
default
;
}
...
...
@@ -3326,9 +3326,9 @@ private static bool UseLegacyWarnings(BoundExpression expr)
public
override
BoundNode
VisitDeconstructionAssignmentOperator
(
BoundDeconstructionAssignmentOperator
node
)
{
// PROTOTYPE(NullableReferenceTypes): Assign each of the deconstructed values.
// https://github.com/dotnet/roslyn/issues/29618: Assign each of the deconstructed values,
// and handle deconstruction conversion for node.Right.
VisitLvalue
(
node
.
Left
);
// PROTOTYPE(NullableReferenceTypes): Handle deconstruction conversion node.Right.
VisitRvalue
(
node
.
Right
.
Operand
);
SetResult
(
node
);
return
null
;
...
...
@@ -3439,7 +3439,7 @@ public override BoundNode VisitCompoundAssignmentOperator(BoundCompoundAssignmen
TypeSymbolWithAnnotations
resultType
;
Debug
.
Assert
(!
IsConditionalState
);
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
TypeSymbolWithAnnotations
leftOnRightType
=
GetAdjustedResult
(
leftType
,
MakeSlot
(
node
.
Left
));
...
...
@@ -3602,7 +3602,7 @@ private void VisitMemberAccess(BoundExpression receiverOpt, Symbol member, bool
{
Debug
.
Assert
(!
IsConditionalState
);
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
VisitRvalue
(
receiverOpt
);
...
...
@@ -3719,7 +3719,7 @@ public override BoundNode VisitUnaryOperator(BoundUnaryOperator node)
var
result
=
base
.
VisitUnaryOperator
(
node
);
TypeSymbolWithAnnotations
resultType
=
default
;
//
PROTOTYPE(NullableReferenceTypes): Update method based on inferred operand type
.
//
Update method based on inferred operand type: see https://github.com/dotnet/roslyn/issues/29605
.
if
(
node
.
OperatorKind
.
IsUserDefined
())
{
if
(
node
.
OperatorKind
.
IsLifted
())
...
...
@@ -3779,7 +3779,7 @@ private TypeSymbolWithAnnotations InferResultNullability(BoundUserDefinedConditi
// PROTOTYPE(NullableReferenceTypes): Conversions: Lifted operator
return
TypeSymbolWithAnnotations
.
Create
(
node
.
Type
);
}
//
PROTOTYPE(NullableReferenceTypes): Update method based on inferred operand types
.
//
Update method based on inferred operand types: see https://github.com/dotnet/roslyn/issues/29605
.
if
((
object
)
node
.
LogicalOperator
!=
null
&&
node
.
LogicalOperator
.
ParameterCount
==
2
)
{
return
node
.
LogicalOperator
.
ReturnType
;
...
...
@@ -3793,7 +3793,7 @@ private TypeSymbolWithAnnotations InferResultNullability(BoundUserDefinedConditi
protected
override
void
AfterLeftChildOfBinaryLogicalOperatorHasBeenVisited
(
BoundExpression
node
,
BoundExpression
right
,
bool
isAnd
,
bool
isBool
,
ref
LocalState
leftTrue
,
ref
LocalState
leftFalse
)
{
Debug
.
Assert
(!
IsConditionalState
);
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
TypeSymbolWithAnnotations
leftType
=
_resultType
;
// PROTOTYPE(NullableReferenceTypes): Update operator methods based on inferred operand types.
...
...
@@ -3872,7 +3872,7 @@ public override BoundNode VisitAwaitExpression(BoundAwaitExpression node)
}
else
{
//
PROTOTYPE(NullableReferenceTypes): Update method based on inferred receiver type
.
//
Update method based on inferred receiver type: see https://github.com/dotnet/roslyn/issues/29605
.
_resultType
=
node
.
GetResult
.
ReturnType
;
}
return
result
;
...
...
@@ -3939,7 +3939,7 @@ public override BoundNode VisitAsOperator(BoundAsOperator node)
{
var
result
=
base
.
VisitAsOperator
(
node
);
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
bool
?
isNullable
=
null
;
if
(!
node
.
Type
.
IsValueType
)
...
...
@@ -3982,7 +3982,7 @@ public override BoundNode VisitSuppressNullableWarningExpression(BoundSuppressNu
{
base
.
VisitSuppressNullableWarningExpression
(
node
);
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
_resultType
=
_resultType
.
IsNull
?
default
:
_resultType
.
WithTopLevelNonNullabilityForReferenceTypes
();
}
...
...
@@ -4018,7 +4018,7 @@ public override BoundNode VisitLiteral(BoundLiteral node)
var
result
=
base
.
VisitLiteral
(
node
);
Debug
.
Assert
(!
IsConditionalState
);
//if (this.State.Reachable) //
PROTOTYPE(NullableReferenceTypes): Consider reachability?
//if (this.State.Reachable) //
Consider reachability: see https://github.com/dotnet/roslyn/issues/28798
{
var
constant
=
node
.
ConstantValue
;
...
...
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
浏览文件 @
2ad93d9a
...
...
@@ -843,7 +843,8 @@ internal override TypeSymbol SetUnknownNullabilityForReferenceTypes()
/// parameters in the type.</param>
public
NamedTypeSymbol
Construct
(
params
TypeSymbol
[]
typeArguments
)
{
return
ConstructWithoutModifiers
(
typeArguments
.
AsImmutableOrNull
(),
false
,
nonNullTypesContext
:
null
);
// PROTOTYPE(NullableReferenceTypes): We should fix the callers to pass an explicit context.
return
ConstructWithoutModifiers
(
typeArguments
.
AsImmutableOrNull
(),
false
,
NonNullTypesFalseContext
.
Instance
);
}
/// <summary>
...
...
@@ -865,7 +866,7 @@ public NamedTypeSymbol Construct(INonNullTypesContext nonNullTypesContext, param
public
NamedTypeSymbol
Construct
(
ImmutableArray
<
TypeSymbol
>
typeArguments
,
INonNullTypesContext
nonNullTypesContext
=
null
)
{
// PROTOTYPE(NullableReferenceTypes): We should fix the callers to pass an explicit context.
return
ConstructWithoutModifiers
(
typeArguments
,
false
,
nonNullTypesContext
);
return
ConstructWithoutModifiers
(
typeArguments
,
false
,
nonNullTypesContext
??
NonNullTypesFalseContext
.
Instance
);
}
/// <summary>
...
...
@@ -875,7 +876,7 @@ public NamedTypeSymbol Construct(ImmutableArray<TypeSymbol> typeArguments, INonN
public
NamedTypeSymbol
Construct
(
IEnumerable
<
TypeSymbol
>
typeArguments
)
{
// PROTOTYPE(NullableReferenceTypes): We should fix the callers to pass an explicit context.
return
ConstructWithoutModifiers
(
typeArguments
.
AsImmutableOrNull
(),
false
,
nonNullTypesContext
:
null
);
return
ConstructWithoutModifiers
(
typeArguments
.
AsImmutableOrNull
(),
false
,
NonNullTypesFalseContext
.
Instance
);
}
/// <summary>
...
...
src/Compilers/CSharp/Portable/Symbols/TypeSymbolWithAnnotations.cs
浏览文件 @
2ad93d9a
...
...
@@ -148,6 +148,7 @@ private TypeSymbolWithAnnotations(TypeSymbol defaultType, INonNullTypesContext n
/// </remarks>
internal
static
TypeSymbolWithAnnotations
Create
(
INonNullTypesContext
nonNullTypesContext
,
TypeSymbol
typeSymbol
,
bool
isAnnotated
=
false
,
ImmutableArray
<
CustomModifier
>
customModifiers
=
default
)
{
Debug
.
Assert
(
nonNullTypesContext
!=
null
);
// PROTOTYPE(NullableReferenceTypes): Enable the assert below.
//Debug.Assert((nonNullTypesContext as Symbol)?.IsDefinition != false);
...
...
@@ -159,8 +160,6 @@ internal static TypeSymbolWithAnnotations Create(INonNullTypesContext nonNullTyp
{
isAnnotated
=
true
;
}
// PROTOTYPE(NullableReferenceTypes): this defaulting logic should be removed. There are many paths that currently don't have an explicit context at the moment.
nonNullTypesContext
=
nonNullTypesContext
??
NonNullTypesFalseContext
.
Instance
;
return
CreateNonLazyType
(
typeSymbol
,
nonNullTypesContext
,
isAnnotated
:
isAnnotated
,
treatUnconstrainedTypeParameterAsNullable
:
!
IsIndexedTypeParameter
(
typeSymbol
),
customModifiers
.
NullToEmpty
());
...
...
@@ -1011,7 +1010,7 @@ internal override TypeSymbolWithAnnotations SubstituteType(TypeSymbolWithAnnotat
var
newUnderlying
=
_underlying
.
SubstituteTypeCore
(
typeMap
,
withTupleUnification
);
if
(!
newUnderlying
.
IsSameAs
(
this
.
_underlying
))
{
if
((
newUnderlying
.
TypeSymbol
.
Equals
(
this
.
_underlying
.
TypeSymbol
,
TypeCompareKind
.
AllAspect
s
)
||
if
((
newUnderlying
.
TypeSymbol
.
Equals
(
this
.
_underlying
.
TypeSymbol
,
TypeCompareKind
.
CompareNullableModifiersForReferenceType
s
)
||
newUnderlying
.
TypeSymbol
is
IndexedTypeParameterSymbolForOverriding
)
&&
newUnderlying
.
CustomModifiers
.
IsEmpty
)
{
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
浏览文件 @
2ad93d9a
...
...
@@ -1401,7 +1401,8 @@ class NonNullTypesAttribute : Attribute
comp.VerifyDiagnostics();
}
[Fact(Skip = "PROTOTYPE(NullableReferenceTypes): stack overflow")]
[WorkItem(29594, "https://github.com/dotnet/roslyn/issues/29594")]
[Fact(Skip = "Stack overflow")]
public void NonNullTypes_DoNotWarnInsideAttributes()
{
string source = @"
...
...
@@ -19334,7 +19335,7 @@ static void F3(object? x3, object y3)
z3.ToString();
}
}";
//
PROTOTYPE(NullableReferenceTypes)
: For captured variables, the lambda should be
//
https://github.com/dotnet/roslyn/issues/29617
: For captured variables, the lambda should be
// considered executed at the location the lambda is converted to a delegate.
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
comp.VerifyDiagnostics(
...
...
@@ -19461,7 +19462,7 @@ static void G(object? o)
if (o != null) F(() => { return o; }).ToString();
}
}";
//
PROTOTYPE(NullableReferenceTypes)
: For captured variables, the lambda should be
//
https://github.com/dotnet/roslyn/issues/29617
: For captured variables, the lambda should be
// considered executed at the location the lambda is converted to a delegate.
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
comp.VerifyDiagnostics(
...
...
@@ -19572,7 +19573,7 @@ static void F(I<object> x, I<object?> y)
D<I<object>> b = () => y;
}
}";
//
PROTOTYPE(NullableReferenceTypes)
: For captured variables, the lambda should be
//
https://github.com/dotnet/roslyn/issues/29617
: For captured variables, the lambda should be
// considered executed at the location the lambda is converted to a delegate.
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
comp.VerifyDiagnostics(
...
...
@@ -19642,7 +19643,7 @@ static void G(string x, string? y)
if (y != null) F(() => y).ToString();
}
}";
//
PROTOTYPE(NullableReferenceTypes)
: For captured variables, the lambda should be
//
https://github.com/dotnet/roslyn/issues/29617
: For captured variables, the lambda should be
// considered executed at the location the lambda is converted to a delegate.
var comp = CreateCompilation(
new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition },
...
...
@@ -21827,7 +21828,7 @@ static void M()
}
}";
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
//
PROTOTYPE(NullableReferenceTypes)
: Deconstruction should infer `string?` for `var x`.
//
https://github.com/dotnet/roslyn/issues/29618
: Deconstruction should infer `string?` for `var x`.
comp.VerifyDiagnostics(
// (8,13): warning CS8600: Converting null literal or possible null value to non-nullable type.
// x = null;
...
...
@@ -21854,7 +21855,7 @@ static void G()
}
}";
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
//
PROTOTYPE(NullableReferenceTypes)
: Deconstruction should infer `string?` for `var x`.
//
https://github.com/dotnet/roslyn/issues/29618
: Deconstruction should infer `string?` for `var x`.
comp.VerifyDiagnostics(
// (9,13): warning CS8600: Converting null literal or possible null value to non-nullable type.
// x = null;
...
...
@@ -21885,7 +21886,7 @@ static void M()
}
}";
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
//
PROTOTYPE(NullableReferenceTypes)
: Deconstruction should infer `string?` for `var x`.
//
https://github.com/dotnet/roslyn/issues/29618
: Deconstruction should infer `string?` for `var x`.
comp.VerifyDiagnostics(
// (13,13): warning CS8600: Converting null literal or possible null value to non-nullable type.
// x = null;
...
...
@@ -21942,7 +21943,7 @@ static void G()
}
}";
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
//
PROTOTYPE(NullableReferenceTypes)
: Deconstruction should infer `string?` for `var y`.
//
https://github.com/dotnet/roslyn/issues/29618
: Deconstruction should infer `string?` for `var y`.
comp.VerifyDiagnostics();
//// (11,13): warning CS8602: Possible dereference of a null reference.
//// y.ToString();
...
...
@@ -25557,7 +25558,8 @@ public class C<T> {}
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_01()
{
string lib = @"
...
...
@@ -26592,7 +26594,8 @@ void Test23(CL0.CL1 c, Action x23)
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_07()
{
string moduleAttributes = @"
...
...
@@ -26713,7 +26716,8 @@ void Test23(CL0.CL1 c, Action x23)
c.VerifyDiagnostics();
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_08()
{
string moduleAttributes = @"
...
...
@@ -26832,7 +26836,8 @@ void Test23(CL0.CL1 c, Action x23)
c.VerifyDiagnostics();
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_09()
{
string moduleAttributes = @"
...
...
@@ -26949,7 +26954,8 @@ void Test23(CL0.CL1 c, Action x23)
c.VerifyDiagnostics();
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_10()
{
string moduleAttributes = @"
...
...
@@ -27141,7 +27147,8 @@ void Test23(CL0.CL1 c, Action x23)
c.VerifyDiagnostics(expected);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_11()
{
string moduleAttributes = @"
...
...
@@ -27333,7 +27340,8 @@ void Test23(CL0.CL1 c, Action x23)
c.VerifyDiagnostics(expected);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_12()
{
string moduleAttributes = @"
...
...
@@ -27525,7 +27533,8 @@ void Test23(CL0.CL1 c, Action x23)
c.VerifyDiagnostics(expected);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_13()
{
string source = @"
...
...
@@ -27568,7 +27577,8 @@ void Test2()
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_14()
{
string source = @"
...
...
@@ -27648,7 +27658,8 @@ class CL1<T>
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_15()
{
string source = @"
...
...
@@ -27727,7 +27738,8 @@ class CL6 : CL4<string?>
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_16()
{
string source = @"
...
...
@@ -27794,7 +27806,8 @@ class CL6 : CL4<string?>
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_17()
{
string source = @"
...
...
@@ -27830,7 +27843,8 @@ public static T M1()
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_18()
{
string source = @"
...
...
@@ -27898,7 +27912,8 @@ class CL1<T>
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_19()
{
string source = @"
...
...
@@ -27931,7 +27946,8 @@ class CL0<T>
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_20()
{
string source = @"
...
...
@@ -28008,7 +28024,8 @@ class CL1<T>
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_21()
{
string source = @"
...
...
@@ -28041,7 +28058,8 @@ class CL0<T>
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_22()
{
string source = @"
...
...
@@ -28108,7 +28126,8 @@ void Assign()
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_23()
{
string source = @"
...
...
@@ -28217,7 +28236,8 @@ class CL1<T>
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_24()
{
string source = @"
...
...
@@ -28304,7 +28324,8 @@ void Test6()
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_25()
{
string source = @"
...
...
@@ -28347,7 +28368,8 @@ void Test3()
);
}
[Fact(Skip = "NonNullTypes does not control warnings")] // PROTOTYPE(NullableReferenceTypes): Update or remove test.
[WorkItem(29616, "https://github.com/dotnet/roslyn/issues/29616")]
[Fact(Skip = "NonNullTypes does not control warnings")]
public void NonNullTypes_26()
{
string source = @"
...
...
@@ -30912,7 +30934,7 @@ static T F<T>(IEnumerable<T> e)
/// should not result in a warning at the call site.
/// </summary>
[WorkItem(26626, "https://github.com/dotnet/roslyn/issues/26626")]
[Fact(Skip = "
PROTOTYPE(NullableReferenceTypes): n
ull check on default value temporarily skipped")]
[Fact(Skip = "
N
ull check on default value temporarily skipped")]
public void ParameterDefaultValue_FromMetadata()
{
var source0 =
...
...
@@ -30951,7 +30973,7 @@ static void Main()
}
[WorkItem(26626, "https://github.com/dotnet/roslyn/issues/26626")]
[Fact(Skip = "
PROTOTYPE(NullableReferenceTypes): n
ull check on default value temporarily skipped")]
[Fact(Skip = "
N
ull check on default value temporarily skipped")]
public void ParameterDefaultValue_01()
{
var source =
...
...
@@ -31045,7 +31067,7 @@ static void M()
}
[WorkItem(26626, "https://github.com/dotnet/roslyn/issues/26626")]
[Fact(Skip = "
PROTOTYPE(NullableReferenceTypes): n
ull check on default value temporarily skipped")]
[Fact(Skip = "
N
ull check on default value temporarily skipped")]
public void ParameterDefaultValue_03()
{
var source =
...
...
@@ -31354,7 +31376,7 @@ void M()
}
[WorkItem(26626, "https://github.com/dotnet/roslyn/issues/26626")]
[Fact(Skip = "
PROTOTYPE(NullableReferenceTypes): n
ull check on default value temporarily skipped")]
[Fact(Skip = "
N
ull check on default value temporarily skipped")]
public void ParameterDefaultValue_04()
{
var source =
...
...
@@ -34718,10 +34740,9 @@ public class B
comp0.VerifyDiagnostics();
var ref0 = comp0.EmitToImageReference();
//
PROTOTYPE(NullableReferenceTypes)
: The result of type inference with null-oblivious
//
https://github.com/dotnet/roslyn/issues/27961
: The result of type inference with null-oblivious
// depends on the order possible type arguments are considered. For instance,
// the type inferred for F(x, z) is A? and the type inferred for F(z, x) is A.
// See https://github.com/dotnet/roslyn/issues/27961.
var source =
@"class C
{
...
...
@@ -35921,7 +35942,7 @@ static void F()
Diagnostic(ErrorCode.WRN_ConvertingNullableToNonNullable, "b.A.F").WithLocation(26, 13));
}
//
PROTOTYPE(NullableReferenceTypes)
: Handle struct properties that are not auto-properties.
//
https://github.com/dotnet/roslyn/issues/29619
: Handle struct properties that are not auto-properties.
[Fact(Skip = "Struct property not auto-property")]
public void ModifyMembers_StructPropertyExplicitAccessors()
{
...
...
@@ -36031,7 +36052,7 @@ void M()
Diagnostic(ErrorCode.WRN_ConvertingNullableToNonNullable, "P").WithLocation(8, 13));
}
//
PROTOTYPE(NullableReferenceTypes)
: Handle struct properties that are not auto-properties.
//
https://github.com/dotnet/roslyn/issues/29619
: Handle struct properties that are not auto-properties.
[Fact(Skip = "Struct property not auto-property")]
public void ModifyMembers_StructPropertyNoBackingField()
{
...
...
@@ -36524,7 +36545,7 @@ static void Main()
}
// Valid struct since the property is not backed by a field.
//
PROTOTYPE(NullableReferenceTypes)
: Handle struct properties that are not auto-properties.
//
https://github.com/dotnet/roslyn/issues/29619
: Handle struct properties that are not auto-properties.
[Fact(Skip = "Struct property not auto-property")]
public void Members_PropertyCycle_Struct()
{
src/Compilers/CSharp/Test/Semantic/Semantics/OperatorTests.cs
浏览文件 @
2ad93d9a
...
...
@@ -6448,7 +6448,7 @@ bool Test(S1? s1)
comp
.
VerifyDiagnostics
();
var
expectedOperator
=
comp
.
GlobalNamespace
.
GetMember
<
NamedTypeSymbol
>(
"S1"
).
GetMembers
(
WellKnownMemberNames
.
EqualityOperatorName
).
OfType
<
MethodSymbol
>().
Single
(
m
=>
m
.
ParameterTypes
[
0
].
Equals
(
m
.
ParameterTypes
[
1
],
TypeCompareKind
.
AllAspect
s
));
OfType
<
MethodSymbol
>().
Single
(
m
=>
m
.
ParameterTypes
[
0
].
Equals
(
m
.
ParameterTypes
[
1
],
TypeCompareKind
.
CompareNullableModifiersForReferenceType
s
));
var
tree
=
comp
.
SyntaxTrees
.
Single
();
var
model
=
comp
.
GetSemanticModel
(
tree
);
...
...
src/Compilers/CSharp/Test/Symbol/Symbols/TypeTests.cs
浏览文件 @
2ad93d9a
...
...
@@ -13,9 +13,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols
{
public
class
TypeTests
:
CSharpTestBase
{
// PROTOTYPE(NullableReferenceTypes): StackOverflowException in
// SetUnknownNullabilityForReferenceTypes.
[
Fact
(
Skip
=
"TODO"
)]
[
Fact
]
public
void
Bug18280
()
{
string
brackets
=
"[][][][][][][][][][][][][][][][][][][][]"
;
...
...
@@ -37,6 +35,8 @@ public void Bug18280()
var
arr
=
x
.
Type
.
TypeSymbol
;
arr
.
GetHashCode
();
// PROTOTYPE(NullableReferenceTypes): StackOverflowException in SetUnknownNullabilityForReferenceTypes.
//arr.SetUnknownNullabilityForReferenceTypes();
}
[
Fact
]
...
...
src/Compilers/Core/Portable/SymbolDisplay/SymbolDisplayMiscellaneousOptions.cs
浏览文件 @
2ad93d9a
...
...
@@ -58,7 +58,7 @@ public enum SymbolDisplayMiscellaneousOptions
/// <summary>
/// Append '?' to nullable reference types.
///
PROTOTYPE(NullableReferenceTypes): review design for this option before shipping. See https://github.com/dotnet/roslyn/issues/26198
///
(Review design for this option before shipping. See https://github.com/dotnet/roslyn/issues/26198)
/// </summary>
IncludeNullableReferenceTypeModifier
=
1
<<
6
,
}
...
...
src/Compilers/Core/Portable/Symbols/TypeCompareKind.cs
浏览文件 @
2ad93d9a
...
...
@@ -27,7 +27,6 @@ internal enum TypeCompareKind
/// Has no impact without CompareNullableModifiersForReferenceTypes.
/// </summary>
UnknownNullableModifierMatchesAny
=
16
,
AllAspects
=
CompareNullableModifiersForReferenceTypes
,
// PROTOTYPE(NullableReferenceTypes): Remove if not used.
AllIgnoreOptions
=
IgnoreCustomModifiersAndArraySizesAndLowerBounds
|
IgnoreDynamic
|
IgnoreTupleNames
,
AllIgnoreOptionsForVB
=
IgnoreCustomModifiersAndArraySizesAndLowerBounds
|
IgnoreTupleNames
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录