When using scratch files, this code does not work ...
# intellij
m
When using scratch files, this code does not work even though it does not show any issue in the code editor in IntelliJ:
Copy code
import Scratch_2.MyEnum.*

enum class MyEnum {
    WORD, NUMBER, WHITESPACE
}

val myPairs = listOf(
    "example" to WORD,
    "42" to NUMBER,
    " " to WHITESPACE
)

println(myPairs)
It does not work because of the import on line 1.
Unresolved reference: Scratch_2
(note that I use
Scratch_n
where n is whatever IntelliJ suggests in the autocompletion menu) If I replace the first line by
import MyEnum.*
directly, then the error is
Unresolved reference: MyEnum
The only way of making this code work is by removing the import and specifying
MyEnum
every time. Is there any way to make this work?
🙏 1
e
through you shouldn’t import element that can be seen explicitly also, scratches are under anonymous package, iirc?
m
Scratch_2 is a class according to IntelliJ's autocompletion, and the import is there to avoid having to specify MyEnum.WORD, MyEnum.NUMBER... every time