Skip to content

Commit edb200b

Browse files
Fix #2295: Ignore some errors
1 parent 0fc1f29 commit edb200b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Fable.Transforms/FSharp2Fable.Util.fs

+6
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,12 @@ module Util =
11481148
| Atts.global_ | Naming.StartsWith Atts.import _ -> true
11491149
| _ -> false)
11501150

1151+
let isEmittedOrImportedMember (memb: FSharpMemberOrFunctionOrValue) =
1152+
memb.Attributes |> Seq.exists (fun att ->
1153+
match att.AttributeType.TryFullName with
1154+
| Some(Naming.StartsWith Atts.emit _ | Atts.global_ | Naming.StartsWith Atts.import _) -> true
1155+
| _ -> false)
1156+
11511157
let isFromDllRef (ent: Fable.Entity) =
11521158
match ent.Ref.Path with
11531159
| Fable.AssemblyPath _ | Fable.CoreAssemblyName _ -> true

src/Fable.Transforms/FSharp2Fable.fs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,11 @@ let private transformMemberDecl (com: FableCompiler) (ctx: Context) (memb: FShar
10491049
let declaringEntity = FsEnt declaringEntity :> Fable.Entity
10501050
if isGlobalOrImportedEntity declaringEntity then ()
10511051
elif isErasedOrStringEnumEntity declaringEntity then
1052-
let r = makeRange memb.DeclarationLocation |> Some
1053-
"Erased types cannot implement abstract members"
1054-
|> addError com ctx.InlinePath r
1052+
// Ignore abstract members for classes, see #2295
1053+
if declaringEntity.IsFSharpUnion || declaringEntity.IsFSharpRecord then
1054+
let r = makeRange memb.DeclarationLocation |> Some
1055+
"Erased unions/records cannot implement abstract members"
1056+
|> addError com ctx.InlinePath r
10551057
else
10561058
// Not sure when it's possible that a member implements multiple abstract signatures
10571059
memb.ImplementedAbstractSignatures
@@ -1096,7 +1098,8 @@ let rec private getUsedRootNames (com: Compiler) (usedNames: Set<string>) decls
10961098
| sub ->
10971099
getUsedRootNames com usedNames sub
10981100
| MemberOrFunctionOrValue(memb,_,_) ->
1099-
if memb.IsOverrideOrExplicitInterfaceImplementation then usedNames
1101+
if memb.IsOverrideOrExplicitInterfaceImplementation
1102+
|| isInline memb || isEmittedOrImportedMember memb then usedNames
11001103
else
11011104
let memberName, _ = getMemberDeclarationName com memb
11021105
addUsedRootName com memberName usedNames

0 commit comments

Comments
 (0)