You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix NRE when accessing nullable fields of types within their equals/hash/compare methods ([PR #18296](https://github.com/dotnet/fsharp/pull/18296))
14
14
* Fix nullness warning for overrides of generic code with nullable type instance ([Issue #17988](https://github.com/dotnet/fsharp/issues/17988), [PR #18337](https://github.com/dotnet/fsharp/pull/18337))
15
+
* Unsafe downcast from `obj` to generic `T` no longer requires `not null` constraint on `T`([Issue #18275](https://github.com/dotnet/fsharp/issues/18275), [PR #18343](https://github.com/dotnet/fsharp/pull/18343))
15
16
16
17
### Added
17
18
* Added missing type constraints in FCS. ([PR #18241](https://github.com/dotnet/fsharp/pull/18241))
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Language/Nullness/NullableReferenceTypesTests.fs
+14-2Lines changed: 14 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -150,10 +150,8 @@ let doNotWarnOnDowncastRepeatedNestedNullable(o:objnull) = o :? list<((AB | null
150
150
|> shouldFail
151
151
|> withDiagnostics
152
152
[ Error 3264, Line 4, Col 39, Line 4, Col 47,"Nullness warning: Downcasting from 'objnull' into 'AB' can introduce unexpected null values. Cast to 'AB|null' instead or handle the null before downcasting."
153
-
Error 3261, Line 5, Col 42, Line 5, Col 59,"Nullness warning: The types 'obj' and 'AB | null' do not have compatible nullability."
154
153
Error 3060, Line 5, Col 42, Line 5, Col 59,"This type test or downcast will erase the provided type 'AB | null' to the type 'AB'"
155
154
Error 3060, Line 6, Col 41, Line 6, Col 55,"This type test or downcast will erase the provided type 'AB | null' to the type 'AB'"
156
-
Error 3261, Line 7, Col 51, Line 7, Col 97,"Nullness warning: The types 'obj' and 'AB | null array | null list | null' do not have compatible nullability."
157
155
Error 3060, Line 7, Col 51, Line 7, Col 97,"This type test or downcast will erase the provided type 'List<AB | null array | null> | null' to the type 'List<AB array>'"]
158
156
159
157
@@ -1381,6 +1379,20 @@ dict["ok"] <- 42
1381
1379
|> typeCheckWithStrictNullness
1382
1380
|> shouldSucceed
1383
1381
1382
+
[<InlineData("t :?> 'T")>]
1383
+
[<InlineData("(downcast t) : 'T")>]
1384
+
[<InlineData("t |> unbox<'T>")>]
1385
+
[<InlineData("(t : objnull) :?> 'T")>]
1386
+
[<Theory>]
1387
+
let``Unsafe cast should not insist on not null constraint``(castOp:string)=
0 commit comments