@@ -219,8 +219,11 @@ let rec remapTypeAux (tyenv: Remap) (ty: TType) =
219219 if domainTy === domainTyR && rangeTy === retTyR then ty else
220220 TType_fun (domainTyR, retTyR, flags)
221221
222- | TType_forall (tps, ty) ->
223- let tpsR, tyenv = copyAndRemapAndBindTypars tyenv tps
222+ | TType_forall (tps, ty) ->
223+ let tpsR, tyenv =
224+ match tyenv.realsig with
225+ | false -> copyAndRemapAndBindTypars tyenv tps
226+ | true -> tps, tyenv
224227 TType_forall (tpsR, remapTypeAux tyenv ty)
225228
226229 | TType_measure unt ->
@@ -328,16 +331,12 @@ and copyAndRemapAndBindTyparsFull remapAttrib tyenv tps =
328331 match tps with
329332 | [] -> tps, tyenv
330333 | _ ->
331- match tyenv.realsig with
332- | true ->
333- tps, tyenv
334- | false ->
335- let tpsR = copyTypars false tps
336- let tyenv = { tyenv with tpinst = bindTypars tps (generalizeTypars tpsR) tyenv.tpinst }
337- (tps, tpsR) ||> List.iter2 (fun tporig tp ->
338- tp.SetConstraints (remapTyparConstraintsAux tyenv tporig.Constraints)
339- tp.SetAttribs (tporig.Attribs |> remapAttrib))
340- tpsR, tyenv
334+ let tpsR = copyTypars false tps
335+ let tyenv = { tyenv with tpinst = bindTypars tps (generalizeTypars tpsR) tyenv.tpinst }
336+ (tps, tpsR) ||> List.iter2 (fun tporig tp ->
337+ tp.SetConstraints (remapTyparConstraintsAux tyenv tporig.Constraints)
338+ tp.SetAttribs (tporig.Attribs |> remapAttrib))
339+ tpsR, tyenv
341340
342341// copies bound typars, extends tpinst
343342and copyAndRemapAndBindTypars tyenv tps =
@@ -389,13 +388,16 @@ let remapTypes tyenv x =
389388/// We currently break the recursion by passing in remapAttribImpl as a function parameter.
390389/// Use this one for any type that may be a forall type where the type variables may contain attributes
391390let remapTypeFull remapAttrib tyenv ty =
392- if isRemapEmpty tyenv then ty else
393- match stripTyparEqns ty with
394- | TType_forall(tps, tau) ->
395- let tpsR, tyenvinner = copyAndRemapAndBindTyparsFull remapAttrib tyenv tps
396- TType_forall(tpsR, remapType tyenvinner tau)
397- | _ ->
398- remapType tyenv ty
391+ if isRemapEmpty tyenv then ty
392+ else
393+ match tyenv.realsig, stripTyparEqns ty with
394+ | false, TType_forall(tps, tau) ->
395+ let tpsR, tyenvinner =
396+ match tyenv.realsig with
397+ | false -> copyAndRemapAndBindTyparsFull remapAttrib tyenv tps
398+ | true -> tps, tyenv
399+ TType_forall(tpsR, remapType tyenvinner tau)
400+ | _-> remapType tyenv ty
399401
400402let remapParam tyenv (TSlotParam(nm, ty, fl1, fl2, fl3, attribs) as x) =
401403 if isRemapEmpty tyenv then x else
@@ -404,7 +406,11 @@ let remapParam tyenv (TSlotParam(nm, ty, fl1, fl2, fl3, attribs) as x) =
404406let remapSlotSig remapAttrib tyenv (TSlotSig(nm, ty, ctps, methTypars, paraml, retTy) as x) =
405407 if isRemapEmpty tyenv then x else
406408 let tyR = remapTypeAux tyenv ty
407- let ctpsR, tyenvinner = copyAndRemapAndBindTyparsFull remapAttrib tyenv ctps
409+ let ctpsR, tyenvinner =
410+ match tyenv.realsig with
411+ | false -> copyAndRemapAndBindTyparsFull remapAttrib tyenv ctps
412+ | true -> ctps, tyenv
413+
408414 let methTyparsR, tyenvinner = copyAndRemapAndBindTyparsFull remapAttrib tyenvinner methTypars
409415 TSlotSig(nm, tyR, ctpsR, methTyparsR, List.mapSquared (remapParam tyenvinner) paraml, Option.map (remapTypeAux tyenvinner) retTy)
410416
@@ -5869,10 +5875,14 @@ let remapAttribKind tmenv k =
58695875 | ILAttrib _ as x -> x
58705876 | FSAttrib vref -> FSAttrib(remapValRef tmenv vref)
58715877
5872- let tmenvCopyRemapAndBindTypars remapAttrib tmenv tps =
5873- let tps', tyenvinner = copyAndRemapAndBindTyparsFull remapAttrib tmenv tps
5874- let tmenvinner = tyenvinner
5875- tps', tmenvinner
5878+ let tmenvCopyRemapAndBindTypars remapAttrib tmenv tps =
5879+ match tmenv.realsig with
5880+ | false ->
5881+ let tps', tyenvinner = copyAndRemapAndBindTyparsFull remapAttrib tmenv tps
5882+ let tmenvinner = tyenvinner
5883+ tps', tmenvinner
5884+ | true ->
5885+ tps, tmenv
58765886
58775887type RemapContext =
58785888 { g: TcGlobals
@@ -6083,7 +6093,10 @@ and remapOpExpr (ctxt: RemapContext) (compgen: ValCopyFlag) (tmenv: Remap) (op,
60836093
60846094and remapAppExpr (ctxt: RemapContext) (compgen: ValCopyFlag) (tmenv: Remap) (e1, e1ty, tyargs, args, m) origExpr =
60856095 let e1R = remapExprImpl ctxt compgen tmenv e1
6086- let e1tyR = remapPossibleForallTyImpl ctxt tmenv e1ty
6096+ let e1tyR =
6097+ match tmenv.realsig with
6098+ | false -> remapPossibleForallTyImpl ctxt tmenv e1ty
6099+ | true -> e1ty
60876100 let tyargsR = remapTypes tmenv tyargs
60886101 let argsR = remapExprs ctxt compgen tmenv args
60896102 if e1 === e1R && e1ty === e1tyR && tyargs === tyargsR && args === argsR then origExpr
@@ -6333,55 +6346,60 @@ and copyTycon compgen (tycon: Tycon) =
63336346 | _ -> Construct.NewClonedTycon tycon
63346347
63356348/// This operates over a whole nested collection of tycons and vals simultaneously *)
6336- and copyAndRemapAndBindTyconsAndVals ctxt compgen tmenv tycons vs =
6349+ and copyAndRemapAndBindTyconsAndVals ctxt compgen tmenv tycons vs =
6350+
63376351 let tyconsR = tycons |> List.map (copyTycon compgen)
63386352
63396353 let tmenvinner = bindTycons tycons tyconsR tmenv
6340-
6354+
63416355 // Values need to be copied and renamed.
63426356 let vsR, tmenvinner = copyAndRemapAndBindVals ctxt compgen tmenvinner vs
63436357
63446358 // "if a type constructor is hidden then all its inner values and inner type constructors must also be hidden"
6345- // Hence we can just lookup the inner tycon/value mappings in the tables.
6346-
6347- let lookupVal (v: Val) =
6348- let vref =
6349- try
6350- let res = tmenvinner.valRemap[v]
6351- res
6352- with :? KeyNotFoundException ->
6359+ // Hence we can just lookup the inner tycon/value mappings in the tables.
6360+
6361+ let lookupVal (v: Val) =
6362+ let vref =
6363+ try
6364+ let res = tmenvinner.valRemap[v]
6365+ res
6366+ with :? KeyNotFoundException ->
63536367 errorR(InternalError(sprintf "couldn't remap internal value '%s'" v.LogicalName, v.Range))
63546368 mkLocalValRef v
63556369 vref.Deref
63566370
6357- let lookupTycon tycon =
6358- let tcref =
6359- try
6371+ let lookupTycon tycon =
6372+ let tcref =
6373+ try
63606374 let res = tmenvinner.tyconRefRemap[mkLocalTyconRef tycon]
63616375 res
6362- with :? KeyNotFoundException ->
6376+ with :? KeyNotFoundException ->
63636377 errorR(InternalError("couldn't remap internal tycon " + showL(DebugPrint.tyconL tycon), tycon.Range))
63646378 mkLocalTyconRef tycon
63656379 tcref.Deref
63666380
6367- (tycons, tyconsR) ||> List.iter2 (fun tcd tcdR ->
6381+ (tycons, tyconsR)
6382+ ||> List.iter2 (fun tcd tcdR ->
63686383 let lookupTycon tycon = lookupTycon tycon
63696384 let tpsR, tmenvinner2 = tmenvCopyRemapAndBindTypars (remapAttribs ctxt tmenvinner) tmenvinner (tcd.entity_typars.Force(tcd.entity_range))
6385+
63706386 tcdR.entity_typars <- LazyWithContext.NotLazy tpsR
63716387 tcdR.entity_attribs <- tcd.entity_attribs |> remapAttribs ctxt tmenvinner2
63726388 tcdR.entity_tycon_repr <- tcd.entity_tycon_repr |> remapTyconRepr ctxt tmenvinner2
6389+
63736390 let typeAbbrevR = tcd.TypeAbbrev |> Option.map (remapType tmenvinner2)
6391+
63746392 tcdR.entity_tycon_tcaug <- tcd.entity_tycon_tcaug |> remapTyconAug tmenvinner2
6375- tcdR.entity_modul_type <- MaybeLazy.Strict (tcd.entity_modul_type.Value
6376- |> mapImmediateValsAndTycons lookupTycon lookupVal)
6393+ tcdR.entity_modul_type <- MaybeLazy.Strict (tcd.entity_modul_type.Value |> mapImmediateValsAndTycons lookupTycon lookupVal)
6394+
63776395 let exnInfoR = tcd.ExceptionInfo |> remapTyconExnInfo ctxt tmenvinner2
63786396 match tcdR.entity_opt_data with
63796397 | Some optData -> tcdR.entity_opt_data <- Some { optData with entity_tycon_abbrev = typeAbbrevR; entity_exn_info = exnInfoR }
6380- | _ ->
6398+ | _ ->
63816399 tcdR.SetTypeAbbrev typeAbbrevR
63826400 tcdR.SetExceptionInfo exnInfoR)
6383- tyconsR, vsR, tmenvinner
63846401
6402+ tyconsR, vsR, tmenvinner
63856403
63866404and allTyconsOfTycon (tycon: Tycon) =
63876405 seq { yield tycon
0 commit comments