@@ -219,8 +219,11 @@ let rec remapTypeAux (tyenv: Remap) (ty: TType) =
219
219
if domainTy === domainTyR && rangeTy === retTyR then ty else
220
220
TType_fun (domainTyR, retTyR, flags)
221
221
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
224
227
TType_forall (tpsR, remapTypeAux tyenv ty)
225
228
226
229
| TType_measure unt ->
@@ -328,16 +331,12 @@ and copyAndRemapAndBindTyparsFull remapAttrib tyenv tps =
328
331
match tps with
329
332
| [] -> tps, tyenv
330
333
| _ ->
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
341
340
342
341
// copies bound typars, extends tpinst
343
342
and copyAndRemapAndBindTypars tyenv tps =
@@ -389,13 +388,16 @@ let remapTypes tyenv x =
389
388
/// We currently break the recursion by passing in remapAttribImpl as a function parameter.
390
389
/// Use this one for any type that may be a forall type where the type variables may contain attributes
391
390
let 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
399
401
400
402
let remapParam tyenv (TSlotParam(nm, ty, fl1, fl2, fl3, attribs) as x) =
401
403
if isRemapEmpty tyenv then x else
@@ -404,7 +406,11 @@ let remapParam tyenv (TSlotParam(nm, ty, fl1, fl2, fl3, attribs) as x) =
404
406
let remapSlotSig remapAttrib tyenv (TSlotSig(nm, ty, ctps, methTypars, paraml, retTy) as x) =
405
407
if isRemapEmpty tyenv then x else
406
408
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
+
408
414
let methTyparsR, tyenvinner = copyAndRemapAndBindTyparsFull remapAttrib tyenvinner methTypars
409
415
TSlotSig(nm, tyR, ctpsR, methTyparsR, List.mapSquared (remapParam tyenvinner) paraml, Option.map (remapTypeAux tyenvinner) retTy)
410
416
@@ -5869,10 +5875,14 @@ let remapAttribKind tmenv k =
5869
5875
| ILAttrib _ as x -> x
5870
5876
| FSAttrib vref -> FSAttrib(remapValRef tmenv vref)
5871
5877
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
5876
5886
5877
5887
type RemapContext =
5878
5888
{ g: TcGlobals
@@ -6083,7 +6093,10 @@ and remapOpExpr (ctxt: RemapContext) (compgen: ValCopyFlag) (tmenv: Remap) (op,
6083
6093
6084
6094
and remapAppExpr (ctxt: RemapContext) (compgen: ValCopyFlag) (tmenv: Remap) (e1, e1ty, tyargs, args, m) origExpr =
6085
6095
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
6087
6100
let tyargsR = remapTypes tmenv tyargs
6088
6101
let argsR = remapExprs ctxt compgen tmenv args
6089
6102
if e1 === e1R && e1ty === e1tyR && tyargs === tyargsR && args === argsR then origExpr
@@ -6333,55 +6346,60 @@ and copyTycon compgen (tycon: Tycon) =
6333
6346
| _ -> Construct.NewClonedTycon tycon
6334
6347
6335
6348
/// 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
+
6337
6351
let tyconsR = tycons |> List.map (copyTycon compgen)
6338
6352
6339
6353
let tmenvinner = bindTycons tycons tyconsR tmenv
6340
-
6354
+
6341
6355
// Values need to be copied and renamed.
6342
6356
let vsR, tmenvinner = copyAndRemapAndBindVals ctxt compgen tmenvinner vs
6343
6357
6344
6358
// "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 ->
6353
6367
errorR(InternalError(sprintf "couldn't remap internal value '%s'" v.LogicalName, v.Range))
6354
6368
mkLocalValRef v
6355
6369
vref.Deref
6356
6370
6357
- let lookupTycon tycon =
6358
- let tcref =
6359
- try
6371
+ let lookupTycon tycon =
6372
+ let tcref =
6373
+ try
6360
6374
let res = tmenvinner.tyconRefRemap[mkLocalTyconRef tycon]
6361
6375
res
6362
- with :? KeyNotFoundException ->
6376
+ with :? KeyNotFoundException ->
6363
6377
errorR(InternalError("couldn't remap internal tycon " + showL(DebugPrint.tyconL tycon), tycon.Range))
6364
6378
mkLocalTyconRef tycon
6365
6379
tcref.Deref
6366
6380
6367
- (tycons, tyconsR) ||> List.iter2 (fun tcd tcdR ->
6381
+ (tycons, tyconsR)
6382
+ ||> List.iter2 (fun tcd tcdR ->
6368
6383
let lookupTycon tycon = lookupTycon tycon
6369
6384
let tpsR, tmenvinner2 = tmenvCopyRemapAndBindTypars (remapAttribs ctxt tmenvinner) tmenvinner (tcd.entity_typars.Force(tcd.entity_range))
6385
+
6370
6386
tcdR.entity_typars <- LazyWithContext.NotLazy tpsR
6371
6387
tcdR.entity_attribs <- tcd.entity_attribs |> remapAttribs ctxt tmenvinner2
6372
6388
tcdR.entity_tycon_repr <- tcd.entity_tycon_repr |> remapTyconRepr ctxt tmenvinner2
6389
+
6373
6390
let typeAbbrevR = tcd.TypeAbbrev |> Option.map (remapType tmenvinner2)
6391
+
6374
6392
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
+
6377
6395
let exnInfoR = tcd.ExceptionInfo |> remapTyconExnInfo ctxt tmenvinner2
6378
6396
match tcdR.entity_opt_data with
6379
6397
| Some optData -> tcdR.entity_opt_data <- Some { optData with entity_tycon_abbrev = typeAbbrevR; entity_exn_info = exnInfoR }
6380
- | _ ->
6398
+ | _ ->
6381
6399
tcdR.SetTypeAbbrev typeAbbrevR
6382
6400
tcdR.SetExceptionInfo exnInfoR)
6383
- tyconsR, vsR, tmenvinner
6384
6401
6402
+ tyconsR, vsR, tmenvinner
6385
6403
6386
6404
and allTyconsOfTycon (tycon: Tycon) =
6387
6405
seq { yield tycon
0 commit comments