@@ -2667,25 +2667,27 @@ module EstablishTypeDefinitionCores =
26672667
26682668 // We must apply the spread shadowing logic here to get
26692669 // the correct set of field types.
2670- let rec collectTys tys fieldsAndSpreads =
2670+ let rec collectTys tys i fieldsAndSpreads =
26712671 match fieldsAndSpreads with
26722672 | [] ->
26732673 tys
26742674 |> Map.toList
26752675 |> List.collect ( fun ( _ , ( _ , dupes )) -> dupes)
2676+ |> List.sortBy ( fun ( i , _ , _ ) -> i)
2677+ |> List.map ( fun ( _ , tyR , m ) -> tyR, m)
26762678
26772679 | SynFieldOrSpread.Field ( SynField ( idOpt = None)) :: fieldsAndSpreads ->
2678- collectTys tys fieldsAndSpreads
2680+ collectTys tys i fieldsAndSpreads
26792681
26802682 | SynFieldOrSpread.Field ( SynField ( idOpt = Some fieldId; fieldType = ty; range = m)) :: fieldsAndSpreads ->
26812683 let tyR , _ = TcTypeAndRecover cenv NoNewTypars NoCheckCxs ItemOccurrence.UseInType WarnOnIWSAM.Yes env tpenv ty
26822684 let tys =
26832685 tys |> Map.change fieldId.idText ( function
2684- | None -> Some ( LeftwardExplicit, [ tyR, m])
2685- | Some ( LeftwardExplicit, dupes) -> Some ( LeftwardExplicit, ( tyR, m) :: dupes)
2686- | Some ( NoLeftwardExplicit, _ dupes) -> Some ( LeftwardExplicit, [ tyR, m]))
2686+ | None -> Some ( LeftwardExplicit, [ i , tyR, m])
2687+ | Some ( LeftwardExplicit, dupes) -> Some ( LeftwardExplicit, ( i , tyR, m) :: dupes)
2688+ | Some ( NoLeftwardExplicit, _ dupes) -> Some ( LeftwardExplicit, [ i , tyR, m]))
26872689
2688- collectTys tys fieldsAndSpreads
2690+ collectTys tys ( i + 1 ) fieldsAndSpreads
26892691
26902692 | SynFieldOrSpread.Spread ( SynTypeSpread ( ty = ty; range = m)) :: fieldsAndSpreads ->
26912693 let spreadSrcTy , _ = TcTypeAndRecover cenv NoNewTypars NoCheckCxs ItemOccurrence.UseInType WarnOnIWSAM.Yes env tpenv ty
@@ -2702,17 +2704,17 @@ module EstablishTypeDefinitionCores =
27022704 | ValueSome ( anonInfo, tys) -> tys |> List.mapi ( fun i ty -> anonInfo.SortedNames[ i], ty, m)
27032705 | ValueNone -> []
27042706
2705- let tys =
2706- ( tys, fieldsFromSpread)
2707- ||> List.fold ( fun tys ( fieldId , ty , m ) ->
2708- tys |> Map.change fieldId ( function
2709- | None -> Some ( NoLeftwardExplicit, [ ty, m])
2710- | Some ( LeftwardExplicit, _ dupes) -> Some ( LeftwardExplicit, [ ty, m])
2711- | Some ( NoLeftwardExplicit, _ dupes) -> Some ( NoLeftwardExplicit, [ ty, m])))
2707+ let i , tys =
2708+ (( i , tys) , fieldsFromSpread)
2709+ ||> List.fold ( fun ( i , tys ) ( fieldId , ty , m ) ->
2710+ i + 1 , tys |> Map.change fieldId ( function
2711+ | None -> Some ( NoLeftwardExplicit, [ i , ty, m])
2712+ | Some ( LeftwardExplicit, _ dupes) -> Some ( LeftwardExplicit, [ i , ty, m])
2713+ | Some ( NoLeftwardExplicit, _ dupes) -> Some ( NoLeftwardExplicit, [ i , ty, m])))
27122714
2713- collectTys tys fieldsAndSpreads
2715+ collectTys tys i fieldsAndSpreads
27142716
2715- yield ! collectTys Map.empty fieldsAndSpreads
2717+ yield ! collectTys Map.empty 0 fieldsAndSpreads
27162718
27172719 | _ ->
27182720 () ], spreadSrcTys
0 commit comments