Open kjx opened 8 years ago
I still don't know what the shadowing rules are (see also #75, #140, #141).
There seem to be two parts:
The most general rule is: all declarations are forbidden from shadowing, and all declarations cannot be shadowed: !findInternalDeclaringContext(name).isMissing
(we do a lookup and we find a preëxisting definition). That rule, for example, forbids the following because bar.inner.x
would shadow the x
method in bar
inherited from foo
:
class foo {
method x { "X" }
}
class bar {
inherit foo
class inner {
method x { "XXXXX" }
method y(x) { "YYYY" }
}
}
Or (along each axis):
bar.inner.x
only shadow a local definition in bar
, not one inherited from foo
?bar.inner.x
be permitted to shadow (almost) anything, but y
's x
method argument should be forbidden as it shadows the enclosing x
?
what should the shadowing rules be (raised by Kim)