Skip to content

Commit a25a2be

Browse files
author
dotnet-automerge-bot
authored
Merge pull request #36425 from dotnet/merges/master-to-features/param-nullchecking
Merge master to features/param-nullchecking
2 parents 4cc2600 + 40fbe90 commit a25a2be

38 files changed

+2496
-2634
lines changed

docs/features/nullable-reference-types.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ A `class?` constraint is allowed, which, like class, requires the type argument
289289
[Nullable strawman](https://github.com/dotnet/csharplang/issues/790)
290290
[4/25/18](https://github.com/dotnet/csharplang/blob/master/meetings/2018/LDM-2018-04-25.md)
291291

292-
An explicit `object` (or `System.Object`) constraint is allowed, which requires the type to be non-nullable (value or reference type).
292+
Explicit `object` (or `System.Object`) constraints of any nullability are disallowed. However, type substitution can lead to
293+
`object!` or `object~` constraints to appear among the constraint types, when their nullability is significant by comparison to
294+
other constraints. An `object!` constraint requires the type to be non-nullable (value or reference type).
293295
However, an explicit `object?` constraint is not allowed.
294296
An unconstrained (here it means - no type constraints, and no `class`, `struct`, or `unmanaged` constraints) type parameter is essentially
295297
equivalent to one constrained by `object?` when it is declared in a context where nullable annotations are enabled. If annotations are disabled,

eng/config/PublishData.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,7 @@
2424
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
2525
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
2626
"channels": [ "dev16.1" ],
27-
"vsBranch": "lab/d16.1stg",
28-
"vsMajorVersion": 16
29-
},
30-
"release/dev16.2-preview2-vs-deps": {
31-
"nugetKind": ["Shipping", "NonShipping"],
32-
"version": "3.2.*",
33-
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
34-
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
35-
"channels": [ "dev16.2p2" ],
36-
"vsBranch": "rel/d16.2",
27+
"vsBranch": "rel/d16.1",
3728
"vsMajorVersion": 16
3829
},
3930
"release/dev16.2-preview3-vs-deps": {
@@ -42,7 +33,7 @@
4233
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
4334
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
4435
"channels": [ "dev16.2p3" ],
45-
"vsBranch": "lab/d16.2stg",
36+
"vsBranch": "rel/d16.2",
4637
"vsMajorVersion": 16
4738
},
4839
"master-vs-deps": {

src/Compilers/CSharp/Portable/Binder/Binder_Constraints.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -483,18 +483,6 @@ private static bool IsValidConstraintType(TypeConstraintSyntax syntax, TypeWithA
483483
break;
484484

485485
case SpecialType.System_Object:
486-
if (typeWithAnnotations.NullableAnnotation.IsAnnotated())
487-
{
488-
// "Constraint cannot be special class '{0}'"
489-
Error(diagnostics, ErrorCode.ERR_SpecialTypeAsBound, syntax, typeWithAnnotations);
490-
return false;
491-
}
492-
493-
// "Constraint cannot be special class '{0}'"
494-
Error(diagnostics, ErrorCode.WRN_SpecialTypeAsBound, syntax, typeWithAnnotations);
495-
CheckFeatureAvailability(syntax, MessageID.IDS_FeatureObjectGenericTypeConstraint, diagnostics);
496-
break;
497-
498486
case SpecialType.System_ValueType:
499487
case SpecialType.System_Array:
500488
// "Constraint cannot be special class '{0}'"

src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private NamespaceOrTypeOrAliasSymbolWithAnnotations BindTypeOrAliasOrConstraintK
154154
CheckFeatureAvailability(syntax, MessageID.IDS_FeatureUnmanagedGenericTypeConstraint, diagnostics);
155155
break;
156156
case ConstraintContextualKeyword.NotNull:
157-
CheckFeatureAvailability(identifierSyntax, MessageID.IDS_NotNullGenericTypeConstraint, diagnostics);
157+
CheckFeatureAvailability(identifierSyntax, MessageID.IDS_FeatureNotNullGenericTypeConstraint, diagnostics);
158158
break;
159159
default:
160160
throw ExceptionUtilities.UnexpectedValue(keyword);

src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

Lines changed: 9 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/CSharpResources.resx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5718,9 +5718,6 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
57185718
<data name="WRN_NullabilityMismatchInTypeParameterReferenceTypeConstraint_Title" xml:space="preserve">
57195719
<value>The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'class' constraint.</value>
57205720
</data>
5721-
<data name="IDS_FeatureObjectGenericTypeConstraint" xml:space="preserve">
5722-
<value>object generic type constraint</value>
5723-
</data>
57245721
<data name="ERR_TripleDotNotAllowed" xml:space="preserve">
57255722
<value>Unexpected character sequence '...'</value>
57265723
</data>
@@ -5913,13 +5910,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
59135910
<data name="WRN_NullabilityMismatchInTypeParameterNotNullConstraint_Title" xml:space="preserve">
59145911
<value>The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'notnull' constraint.</value>
59155912
</data>
5916-
<data name="WRN_SpecialTypeAsBound" xml:space="preserve">
5917-
<value>Constraint cannot be special class '{0}'</value>
5918-
</data>
5919-
<data name="WRN_SpecialTypeAsBound_Title" xml:space="preserve">
5920-
<value>Constraint cannot be special class</value>
5921-
</data>
5922-
<data name="IDS_NotNullGenericTypeConstraint" xml:space="preserve">
5913+
<data name="IDS_FeatureNotNullGenericTypeConstraint" xml:space="preserve">
59235914
<value>notnull generic type constraint</value>
59245915
</data>
59255916
<data name="ERR_NeedSpaceBetweenExclamationAndEquals" xml:space="preserve">

src/Compilers/CSharp/Portable/Errors/ErrorCode.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,6 @@ internal enum ErrorCode
17221722
ERR_AbstractEventHasAccessors = 8712,
17231723
ERR_NotNullConstraintMustBeFirst = 8713,
17241724
WRN_NullabilityMismatchInTypeParameterNotNullConstraint = 8714,
1725-
WRN_SpecialTypeAsBound = 8715,
17261725

17271726
ERR_NeedSpaceBetweenExclamationAndEquals = 8716,
17281727
ERR_MustNullCheckInImplementation = 8717,

src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ internal static int GetWarningLevel(ErrorCode code)
411411
case ErrorCode.WRN_UnconsumedEnumeratorCancellationAttributeUsage:
412412
case ErrorCode.WRN_UndecoratedCancellationTokenParameter:
413413
case ErrorCode.WRN_NullabilityMismatchInTypeParameterNotNullConstraint:
414-
case ErrorCode.WRN_SpecialTypeAsBound:
415414
case ErrorCode.WRN_DisallowNullAttributeForbidsMaybeNullAssignment:
416415
return 1;
417416
default:

src/Compilers/CSharp/Portable/Errors/MessageID.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ internal enum MessageID
165165
IDS_FeatureAltInterpolatedVerbatimStrings = MessageBase + 12745,
166166
IDS_FeatureCoalesceAssignmentExpression = MessageBase + 12746,
167167
IDS_FeatureUnconstrainedTypeParameterInNullCoalescingOperator = MessageBase + 12747,
168-
IDS_FeatureObjectGenericTypeConstraint = MessageBase + 12748,
168+
IDS_FeatureNotNullGenericTypeConstraint = MessageBase + 12748,
169169
IDS_FeatureIndexOperator = MessageBase + 12749,
170170
IDS_FeatureRangeOperator = MessageBase + 12750,
171171
IDS_FeatureAsyncStreams = MessageBase + 12751,
@@ -180,7 +180,6 @@ internal enum MessageID
180180
IDS_DefaultInterfaceImplementation = MessageBase + 12760,
181181
IDS_OverrideWithConstraints = MessageBase + 12761,
182182
IDS_FeatureNestedStackalloc = MessageBase + 12762,
183-
IDS_NotNullGenericTypeConstraint = MessageBase + 12763,
184183
}
185184

186185
// Message IDs may refer to strings that need to be localized.
@@ -276,7 +275,6 @@ internal static LanguageVersion RequiredVersion(this MessageID feature)
276275
case MessageID.IDS_FeatureUnconstrainedTypeParameterInNullCoalescingOperator:
277276
case MessageID.IDS_FeatureNullableReferenceTypes: // syntax and semantic check
278277
case MessageID.IDS_FeaturePragmaWarningEnable:
279-
case MessageID.IDS_FeatureObjectGenericTypeConstraint: // semantic check
280278
case MessageID.IDS_FeatureIndexOperator: // semantic check
281279
case MessageID.IDS_FeatureRangeOperator: // semantic check
282280
case MessageID.IDS_FeatureAsyncStreams:
@@ -290,7 +288,7 @@ internal static LanguageVersion RequiredVersion(this MessageID feature)
290288
case MessageID.IDS_DefaultInterfaceImplementation: // semantic check
291289
case MessageID.IDS_OverrideWithConstraints: // semantic check
292290
case MessageID.IDS_FeatureNestedStackalloc: // semantic check
293-
case MessageID.IDS_NotNullGenericTypeConstraint:// semantic check
291+
case MessageID.IDS_FeatureNotNullGenericTypeConstraint:// semantic check
294292
return LanguageVersion.CSharp8;
295293

296294
// C# 7.3 features.

src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)