Skip to content

Commit fd0d2ad

Browse files
committed
Kotlin: Add test for enumValues call with type parameter
1 parent 4f7eb7b commit fd0d2ad

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

java/ql/test/kotlin/library-tests/exprs/PrintAst.expected

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,6 +2832,27 @@ exprs.kt:
28322832
# 268| 0: [AssignRemExpr] ...%=...
28332833
# 268| 0: [VarAccess] updated
28342834
# 268| 1: [IntegerLiteral] 1
2835+
# 272| 12: [Method] getEnumValues
2836+
#-----| 2: (Generic Parameters)
2837+
# 272| 0: [TypeVariable] T
2838+
# 272| 3: [TypeAccess] T[]
2839+
# 272| 0: [TypeAccess] T
2840+
# 272| 5: [BlockStmt] { ... }
2841+
# 272| 0: [ReturnStmt] return ...
2842+
# 274| 13: [Method] callToEnumValues
2843+
# 274| 3: [TypeAccess] Unit
2844+
# 274| 5: [BlockStmt] { ... }
2845+
# 275| 0: [ExprStmt] <Expr>;
2846+
# 275| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
2847+
# 275| 0: [TypeAccess] Unit
2848+
# 275| 1: [MethodAccess] values(...)
2849+
# 275| -1: [TypeAccess] Color
2850+
# 276| 1: [ExprStmt] <Expr>;
2851+
# 276| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
2852+
# 276| 0: [TypeAccess] Unit
2853+
# 276| 1: [MethodAccess] getEnumValues(...)
2854+
# 276| -2: [TypeAccess] Color
2855+
# 276| -1: [TypeAccess] ExprsKt
28352856
# 142| 2: [Class] C
28362857
# 142| 1: [Constructor] C
28372858
#-----| 4: (Parameters)

java/ql/test/kotlin/library-tests/exprs/exprs.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,18 @@
17231723
| exprs.kt:268:3:268:9 | updated | exprs.kt:261:1:270:1 | inPlaceOperators | VarAccess |
17241724
| exprs.kt:268:3:268:14 | ...%=... | exprs.kt:261:1:270:1 | inPlaceOperators | AssignRemExpr |
17251725
| exprs.kt:268:14:268:14 | 1 | exprs.kt:261:1:270:1 | inPlaceOperators | IntegerLiteral |
1726+
| exprs.kt:272:8:272:66 | T | file://:0:0:0:0 | <none> | TypeAccess |
1727+
| exprs.kt:272:8:272:66 | T[] | file://:0:0:0:0 | <none> | TypeAccess |
1728+
| exprs.kt:274:1:277:1 | Unit | file://:0:0:0:0 | <none> | TypeAccess |
1729+
| exprs.kt:275:5:275:23 | <implicit coercion to unit> | exprs.kt:274:1:277:1 | callToEnumValues | ImplicitCoercionToUnitExpr |
1730+
| exprs.kt:275:5:275:23 | Color | exprs.kt:274:1:277:1 | callToEnumValues | TypeAccess |
1731+
| exprs.kt:275:5:275:23 | Unit | exprs.kt:274:1:277:1 | callToEnumValues | TypeAccess |
1732+
| exprs.kt:275:5:275:23 | values(...) | exprs.kt:274:1:277:1 | callToEnumValues | MethodAccess |
1733+
| exprs.kt:276:5:276:26 | <implicit coercion to unit> | exprs.kt:274:1:277:1 | callToEnumValues | ImplicitCoercionToUnitExpr |
1734+
| exprs.kt:276:5:276:26 | Color | exprs.kt:274:1:277:1 | callToEnumValues | TypeAccess |
1735+
| exprs.kt:276:5:276:26 | ExprsKt | exprs.kt:274:1:277:1 | callToEnumValues | TypeAccess |
1736+
| exprs.kt:276:5:276:26 | Unit | exprs.kt:274:1:277:1 | callToEnumValues | TypeAccess |
1737+
| exprs.kt:276:5:276:26 | getEnumValues(...) | exprs.kt:274:1:277:1 | callToEnumValues | MethodAccess |
17261738
| funcExprs.kt:1:1:1:46 | Unit | file://:0:0:0:0 | <none> | TypeAccess |
17271739
| funcExprs.kt:1:26:1:37 | Function0<Integer> | file://:0:0:0:0 | <none> | TypeAccess |
17281740
| funcExprs.kt:1:26:1:37 | Integer | file://:0:0:0:0 | <none> | TypeAccess |

java/ql/test/kotlin/library-tests/exprs/exprs.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,10 @@ fun inPlaceOperators() {
268268
updated %= 1
269269

270270
}
271+
272+
inline fun <reified T : Enum<T>> getEnumValues() = enumValues<T>()
273+
274+
fun callToEnumValues() {
275+
enumValues<Color>()
276+
getEnumValues<Color>()
277+
}

0 commit comments

Comments
 (0)