Skip to content

Commit 2e3f35c

Browse files
CopilotT-Gro
andcommitted
Fix nullness warning in TryParseFeature by using box before downcast
Changed the null check pattern from matching on union directly to matching on box union. This satisfies the nullness analysis by ensuring the null check happens on the boxed value before downcasting, eliminating the FS3264 nullness warning. Fixes build error reported in comment 3675368950. Co-authored-by: T-Gro <[email protected]>
1 parent 9da0e1b commit 2e3f35c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Compiler/Facilities/LanguageFeatures.fs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,9 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array)
443443
|> Option.bind (fun case ->
444444
let union = Microsoft.FSharp.Reflection.FSharpValue.MakeUnion(case, [||])
445445

446-
if isNull union then
447-
None
448-
else
449-
Some(union :?> LanguageFeature))
446+
match box union with
447+
| null -> None
448+
| obj -> Some(obj :?> LanguageFeature))
450449

451450
override x.Equals(yobj: obj) =
452451
match yobj with

0 commit comments

Comments
 (0)