Skip to content

Commit 00a591c

Browse files
authored
Nullness - include in QuickInfo and in general in "typeEnc" (string representation of a type) (#16555)
* failing test * todo for IL import * explanation added * il meta parsing * flags evaluation * you shall passs * evaluateFirstOrderNullnessAndAdvance * import il type with nullness * type import * IL nullness import fields, props, events, method args, method return types - nullness imported from IL * test rename * fantomas * get stack trace on error * split ilmethod's type * fix crashes for Csharp style extensions * solve coexistance of nullness and Is* properties of DUs * updating tests * clean tests * fantomas * fantomas one more time * importing nullness for generic typars * print failing ivals, let's see * write even more! * isolated failing test - combo of module rec, signature file, IVT * another attempt * format * test * hide tests * Remove 'specialname' for DU case tester * format * warning as error * update baseline netcore * nullable errors not in desktop framework * surface area, trimming * surface area * cosmetic cleanup & annotations * Rename to ILMethParentTypeInfo * making vMapFold tail recursive * physical nullnessEquiv * format * Commenting SkipNullness usages * Nullness work - activity module * Remove strict generic 'T:null' import * Null|NonNull pattern also for regular compilation * Backported Null|NonNull active pattern * one more time * revert * Show nullness in quickinfo and in general in type representations
1 parent d697c63 commit 00a591c

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/Compiler/Symbols/SymbolHelpers.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ module internal SymbolHelpers =
546546
let SimplerDisplayEnv denv =
547547
{ denv with shortConstraints=true
548548
showStaticallyResolvedTyparAnnotations=false
549-
showNullnessAnnotations = Some false
549+
showNullnessAnnotations = Some true
550550
abbreviateAdditionalConstraints=false
551551
suppressNestedTypes=true
552552
maxMembers=Some EnvMisc2.maxMembers }

src/Compiler/TypedTree/TypedTree.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4227,6 +4227,8 @@ type Nullness =
42274227

42284228
override n.ToString() = match n.Evaluate() with NullnessInfo.WithNull -> "?" | NullnessInfo.WithoutNull -> "" | NullnessInfo.AmbivalentToNull -> "%"
42294229

4230+
member n.ToFsharpCodeString() = match n.Evaluate() with NullnessInfo.WithNull -> " | null " | NullnessInfo.WithoutNull -> "" | NullnessInfo.AmbivalentToNull -> ""
4231+
42304232
// Note, nullness variables are only created if the nullness checking feature is on
42314233
[<NoComparison;NoEquality>]
42324234
type NullnessVar() =

src/Compiler/TypedTree/TypedTree.fsi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3043,6 +3043,8 @@ type Nullness =
30433043
30443044
member TryEvaluate: unit -> NullnessInfo voption
30453045
3046+
member ToFsharpCodeString: unit -> string
3047+
30463048
[<NoComparison; NoEquality>]
30473049
type NullnessVar =
30483050
new: unit -> NullnessVar

src/Compiler/TypedTree/TypedTreeOps.fs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8776,26 +8776,26 @@ let rec typeEnc g (gtpsType, gtpsMethod) ty =
87768776
let ety = destNativePtrTy g ty
87778777
typeEnc g (gtpsType, gtpsMethod) ety + "*"
87788778

8779-
| _ when isArrayTy g ty ->
8780-
let tcref, tinst = destAppTy g ty
8779+
| TType_app (_, _, nullness) when isArrayTy g ty ->
8780+
let tcref, tinst = destAppTy g ty
87818781
let rank = rankOfArrayTyconRef g tcref
87828782
let arraySuffix = "[" + String.concat ", " (List.replicate (rank-1) "0:") + "]"
8783-
typeEnc g (gtpsType, gtpsMethod) (List.head tinst) + arraySuffix
8783+
typeEnc g (gtpsType, gtpsMethod) (List.head tinst) + arraySuffix + nullness.ToFsharpCodeString()
87848784

87858785
| TType_ucase (_, tinst)
87868786
| TType_app (_, tinst, _) ->
8787-
let tyName =
8787+
let tyName,nullness =
87888788
let ty = stripTyEqnsAndMeasureEqns g ty
87898789
match ty with
8790-
| TType_app (tcref, _tinst, _) ->
8790+
| TType_app (tcref, _tinst, nullness) ->
87918791
// Generic type names are (name + "`" + digits) where name does not contain "`".
87928792
// In XML doc, when used in type instances, these do not use the ticks.
87938793
let path = Array.toList (fullMangledPathToTyconRef tcref) @ [tcref.CompiledName]
8794-
textOfPath (List.map DemangleGenericTypeName path)
8794+
textOfPath (List.map DemangleGenericTypeName path),nullness
87958795
| _ ->
87968796
assert false
87978797
failwith "impossible"
8798-
tyName + tyargsEnc g (gtpsType, gtpsMethod) tinst
8798+
tyName + tyargsEnc g (gtpsType, gtpsMethod) tinst + nullness.ToFsharpCodeString()
87998799

88008800
| TType_anon (anonInfo, tinst) ->
88018801
sprintf "%s%s" anonInfo.ILTypeRef.FullName (tyargsEnc g (gtpsType, gtpsMethod) tinst)
@@ -8806,11 +8806,11 @@ let rec typeEnc g (gtpsType, gtpsMethod) ty =
88068806
else
88078807
sprintf "System.Tuple%s"(tyargsEnc g (gtpsType, gtpsMethod) tys)
88088808

8809-
| TType_fun (domainTy, rangeTy, _) ->
8810-
"Microsoft.FSharp.Core.FSharpFunc" + tyargsEnc g (gtpsType, gtpsMethod) [domainTy; rangeTy]
8809+
| TType_fun (domainTy, rangeTy, nullness) ->
8810+
"Microsoft.FSharp.Core.FSharpFunc" + tyargsEnc g (gtpsType, gtpsMethod) [domainTy; rangeTy] + nullness.ToFsharpCodeString()
88118811

8812-
| TType_var (typar, _) ->
8813-
typarEnc g (gtpsType, gtpsMethod) typar
8812+
| TType_var (typar, nullness) ->
8813+
typarEnc g (gtpsType, gtpsMethod) typar + nullness.ToFsharpCodeString()
88148814

88158815
| TType_measure _ -> "?"
88168816

@@ -8822,7 +8822,7 @@ and tyargsEnc g (gtpsType, gtpsMethod) args =
88228822

88238823
let XmlDocArgsEnc g (gtpsType, gtpsMethod) argTys =
88248824
if isNil argTys then ""
8825-
else "(" + String.concat "," (List.map (typeEnc g (gtpsType, gtpsMethod)) argTys) + ")"
8825+
else "(" + String.concat "," (List.map (typeEnc g (gtpsType, gtpsMethod)) argTys) + ")"
88268826

88278827
let buildAccessPath (cp: CompilationPath option) =
88288828
match cp with

0 commit comments

Comments
 (0)