@@ -986,22 +986,31 @@ 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 : Context ) ( 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+ let range = baseCall |> Option.bind ( fun x -> x.Range)
1006+ sprintf " Ignoring base call for %s " baseType.Entity.FullName |> addWarning com [] range
1007+ None
1008+ | Some _, _ ->
1009+ let range = baseCall |> Option.bind ( fun x -> x.Range)
1010+ " Unexpected base call expression, please report" |> addError com [] range
1011+ None
1012+ | None, _ ->
1013+ None
10051014
10061015 let transformObjectExpr ( com : IBabelCompiler ) ctx ( members : Fable.MemberDecl list ) baseCall : Expression =
10071016 let compileAsClass =
@@ -1058,7 +1067,7 @@ module Util =
10581067
10591068 let baseExpr , classMembers =
10601069 baseCall
1061- |> Option.map ( extractBaseExprFromBaseCall com ctx)
1070+ |> extractBaseExprFromBaseCall com ctx None
10621071 |> Option.map ( fun ( baseExpr , baseArgs ) ->
10631072 let consBody = BlockStatement [| callSuperAsStatement baseArgs|]
10641073 let cons = makeClassConstructor [||] consBody
@@ -1964,7 +1973,7 @@ module Util =
19641973
19651974 let baseExpr , consBody =
19661975 classDecl.BaseCall
1967- |> Option.map ( extractBaseExprFromBaseCall com ctx)
1976+ |> extractBaseExprFromBaseCall com ctx classEnt.BaseType
19681977 |> Option.orElseWith ( fun () ->
19691978 if classEnt.IsValueType then Some( libValue com ctx " Types" " Record" , [])
19701979 else None)
0 commit comments