To my beginner's knowledge of Scala there isn't any way to achieve the last line. I hope I am mistaken, and I just wanted to confirm. Also, I don't understand why, because the compiler should know the owner object of the f
method from the import statement.
object A { def f(s: Any) = println(s) }
import A.f
A f 1 //Works
f 2 // Does not compile
For clarification there are two questions:
- How should a single parameter method without parenthesis and explicit owner object reference be called? (See the subject.)
- What is the reason the compiler cannot understand the last statement?