@@ -1233,7 +1233,7 @@ let private getExceptionTypeExpr (com: IPythonCompiler) ctx =
12331233 | Fable.DeclaredType( entRef, _) -> Annotation.tryPyConstructor com ctx ( com.GetEntity( entRef))
12341234 | _ -> None
12351235
1236- let transformTryCatch com ( ctx : Context ) r returnStrategy ( body , catch : option < Fable.Ident * Fable.Expr > , finalizer ) =
1236+ let transformTryCatch com ( ctx : Context ) r returnStrategy ( body , catch : ( Fable.Ident * Fable.Expr ) option , finalizer ) =
12371237 // try .. catch statements cannot be tail call optimized
12381238 let ctx = { ctx with TailCallOpportunity = None }
12391239
@@ -3278,32 +3278,35 @@ let declareDataClassType
32783278 let interfaceBases =
32793279 ent.AllInterfaces
32803280 |> List.ofSeq
3281- |> List.filter ( fun int ->
3281+ |> List.choose ( fun int ->
32823282 let name = Helpers.removeNamespace ( int.Entity.FullName)
3283- allowedInterfaces |> List.contains name
3284- )
3285- |> List.map ( fun int ->
3286- // Filter out self-referential generic arguments to avoid forward reference errors
3287- let genericArgs =
3288- int.GenericArgs
3289- |> List.filter ( fun genArg ->
3290- match genArg with
3291- | Fable.DeclaredType({ FullName = fullName }, _) -> Helpers.removeNamespace ( fullName) <> entName
3292- | _ -> true
3293- )
32943283
3295- // Generate the EnumerableBase reference from bases module
3296- if List.isEmpty genericArgs then
3297- libValue com ctx " bases" " EnumerableBase"
3284+ if not ( allowedInterfaces |> List.contains name) then
3285+ None
32983286 else
3299- let typeArgs =
3300- genericArgs
3301- |> List.map ( fun genArg ->
3302- let arg , _ = Annotation.typeAnnotation com ctx None genArg
3303- arg
3287+ // Filter out self-referential generic arguments to avoid forward reference errors
3288+ let genericArgs =
3289+ int.GenericArgs
3290+ |> List.filter ( fun genArg ->
3291+ match genArg with
3292+ | Fable.DeclaredType({ FullName = fullName }, _) ->
3293+ Helpers.removeNamespace ( fullName) <> entName
3294+ | _ -> true
33043295 )
33053296
3306- Expression.subscript ( libValue com ctx " bases" " EnumerableBase" , Expression.tuple typeArgs)
3297+ // Generate the EnumerableBase reference from bases module
3298+ if List.isEmpty genericArgs then
3299+ libValue com ctx " bases" " EnumerableBase" |> Some
3300+ else
3301+ let typeArgs =
3302+ genericArgs
3303+ |> List.map ( fun genArg ->
3304+ let arg , _ = Annotation.typeAnnotation com ctx None genArg
3305+ arg
3306+ )
3307+
3308+ Expression.subscript ( libValue com ctx " bases" " EnumerableBase" , Expression.tuple typeArgs)
3309+ |> Some
33073310 )
33083311
33093312 let bases = ( baseExpr |> Option.toList) @ interfaceBases
@@ -4473,8 +4476,12 @@ let transformInterface (com: IPythonCompiler) ctx (classEnt: Fable.Entity) (_cla
44734476 let interfaces =
44744477 classEnt.AllInterfaces
44754478 |> List.ofSeq
4476- |> List.map ( fun int -> int.Entity)
4477- |> List.filter ( fun ent -> ent.FullName <> classEnt.FullName)
4479+ |> List.choose ( fun int ->
4480+ if int.Entity.FullName <> classEnt.FullName then
4481+ Some int.Entity
4482+ else
4483+ None
4484+ )
44784485
44794486 for ref in interfaces do
44804487 let entity = com.TryGetEntity( ref)
0 commit comments