Commit 560371c6 authored by Jinseong Jeon's avatar Jinseong Jeon
Browse files

FIR/UAST: regression test about exp type for range operator

^KT-59564
parent 189de89a
Branches unavailable Tags unavailable
No related merge requests found
Showing with 37 additions and 0 deletions
+37 -0
......@@ -352,6 +352,35 @@ interface UastApiFixtureTestBase : UastPluginSelection {
TestCase.assertEquals(UastCallKind.CONSTRUCTOR_CALL, uCallExpression.kind)
}
// Regression test from KT-59564
fun checkExpressionTypeOfForEach(myFixture: JavaCodeInsightTestFixture) {
myFixture.configureByText(
"main.kt", """
// !LANGUAGE: +RangeUntilOperator
@file:OptIn(ExperimentalStdlibApi::class)
fun test(a: Int, b: Int) {
for (i in a..<b step 1) {
println(i)
}
}
""".trimIndent()
)
val uFile = myFixture.file.toUElement()!!
uFile.accept(object : AbstractUastVisitor() {
override fun visitForEachExpression(node: UForEachExpression): Boolean {
when (val exp = node.iteratedValue.skipParenthesizedExprDown()) {
is UBinaryExpression -> {
TestCase.assertEquals("kotlin.ranges.IntProgression", exp.getExpressionType()?.canonicalText)
TestCase.assertEquals("kotlin.ranges.IntRange", exp.leftOperand.getExpressionType()?.canonicalText)
}
}
return super.visitForEachExpression(node)
}
})
}
// Regression test from KTIJ-23503
fun checkExpressionTypeFromIncorrectObject(myFixture: JavaCodeInsightTestFixture) {
myFixture.configureByText(
......
......@@ -57,6 +57,10 @@ class FirUastApiFixtureTest : KotlinLightCodeInsightFixtureTestCase(), UastApiFi
checkCallKindOfSamConstructor(myFixture)
}
fun testExpressionTypeOfForEach() {
checkExpressionTypeOfForEach(myFixture)
}
fun testExpressionTypeFromIncorrectObject() {
checkExpressionTypeFromIncorrectObject(myFixture)
}
......
......@@ -55,6 +55,10 @@ class FE1UastApiFixtureTest : KotlinLightCodeInsightFixtureTestCase(), UastApiFi
checkCallKindOfSamConstructor(myFixture)
}
fun testExpressionTypeOfForEach() {
checkExpressionTypeOfForEach(myFixture)
}
fun testExpressionTypeFromIncorrectObject() {
checkExpressionTypeFromIncorrectObject(myFixture)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment