diff --git a/src/fsharp/tc.fs b/src/fsharp/tc.fs index 82ed0352cb0..ba88da92f3b 100644 --- a/src/fsharp/tc.fs +++ b/src/fsharp/tc.fs @@ -13982,7 +13982,7 @@ module EstablishTypeDefinitionCores = begin let hasCLIMutable = HasFSharpAttribute cenv.g cenv.g.attrib_CLIMutableAttribute attrs let hasStructLayoutAttr = HasFSharpAttribute cenv.g cenv.g.attrib_StructLayoutAttribute attrs - let hasAllowNullLiteralAttr = HasFSharpAttribute cenv.g cenv.g.attrib_AllowNullLiteralAttribute attrs + let hasAllowNullLiteralAttr = TryFindFSharpBoolAttribute cenv.g cenv.g.attrib_AllowNullLiteralAttribute attrs = Some(true) if hasAbstractAttr then tycon.TypeContents.tcaug_abstract <- true diff --git a/tests/fsharp/typecheck/sigs/neg16.bsl b/tests/fsharp/typecheck/sigs/neg16.bsl index a4bfaf80f2f..9a3b64f0066 100644 --- a/tests/fsharp/typecheck/sigs/neg16.bsl +++ b/tests/fsharp/typecheck/sigs/neg16.bsl @@ -88,3 +88,5 @@ neg16.fs(110,16,110,20): typecheck error FS0879: Volatile fields must be marked neg16.fs(113,9,113,11): typecheck error FS0879: Volatile fields must be marked 'mutable' and cannot be thread-static neg16.fs(116,9,116,13): typecheck error FS0879: Volatile fields must be marked 'mutable' and cannot be thread-static + +neg16.fs(130,10,130,11): typecheck error FS0935: Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal diff --git a/tests/fsharp/typecheck/sigs/neg16.fs b/tests/fsharp/typecheck/sigs/neg16.fs index f43f6e4f28b..2fa1df8fa03 100644 --- a/tests/fsharp/typecheck/sigs/neg16.fs +++ b/tests/fsharp/typecheck/sigs/neg16.fs @@ -122,3 +122,11 @@ module VolatileFieldSanityChecks = begin end +module AllowNullLiteralWithArgumentTest = begin + + type A() = class end + + [] // expect an error here + type B() = inherit A() + +end diff --git a/tests/fsharp/typecheck/sigs/pos16.fs b/tests/fsharp/typecheck/sigs/pos16.fs index 8db563b38fd..becdb981815 100644 --- a/tests/fsharp/typecheck/sigs/pos16.fs +++ b/tests/fsharp/typecheck/sigs/pos16.fs @@ -46,3 +46,10 @@ module UnitOfMeasurePrintfPositiveTests = let _ = sprintf "%g" 1.0M let _ = sprintf "%g" 1.0M let _ = sprintf "%g" 1.0M + +module AllowNullLiteralWithArgumentTest = + + type A() = class end + + [] + type B() = inherit A()