UAST properly handles string "when conditions" in lazy parent (KT-20709) (#1338)

This commit is contained in:
xiexed
2017-10-11 16:16:15 +03:00
committed by Dmitry Jemerov
parent 88595e1a58
commit 5c2962e195
6 changed files with 116 additions and 4 deletions
+12
View File
@@ -0,0 +1,12 @@
val a = readLine()
val b = when(a) {
"abc" -> 1
"def", "ghi" -> 2
else -> 3
}
when(a) {
"abc1" -> println(1)
"def1", "ghi1" -> println(2)
}
+33
View File
@@ -0,0 +1,33 @@
UFile (package = )
UClass (name = WhenStringLiteralKt)
UField (name = a)
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (readLine))
USimpleNameReferenceExpression (identifier = readLine)
UField (name = b)
UAnnotation (fqName = null)
USwitchExpression
USimpleNameReferenceExpression (identifier = a)
UExpressionList (when)
USwitchClauseExpressionWithBody
ULiteralExpression (value = "abc")
UExpressionList (when_entry)
ULiteralExpression (value = 1)
UBreakExpression (label = null)
USwitchClauseExpressionWithBody
ULiteralExpression (value = "def")
ULiteralExpression (value = "ghi")
UExpressionList (when_entry)
ULiteralExpression (value = 2)
UBreakExpression (label = null)
USwitchClauseExpressionWithBody
UExpressionList (when_entry)
ULiteralExpression (value = 3)
UBreakExpression (label = null)
UAnnotationMethod (name = getA)
UAnnotationMethod (name = getB)
UAnnotationMethod (name = <no name provided>)
UBlockExpression
ULiteralExpression (value = "abc1")
ULiteralExpression (value = "def1")
@@ -0,0 +1,27 @@
public final class WhenStringLiteralKt {
private static final var a: java.lang.String = readLine()
private static final var b: int = switch (a) {
"abc" -> {
1
break
}
"def", "ghi" -> {
2
break
}
-> {
3
break
}
}
public static final fun getA() : java.lang.String = UastEmptyExpression
public static final fun getB() : int = UastEmptyExpression
public static final fun <no name provided>() : void {
"abc1"
"def1"
}
}