Skip to content

Commit

Permalink
Fix #2295: Ignore some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Nov 28, 2020
1 parent 0fc1f29 commit edb200b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,12 @@ module Util =
| Atts.global_ | Naming.StartsWith Atts.import _ -> true
| _ -> false)

let isEmittedOrImportedMember (memb: FSharpMemberOrFunctionOrValue) =
memb.Attributes |> Seq.exists (fun att ->
match att.AttributeType.TryFullName with
| Some(Naming.StartsWith Atts.emit _ | Atts.global_ | Naming.StartsWith Atts.import _) -> true
| _ -> false)

let isFromDllRef (ent: Fable.Entity) =
match ent.Ref.Path with
| Fable.AssemblyPath _ | Fable.CoreAssemblyName _ -> true
Expand Down
11 changes: 7 additions & 4 deletions src/Fable.Transforms/FSharp2Fable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,11 @@ let private transformMemberDecl (com: FableCompiler) (ctx: Context) (memb: FShar
let declaringEntity = FsEnt declaringEntity :> Fable.Entity
if isGlobalOrImportedEntity declaringEntity then ()
elif isErasedOrStringEnumEntity declaringEntity then
let r = makeRange memb.DeclarationLocation |> Some
"Erased types cannot implement abstract members"
|> addError com ctx.InlinePath r
// Ignore abstract members for classes, see #2295
if declaringEntity.IsFSharpUnion || declaringEntity.IsFSharpRecord then
let r = makeRange memb.DeclarationLocation |> Some
"Erased unions/records cannot implement abstract members"
|> addError com ctx.InlinePath r
else
// Not sure when it's possible that a member implements multiple abstract signatures
memb.ImplementedAbstractSignatures
Expand Down Expand Up @@ -1096,7 +1098,8 @@ let rec private getUsedRootNames (com: Compiler) (usedNames: Set<string>) decls
| sub ->
getUsedRootNames com usedNames sub
| MemberOrFunctionOrValue(memb,_,_) ->
if memb.IsOverrideOrExplicitInterfaceImplementation then usedNames
if memb.IsOverrideOrExplicitInterfaceImplementation
|| isInline memb || isEmittedOrImportedMember memb then usedNames
else
let memberName, _ = getMemberDeclarationName com memb
addUsedRootName com memberName usedNames
Expand Down

0 comments on commit edb200b

Please sign in to comment.