I’m opening a discussion here since I’m not sure whether it’s a feature request or a bug.
How do I explicitly add a type annotation for Main.all in the program below?
class Outer {
object inner {
class Foo
def foo = new Foo
}
}
object Main {
val a = new Outer
val b = new Outer
def all = List(a.inner.foo, b.inner.foo)
}
When compiling this program with -Xprint:typer, we see the inferred type of Main.all is
When I copy-paste the inferred type into the program and try to compile again I get a syntax error
infer.scala:11: error: ']' expected but '.' found.
def all: List[Outer#inner.Foo] = List(a.inner.foo, b.inner.foo)
^
one error found
I failed to come up with a wider type that’s not Any. The compiler is capable of inferring Outer#inner.Foo so it seems like this type is “just” missing surface syntax