But imo o.Inner
is much uglyier than Outer#Inner
. Would you explain, what the point of use former instead of latter? The compiler can do only static checks so o.Inner
should be equal o.type#Inner
which should be (statically) equal to Outer#Inner
. Am I missing something?
Here is the reason. Imagine you had
class Outer1 extends Outer {
type Inner = Int
def apply(i: Int) { ... }
}
class Outer2 extends Outer {
type Inner = String
def apply(i: Int) { ... }
}
Should test.apply(new Outer1, "abc")
compile? Obviously not, since it'll call Outer1.apply(String)
, which doesn't exist. But then, test.apply(new Outer1, 1)
can't compile either (otherwise you are back to path-dependent types) and there is no way to use this apply
at all!