LYR-SEM0123
a delegated conformance whose field cannot answer it
A conformance delegated with 'by field' names a field the type does not have, or a field whose type does not conform to the interface.
Explanation
:: [Walker by legs] forwards every member of Walker to the field legs. That works only if legs is a field of the type and its type conforms to Walker (or is a Walker value, or a value of a child of it); otherwise the forwarded calls have nowhere to go.
Name the right field, make the field's type conform to the interface, or implement the interface on the type directly.
Wrong
interface Walker { fn walk(): string; }
class Dog :: [Walker by legs] { var legs: int }
fn main(): void {
}
Right
interface Walker { fn walk(): string; }
class Legs :: [Walker] {
fn walk(): string { return "step"; }
}
class Dog :: [Walker by legs] { var legs: Legs }
fn main(): void {
let _ = Dog { legs = Legs { } }.walk();
}