Hi, is it possible to use sealed classes declared ...
# scripting
m
Hi, is it possible to use sealed classes declared in another script file ? This doesn't seem to work test.main.kts
Copy code
sealed class Test {
    object One : Test()
    object Two : Test()
}
test2.main.kts
Copy code
@file:Import("test.main.kts")

println("I have one: " + Test.One)
println("I have two: " + Test.One)
Error:
Copy code
$ kotlin
Welcome to Kotlin version 1.4.0 (JRE 14.0.1+7)
...
$ kotlin test2.main.kts
error: unresolved reference: Test (test2.main.kts:3:26)
error: unresolved reference: Test (test2.main.kts:4:26)
test2.main.kts:3:26: error: unresolved reference: Test
println("I have one: " + Test.One)
                         ^
test2.main.kts:4:26: error: unresolved reference: Test
println("I have two: " + Test.One)
                         ^
Is that supposed to happen? What am I missing here ?
v
According to https://youtrack.jetbrains.com/issue/KT-34178 this is fixed for 1.4.20 and before you would need to use
Test_main.Test.One
m
Oh, that's great news! I didn't realize this was such a general bug, I thought it was specific to sealed classes. Thanks!