I am working on a small Scala project. I have the following issue with ‘import’:
If, at the top of one of my files, I import two thing with these commands:
import main.Main._
import main.game.Game
^^^^
it gives me the following error message at the underlined ‘main’ word: “missing arguments for method main in object Main; follow this method with `_’ if you want to treat it as a partially applied function” which is quite strange especially that it is just an import statement. And naturally no actual importing occures. At first I thought about semicolon inference quirks again but it is not the case. If I swap the two lines and write like this:
import main.game.Game
import main.Main._
then everythinng is fine.
Could anyone shed some light on that? Is it something special about Scala?
Presumably you have a
mainmethod inobject Main. So afterimport main.Main._mainrefers to this method instead of themainpackage. You could avoid it in several ways:mainmethod, as Daniel C. Sobral’s answer suggests.Explicitly say you want the top-level
mainpackage:Following the normal Java package naming convention should avoid this problem in most cases, as you are unlikely to have members (or subpackages) called
comororg(thoughnetcould be a problem).