From 3f9c5ef8162bc203bd6eb92d0b8b5da0990f2c0f Mon Sep 17 00:00:00 2001 From: Charles Stoner Date: Thu, 5 Jul 2018 10:48:15 -0700 Subject: [PATCH] Ensure TypeSymbolWithAnnotations.IsNullable != null for value type (#28298) --- .../Portable/Symbols/SymbolWithAnnotations.cs | 2 +- .../Test/Semantic/Semantics/StaticNullChecking.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Compilers/CSharp/Portable/Symbols/SymbolWithAnnotations.cs b/src/Compilers/CSharp/Portable/Symbols/SymbolWithAnnotations.cs index b2c208d8eca..5f4a37e3de8 100644 --- a/src/Compilers/CSharp/Portable/Symbols/SymbolWithAnnotations.cs +++ b/src/Compilers/CSharp/Portable/Symbols/SymbolWithAnnotations.cs @@ -566,7 +566,7 @@ public bool ApplyNullableTransforms(ImmutableArray transforms, bool useNon result = result.DoUpdate(newTypeSymbol, result.CustomModifiers); } - //if (!result.IsValueType) // PROTOTYPE(NullableReferenceTypes): this is causing cycle 6 in NullableAttribute_01 + if (!result.IsValueType) { if (isNullable) { diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/StaticNullChecking.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/StaticNullChecking.cs index 6c721754974..8823a860d77 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/StaticNullChecking.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/StaticNullChecking.cs @@ -1863,6 +1863,21 @@ public class Oblivious { } VerifyNonNullTypes(obliviousComp.GetMember("Oblivious"), true); // PROTOTYPE(NullableReferenceTypes): should be false } + [Fact] + public void NonNullTypes_ValueTypeArgument() + { + var source = +@"using System.Runtime.CompilerServices; +[module: NonNullTypes(false)] +class A { } +class B +{ + A P { get; } +}"; + var comp = CreateCompilation(new[] { source, NonNullTypesAttributesDefinition }, parseOptions: TestOptions.Regular8); + comp.VerifyDiagnostics(); + } + [Fact] public void AssignObliviousIntoLocals() { -- GitLab