Open
Description
It's weird that this does not produce an error:
abstract class Bird {
name: String
}
class Parrot extends Bird {
name = "Polly"
lifespan = (super.lifespan) { // Bird does not define a property lifespan
min = 5
max = 20
}
}
mybird = new Parrot {}
Adding a trace()
around super.lifespan
indicates this expression has value new Dynamic {}
.
This behavior makes sense in dynamic context where the parent may not define properties the child needs to amend, eg.
foo { // this is in module definition context
bar { // this is in Dynamic object body context
baz = true
}
}
// which is syntax sugar for:
foo = (super.foo) {
bar = (super.bar) {
baz = true
}
}
But in a typed context where the full set of properties of the parent is known, attempting to access an unknown property should result in an error like this:
Cannot find property `lifespan` in object of type `bird#Bird`.
Metadata
Metadata
Assignees
Labels
No labels