The following code cannot be compiled with 2.12.8:
package foo
class Bar(y: Int) {
import Bar.x
def this() = this(x)
}
object Bar {
def x = 42
}
It works fine if the import statement is moved outside class Bar. Is this an intended behavior, based on some peculiarities of import I’m not aware of, or a bug?
The signature and the self constructor invocation of a constructor definition are type-checked and evaluated in the scope which is in effect at the point of the enclosing class definition, augmented by any type parameters of the enclosing class and by any early definitions of the enclosing template.