A simple example illustrating what happens here (in the REPL):
object A def foo(a : A) = "Does not compile" def bar(a : A.type) = "Does compile!" bar(A) // returns "Does compile!"
As Nikolai says, Inner is not a type, so you cannot use it as such.
Trying to understand your motivation, I came up with something like this:
class Outer(i : Int) { object Inner { def getI : Int = i } def foo(x : Inner.type) = x.getI }
This is a little pointless, as we would just refer to Inner only - after all, only one of them:
class Outer(i : Int) { object Inner { def getI : Int = i } def foo = Inner.getI }
I assume you want to accept Inner from any instance of Outer. We can check the type of such a thing:
val o = new Outer(1) :type o.Inner o.Inner.type
So, we can expect that I can do something like this:
class Outer(i : Int) { object Inner { def getI : Int = i } def foo(x : Outer
This, however, cannot be compiled. I do not know why. Enter aliases to help!
class Outer(i : Int) { type Inner = Inner.type object Inner { def getI : Int = i } def foo(x : Outer
I assume this is just a parser restriction that it cannot read something from the form A#B.type . You can send an error request.
Submonoid
source share