@@ -986,22 +986,29 @@ module Util =
986986 let enumerator = CallExpression( get None ( Identifier " this" ) " GetEnumerator" , [||]) :> Expression
987987 BlockStatement [| ReturnStatement( libCall com ctx None " Seq" " toIterator" [| enumerator|])|]
988988
989- let extractBaseExprFromBaseCall com ctx baseCall =
990- let baseRef , args , hasSpread =
991- match baseCall with
992- | Fable.Call( baseRef, info, _, _) ->
993- baseRef, info.Args, info.HasSpread
994- | _ ->
995- " Unexpected base call expression, please report"
996- |> addError com [] baseCall.Range
997- Fable.Value( Fable.UnitConstant, None), [], false
998-
999- let baseExpr =
1000- match baseRef with
1001- | Fable.IdentExpr id -> typedIdent com ctx id :> Expression
1002- | _ -> transformAsExpr com ctx baseRef
1003- let args = transformCallArgs com ctx hasSpread args
1004- baseExpr, args
989+ let extractBaseExprFromBaseCall ( com : IBabelCompiler ) ctx ( baseType : Fable.DeclaredType option ) baseCall =
990+ match baseCall, baseType with
991+ | Some ( Fable.Call( baseRef, info, _, _)), _ ->
992+ let baseExpr =
993+ match baseRef with
994+ | Fable.IdentExpr id -> typedIdent com ctx id :> Expression
995+ | _ -> transformAsExpr com ctx baseRef
996+ let args = transformCallArgs com ctx info.HasSpread info.Args
997+ Some ( baseExpr, args)
998+ | Some ( Fable.Value _), Some baseType ->
999+ // let baseEnt = com.GetEntity(baseType.Entity)
1000+ // let entityName = FSharp2Fable.Helpers.getEntityDeclarationName com baseType.Entity
1001+ // let entityType = FSharp2Fable.Util.getEntityType baseEnt
1002+ // let baseRefId = makeTypedIdent entityType entityName
1003+ // let baseExpr = (baseRefId |> typedIdent com ctx) :> Expression
1004+ // Some (baseExpr, []) // default base constructor
1005+ None // ignore some base constructor calls
1006+ | Some _, _ ->
1007+ let range = baseCall |> Option.bind ( fun x -> x.Range)
1008+ " Unexpected base call expression, please report" |> addError com [] range
1009+ None
1010+ | None, _ ->
1011+ None
10051012
10061013 let transformObjectExpr ( com : IBabelCompiler ) ctx ( members : Fable.MemberDecl list ) baseCall : Expression =
10071014 let compileAsClass =
@@ -1058,7 +1065,7 @@ module Util =
10581065
10591066 let baseExpr , classMembers =
10601067 baseCall
1061- |> Option.map ( extractBaseExprFromBaseCall com ctx)
1068+ |> extractBaseExprFromBaseCall com ctx None
10621069 |> Option.map ( fun ( baseExpr , baseArgs ) ->
10631070 let consBody = BlockStatement [| callSuperAsStatement baseArgs|]
10641071 let cons = makeClassConstructor [||] consBody
@@ -1964,7 +1971,7 @@ module Util =
19641971
19651972 let baseExpr , consBody =
19661973 classDecl.BaseCall
1967- |> Option.map ( extractBaseExprFromBaseCall com ctx)
1974+ |> extractBaseExprFromBaseCall com ctx classEnt.BaseType
19681975 |> Option.orElseWith ( fun () ->
19691976 if classEnt.IsValueType then Some( libValue com ctx " Types" " Record" , [])
19701977 else None)
0 commit comments