[minor] Add the test confirming the wrong behavior of KT-48355

This commit is contained in:
Ilya Muradyan
2021-08-22 03:28:36 +03:00
parent 7306f1c3f1
commit d9c0b9ad5a
@@ -509,6 +509,41 @@ class ReplCompletionAndErrorsAnalysisTest : TestCase() {
}
}
@Test
fun testRequiresOptIn() = test {
// This test confirms the wrong behavior described in KT-48355
// This compilation is here to initialize the compiler without RequiresOptIn option.
// If you remove it, warning disappears.
run {
code = "1"
doCompile
}
run {
code = """
import kotlin.time.*
@OptIn(ExperimentalTime::class)
val mark = TimeSource.Monotonic.markNow()
""".trimIndent()
compilationConfiguration = ScriptCompilationConfiguration {
compilerOptions("-Xopt-in=kotlin.RequiresOptIn")
}
doErrorCheck
expect {
// This warning is a wrong behavior, it should pass away after fixing KT-48355
addError(
2, 2, 2, 7,
"This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'",
"WARNING"
)
}
}
}
private val setupDefaultImportsCompletionRun: TestRunConfigurator = {
compilationConfiguration = ScriptCompilationConfiguration {
defaultImports(listOf("kotlin.math.atan"))