Skip to content

Commit

Permalink
Proof of concept
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed May 24, 2023
1 parent 635d723 commit d99b563
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/Compiler/Checking/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,22 @@ module internal PrintUtilities =
else
path |> List.map (fun s ->
let i = s.IndexOf(',')
if i <> -1 then s.Substring(0, i)+"<...>" // apparently has static params, shorten
else s)
if i <> -1 then
s.Substring(0, i)+"<...>" // apparently has static params, shorten
else
// Verify the name does not end in `1
let tickIdx = s.LastIndexOf("`")
if tickIdx = -1 && tickIdx < s.Length - 1 then
s
else

match Int32.TryParse(s.Substring(tickIdx + 1)) with
| false, _ -> s
| true, idx ->
match List.tryItem (idx - 1) tcref.TyparsNoRange with
| None -> s
| Some typar -> String.Concat(s.Substring(0, tickIdx), "<'", typar.typar_id.idText, ">")
)
let pathText = trimPathByDisplayEnv denv path
if pathText = "" then tyconTextL else leftL (tagUnknownEntity pathText) ^^ tyconTextL

Expand Down Expand Up @@ -900,7 +914,12 @@ module PrintTypes =
| TType_ucase (UnionCaseRef(tc, _), args)
| TType_app (tc, args, _) ->
let prefix = usePrefix denv tc
layoutTypeAppWithInfoAndPrec denv env (layoutTyconRef denv tc) prec prefix args
let partsWithTick = tc.CompilationPath.DemangledPath |> List.sumBy (fun p -> if p.Contains("`") then 1 else 0)
// Very specific check for types like System.Collections.Immutable.ImmutableArray<'T>.Builder
if partsWithTick = args.Length then
layoutTypeAppWithInfoAndPrec denv env (layoutTyconRef denv tc) prec prefix []
else
layoutTypeAppWithInfoAndPrec denv env (layoutTyconRef denv tc) prec prefix args

// Layout a tuple type
| TType_anon (anonInfo, tys) ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
open System.Collections.Immutable

type ImmutableArrayViaBuilder<'T>(builder: ImmutableArray<'T>.Builder) = class end

0 comments on commit d99b563

Please sign in to comment.