I have a class hierarchy that implements IAspect<'C> and overrides the Attach method. The bottom-most class(ProjectSelection) is causing Fable to generate code that fails at runtime, making reference to a non-existent method. This is caught by the example program below, and printed.
I've trimmed this down from my application code. If I remove the <'C> templating parameter, the issue goes away. That may be useful in tracking the issue down.
Bad code in class ProjectSelection:
"OverrideIssue.AspectBase`1.Attach2B595"(owner) {
super["OverrideIssue.AspectBase`1.Attach1505"](owner); // Attach1505 is undefined
toConsole(printf("ProjectSelection: attach to %A"))(owner);
}
Repro code
module OverrideIssue
type IAspect<'C> =
abstract Attach: 'C -> unit
[<AbstractClass>]
type AspectBase<'C>( ) =
abstract Attach: 'C -> unit
default this.Attach (owner): unit =
printfn "AspectBase: attach to %A" owner
interface IAspect<'C> with
member __.Attach (owner): unit = __.Attach(owner)
type SelectionAspect<'Container>( ) =
inherit AspectBase<'Container>()
override __.Attach(owner) =
base.Attach(owner)
printfn "SelectionAspect: attach to %A" owner
type ProjectSelection() =
inherit SelectionAspect<string>()
override __.Attach(owner) =
base.Attach(owner)
printfn "ProjectSelection: attach to %A" owner
try
(new ProjectSelection()).Attach("root")
with
| x -> printfn "Error: %s" x.Message
Description
I have a class hierarchy that implements
IAspect<'C>
and overrides theAttach
method. The bottom-most class(ProjectSelection
) is causing Fable to generate code that fails at runtime, making reference to a non-existent method. This is caught by the example program below, and printed.I've trimmed this down from my application code. If I remove the
<'C>
templating parameter, the issue goes away. That may be useful in tracking the issue down.Bad code in class
ProjectSelection
:Repro code
Fable REPL URL
https://fable.io/repl/#?code=LYewJgrgNgpgBAeQG4wE6oJZhgSQM54QwBQxALgJ4AO8OAgnjQMZkA8A5AMIB8cAvMThC4AQwBGeMqhEs4dMmRkALAFxwucALS8IAOwxlSAbVZ0JUmWU5QRBbgF1y1eA2ZkAQrZgceACjgAlPykwqLm0rLyikyq6pxaOvqGodgAZiLQZHBkShh4AHRRynC+IADuumgBanoG-HCCocJUmLpkqbpwAESuMCyeeDBqIgrFZCBwAKR0XXDllaghwhhtaOlMtL0sPrxlBkqNTXDAMMBiaHAA+peFozEl81U1SfXXt9FKpRVVpJQ0cABlGCwFgYEC6LZsLjgxQrNDcfxBAShFZKNB1SEDbzQtoiOGoBEBJZCEAodBYeBvIoxL4LJENI5CMRed7KWk-RlwFordqdLpAkFkMEQxh9MjDO5KbITaazR6LJz-AAKqBAACsxQKxcLfEjDnBUeislrQeDIaxJK0AOaE4lzMmYbBXG7Uz7y+n60LMwasmnuz3NVq87oq9Wa4Ha8ESj7SqYzObfBVSCj63yVMpwUMalgmoXg3UBX2fLqqkBkLpEvY5YgAHzgAA8Elygx1ugBRdAgVBqSZ4Wb1-IAWRgBBEVpgQA&html=Q&css=Q
Expected output
Actual output
Related information
dotnet fable --version
4.20.0