From a603f21ce1a547f5fe5b7bb87f0a4c0b31629fbc Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 11 Jul 2023 14:10:48 +0100 Subject: [PATCH 1/3] Kotlin: Use 1.9.0 for CI --- java/kotlin-extractor/kotlin_plugin_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/kotlin-extractor/kotlin_plugin_versions.py b/java/kotlin-extractor/kotlin_plugin_versions.py index bf1c211073a0..ea487b4e6cc5 100755 --- a/java/kotlin-extractor/kotlin_plugin_versions.py +++ b/java/kotlin-extractor/kotlin_plugin_versions.py @@ -22,7 +22,7 @@ def version_string_to_tuple(version): return tuple([int(m.group(i)) for i in range(1, 4)] + [m.group(4)]) # Version number used by CI. -ci_version = '1.8.10' +ci_version = '1.9.0' many_versions = [ '1.4.32', '1.5.0', '1.5.10', '1.5.20', '1.5.30', '1.6.0', '1.6.20', '1.7.0', '1.7.20', '1.8.0', '1.9.0-Beta' ] From 470e033090aad5be28dcff7354151c13df7ea7d6 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 11 Jul 2023 17:35:20 +0100 Subject: [PATCH 2/3] Kotlin: Restrict a test's results to those in the test directory --- .../kotlin/library-tests/annotation-accessor-result-type/test.ql | 1 + 1 file changed, 1 insertion(+) diff --git a/java/ql/test/kotlin/library-tests/annotation-accessor-result-type/test.ql b/java/ql/test/kotlin/library-tests/annotation-accessor-result-type/test.ql index 1f2454995524..65576a7c19dd 100644 --- a/java/ql/test/kotlin/library-tests/annotation-accessor-result-type/test.ql +++ b/java/ql/test/kotlin/library-tests/annotation-accessor-result-type/test.ql @@ -1,6 +1,7 @@ import java query predicate classExprs(Expr e, string tstr) { + exists(e.getFile().getRelativePath()) and tstr = e.getType().toString() and tstr.matches("%Class%") } From b83f0275e3061a8a3a03546b41e57a5de05d88ee Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 11 Jul 2023 15:09:40 +0100 Subject: [PATCH 3/3] Kotlin: Accept test changes for Kotlin 1.9.0 --- .../annotation_classes/PrintAst.expected | 15 ++++---- .../library-tests/classes/PrintAst.expected | 36 +++++++++++-------- .../library-tests/exprs/PrintAst.expected | 36 +++++++++++-------- .../kotlin/library-tests/exprs/exprs.expected | 4 +++ .../exprs_typeaccess/PrintAst.expected | 15 ++++---- .../library-tests/methods/exprs.expected | 4 +++ .../library-tests/methods/methods.expected | 2 ++ 7 files changed, 70 insertions(+), 42 deletions(-) diff --git a/java/ql/test/kotlin/library-tests/annotation_classes/PrintAst.expected b/java/ql/test/kotlin/library-tests/annotation_classes/PrintAst.expected index 0ff19b747fab..643c416b7361 100644 --- a/java/ql/test/kotlin/library-tests/annotation_classes/PrintAst.expected +++ b/java/ql/test/kotlin/library-tests/annotation_classes/PrintAst.expected @@ -169,15 +169,18 @@ def.kt: # 33| 0: [SuperConstructorInvocationStmt] super(...) # 33| 1: [BlockStmt] { ... } # 34| 5: [Class] Y -# 0| 2: [Method] valueOf +# 0| 2: [Method] getEntries +# 0| 3: [TypeAccess] EnumEntries +# 0| 0: [TypeAccess] Y +# 0| 3: [Method] valueOf # 0| 3: [TypeAccess] Y #-----| 4: (Parameters) # 0| 0: [Parameter] value # 0| 0: [TypeAccess] String -# 0| 3: [Method] values +# 0| 4: [Method] values # 0| 3: [TypeAccess] Y[] # 0| 0: [TypeAccess] Y -# 34| 4: [Constructor] Y +# 34| 5: [Constructor] Y # 34| 5: [BlockStmt] { ... } # 34| 0: [ExprStmt] ; # 34| 0: [ClassInstanceExpr] new Enum(...) @@ -186,15 +189,15 @@ def.kt: # 34| 0: [NullLiteral] null # 34| 1: [IntegerLiteral] 0 # 34| 1: [BlockStmt] { ... } -# 35| 5: [FieldDeclaration] Y A; +# 35| 6: [FieldDeclaration] Y A; # 35| -1: [TypeAccess] Y # 35| 0: [ClassInstanceExpr] new Y(...) # 35| -3: [TypeAccess] Y -# 35| 6: [FieldDeclaration] Y B; +# 35| 7: [FieldDeclaration] Y B; # 35| -1: [TypeAccess] Y # 35| 0: [ClassInstanceExpr] new Y(...) # 35| -3: [TypeAccess] Y -# 35| 7: [FieldDeclaration] Y C; +# 35| 8: [FieldDeclaration] Y C; # 35| -1: [TypeAccess] Y # 35| 0: [ClassInstanceExpr] new Y(...) # 35| -3: [TypeAccess] Y diff --git a/java/ql/test/kotlin/library-tests/classes/PrintAst.expected b/java/ql/test/kotlin/library-tests/classes/PrintAst.expected index 6f19fb37feee..8da4a380a802 100644 --- a/java/ql/test/kotlin/library-tests/classes/PrintAst.expected +++ b/java/ql/test/kotlin/library-tests/classes/PrintAst.expected @@ -160,15 +160,18 @@ classes.kt: # 42| -1: [TypeAccess] int # 42| 0: [IntegerLiteral] 3 # 49| 11: [Class] Direction -# 0| 2: [Method] valueOf +# 0| 2: [Method] getEntries +# 0| 3: [TypeAccess] EnumEntries +# 0| 0: [TypeAccess] Direction +# 0| 3: [Method] valueOf # 0| 3: [TypeAccess] Direction #-----| 4: (Parameters) # 0| 0: [Parameter] value # 0| 0: [TypeAccess] String -# 0| 3: [Method] values +# 0| 4: [Method] values # 0| 3: [TypeAccess] Direction[] # 0| 0: [TypeAccess] Direction -# 49| 4: [Constructor] Direction +# 49| 5: [Constructor] Direction # 49| 5: [BlockStmt] { ... } # 49| 0: [ExprStmt] ; # 49| 0: [ClassInstanceExpr] new Enum(...) @@ -177,32 +180,35 @@ classes.kt: # 49| 0: [NullLiteral] null # 49| 1: [IntegerLiteral] 0 # 49| 1: [BlockStmt] { ... } -# 50| 5: [FieldDeclaration] Direction NORTH; +# 50| 6: [FieldDeclaration] Direction NORTH; # 50| -1: [TypeAccess] Direction # 50| 0: [ClassInstanceExpr] new Direction(...) # 50| -3: [TypeAccess] Direction -# 50| 6: [FieldDeclaration] Direction SOUTH; +# 50| 7: [FieldDeclaration] Direction SOUTH; # 50| -1: [TypeAccess] Direction # 50| 0: [ClassInstanceExpr] new Direction(...) # 50| -3: [TypeAccess] Direction -# 50| 7: [FieldDeclaration] Direction WEST; +# 50| 8: [FieldDeclaration] Direction WEST; # 50| -1: [TypeAccess] Direction # 50| 0: [ClassInstanceExpr] new Direction(...) # 50| -3: [TypeAccess] Direction -# 50| 8: [FieldDeclaration] Direction EAST; +# 50| 9: [FieldDeclaration] Direction EAST; # 50| -1: [TypeAccess] Direction # 50| 0: [ClassInstanceExpr] new Direction(...) # 50| -3: [TypeAccess] Direction # 53| 12: [Class] Color -# 0| 2: [Method] valueOf +# 0| 2: [Method] getEntries +# 0| 3: [TypeAccess] EnumEntries +# 0| 0: [TypeAccess] Color +# 0| 3: [Method] valueOf # 0| 3: [TypeAccess] Color #-----| 4: (Parameters) # 0| 0: [Parameter] value # 0| 0: [TypeAccess] String -# 0| 3: [Method] values +# 0| 4: [Method] values # 0| 3: [TypeAccess] Color[] # 0| 0: [TypeAccess] Color -# 53| 4: [Constructor] Color +# 53| 5: [Constructor] Color #-----| 4: (Parameters) # 53| 0: [Parameter] rgb # 53| 0: [TypeAccess] int @@ -217,26 +223,26 @@ classes.kt: # 53| 0: [ExprStmt] ; # 53| 0: [KtInitializerAssignExpr] ...=... # 53| 0: [VarAccess] rgb -# 53| 5: [Method] getRgb +# 53| 6: [Method] getRgb # 53| 3: [TypeAccess] int # 53| 5: [BlockStmt] { ... } # 53| 0: [ReturnStmt] return ... # 53| 0: [VarAccess] this.rgb # 53| -1: [ThisAccess] this -# 53| 6: [FieldDeclaration] int rgb; +# 53| 7: [FieldDeclaration] int rgb; # 53| -1: [TypeAccess] int # 53| 0: [VarAccess] rgb -# 54| 7: [FieldDeclaration] Color RED; +# 54| 8: [FieldDeclaration] Color RED; # 54| -1: [TypeAccess] Color # 54| 0: [ClassInstanceExpr] new Color(...) # 54| -3: [TypeAccess] Color # 54| 0: [IntegerLiteral] 16711680 -# 55| 8: [FieldDeclaration] Color GREEN; +# 55| 9: [FieldDeclaration] Color GREEN; # 55| -1: [TypeAccess] Color # 55| 0: [ClassInstanceExpr] new Color(...) # 55| -3: [TypeAccess] Color # 55| 0: [IntegerLiteral] 65280 -# 56| 9: [FieldDeclaration] Color BLUE; +# 56| 10: [FieldDeclaration] Color BLUE; # 56| -1: [TypeAccess] Color # 56| 0: [ClassInstanceExpr] new Color(...) # 56| -3: [TypeAccess] Color diff --git a/java/ql/test/kotlin/library-tests/exprs/PrintAst.expected b/java/ql/test/kotlin/library-tests/exprs/PrintAst.expected index 3b4cc35d4d4f..fbcea06528f1 100644 --- a/java/ql/test/kotlin/library-tests/exprs/PrintAst.expected +++ b/java/ql/test/kotlin/library-tests/exprs/PrintAst.expected @@ -3344,15 +3344,18 @@ exprs.kt: # 154| 0: [SuperConstructorInvocationStmt] super(...) # 154| 1: [BlockStmt] { ... } # 174| 6: [Class] Direction -# 0| 2: [Method] valueOf +# 0| 2: [Method] getEntries +# 0| 3: [TypeAccess] EnumEntries +# 0| 0: [TypeAccess] Direction +# 0| 3: [Method] valueOf # 0| 3: [TypeAccess] Direction #-----| 4: (Parameters) # 0| 0: [Parameter] value # 0| 0: [TypeAccess] String -# 0| 3: [Method] values +# 0| 4: [Method] values # 0| 3: [TypeAccess] Direction[] # 0| 0: [TypeAccess] Direction -# 174| 4: [Constructor] Direction +# 174| 5: [Constructor] Direction # 174| 5: [BlockStmt] { ... } # 174| 0: [ExprStmt] ; # 174| 0: [ClassInstanceExpr] new Enum(...) @@ -3361,32 +3364,35 @@ exprs.kt: # 174| 0: [NullLiteral] null # 174| 1: [IntegerLiteral] 0 # 174| 1: [BlockStmt] { ... } -# 175| 5: [FieldDeclaration] Direction NORTH; +# 175| 6: [FieldDeclaration] Direction NORTH; # 175| -1: [TypeAccess] Direction # 175| 0: [ClassInstanceExpr] new Direction(...) # 175| -3: [TypeAccess] Direction -# 175| 6: [FieldDeclaration] Direction SOUTH; +# 175| 7: [FieldDeclaration] Direction SOUTH; # 175| -1: [TypeAccess] Direction # 175| 0: [ClassInstanceExpr] new Direction(...) # 175| -3: [TypeAccess] Direction -# 175| 7: [FieldDeclaration] Direction WEST; +# 175| 8: [FieldDeclaration] Direction WEST; # 175| -1: [TypeAccess] Direction # 175| 0: [ClassInstanceExpr] new Direction(...) # 175| -3: [TypeAccess] Direction -# 175| 8: [FieldDeclaration] Direction EAST; +# 175| 9: [FieldDeclaration] Direction EAST; # 175| -1: [TypeAccess] Direction # 175| 0: [ClassInstanceExpr] new Direction(...) # 175| -3: [TypeAccess] Direction # 178| 7: [Class] Color -# 0| 2: [Method] valueOf +# 0| 2: [Method] getEntries +# 0| 3: [TypeAccess] EnumEntries +# 0| 0: [TypeAccess] Color +# 0| 3: [Method] valueOf # 0| 3: [TypeAccess] Color #-----| 4: (Parameters) # 0| 0: [Parameter] value # 0| 0: [TypeAccess] String -# 0| 3: [Method] values +# 0| 4: [Method] values # 0| 3: [TypeAccess] Color[] # 0| 0: [TypeAccess] Color -# 178| 4: [Constructor] Color +# 178| 5: [Constructor] Color #-----| 4: (Parameters) # 178| 0: [Parameter] rgb # 178| 0: [TypeAccess] int @@ -3401,26 +3407,26 @@ exprs.kt: # 178| 0: [ExprStmt] ; # 178| 0: [KtInitializerAssignExpr] ...=... # 178| 0: [VarAccess] rgb -# 178| 5: [Method] getRgb +# 178| 6: [Method] getRgb # 178| 3: [TypeAccess] int # 178| 5: [BlockStmt] { ... } # 178| 0: [ReturnStmt] return ... # 178| 0: [VarAccess] this.rgb # 178| -1: [ThisAccess] this -# 178| 6: [FieldDeclaration] int rgb; +# 178| 7: [FieldDeclaration] int rgb; # 178| -1: [TypeAccess] int # 178| 0: [VarAccess] rgb -# 179| 7: [FieldDeclaration] Color RED; +# 179| 8: [FieldDeclaration] Color RED; # 179| -1: [TypeAccess] Color # 179| 0: [ClassInstanceExpr] new Color(...) # 179| -3: [TypeAccess] Color # 179| 0: [IntegerLiteral] 16711680 -# 180| 8: [FieldDeclaration] Color GREEN; +# 180| 9: [FieldDeclaration] Color GREEN; # 180| -1: [TypeAccess] Color # 180| 0: [ClassInstanceExpr] new Color(...) # 180| -3: [TypeAccess] Color # 180| 0: [IntegerLiteral] 65280 -# 181| 9: [FieldDeclaration] Color BLUE; +# 181| 10: [FieldDeclaration] Color BLUE; # 181| -1: [TypeAccess] Color # 181| 0: [ClassInstanceExpr] new Color(...) # 181| -3: [TypeAccess] Color diff --git a/java/ql/test/kotlin/library-tests/exprs/exprs.expected b/java/ql/test/kotlin/library-tests/exprs/exprs.expected index 07d57c444e42..69c4f096de96 100644 --- a/java/ql/test/kotlin/library-tests/exprs/exprs.expected +++ b/java/ql/test/kotlin/library-tests/exprs/exprs.expected @@ -885,10 +885,14 @@ | delegatedProperties.kt:87:34:87:46 | this | delegatedProperties.kt:87:34:87:46 | invoke | ThisAccess | | exprs.kt:0:0:0:0 | Color | file://:0:0:0:0 | | TypeAccess | | exprs.kt:0:0:0:0 | Color | file://:0:0:0:0 | | TypeAccess | +| exprs.kt:0:0:0:0 | Color | file://:0:0:0:0 | | TypeAccess | | exprs.kt:0:0:0:0 | Color[] | file://:0:0:0:0 | | TypeAccess | | exprs.kt:0:0:0:0 | Direction | file://:0:0:0:0 | | TypeAccess | | exprs.kt:0:0:0:0 | Direction | file://:0:0:0:0 | | TypeAccess | +| exprs.kt:0:0:0:0 | Direction | file://:0:0:0:0 | | TypeAccess | | exprs.kt:0:0:0:0 | Direction[] | file://:0:0:0:0 | | TypeAccess | +| exprs.kt:0:0:0:0 | EnumEntries | file://:0:0:0:0 | | TypeAccess | +| exprs.kt:0:0:0:0 | EnumEntries | file://:0:0:0:0 | | TypeAccess | | exprs.kt:0:0:0:0 | String | file://:0:0:0:0 | | TypeAccess | | exprs.kt:0:0:0:0 | String | file://:0:0:0:0 | | TypeAccess | | exprs.kt:4:1:142:1 | int | file://:0:0:0:0 | | TypeAccess | diff --git a/java/ql/test/kotlin/library-tests/exprs_typeaccess/PrintAst.expected b/java/ql/test/kotlin/library-tests/exprs_typeaccess/PrintAst.expected index 5af83a46a01b..56a295cfaf79 100644 --- a/java/ql/test/kotlin/library-tests/exprs_typeaccess/PrintAst.expected +++ b/java/ql/test/kotlin/library-tests/exprs_typeaccess/PrintAst.expected @@ -74,15 +74,18 @@ A.kt: # 20| 0: [VarAccess] B.x # 20| -1: [TypeAccess] B # 23| 11: [Class] Enu -# 0| 2: [Method] valueOf +# 0| 2: [Method] getEntries +# 0| 3: [TypeAccess] EnumEntries +# 0| 0: [TypeAccess] Enu +# 0| 3: [Method] valueOf # 0| 3: [TypeAccess] Enu #-----| 4: (Parameters) # 0| 0: [Parameter] value # 0| 0: [TypeAccess] String -# 0| 3: [Method] values +# 0| 4: [Method] values # 0| 3: [TypeAccess] Enu[] # 0| 0: [TypeAccess] Enu -# 23| 4: [Constructor] Enu +# 23| 5: [Constructor] Enu # 23| 5: [BlockStmt] { ... } # 23| 0: [ExprStmt] ; # 23| 0: [ClassInstanceExpr] new Enum(...) @@ -91,15 +94,15 @@ A.kt: # 23| 0: [NullLiteral] null # 23| 1: [IntegerLiteral] 0 # 23| 1: [BlockStmt] { ... } -# 24| 5: [FieldDeclaration] Enu A; +# 24| 6: [FieldDeclaration] Enu A; # 24| -1: [TypeAccess] Enu # 24| 0: [ClassInstanceExpr] new Enu(...) # 24| -3: [TypeAccess] Enu -# 24| 6: [FieldDeclaration] Enu B; +# 24| 7: [FieldDeclaration] Enu B; # 24| -1: [TypeAccess] Enu # 24| 0: [ClassInstanceExpr] new Enu(...) # 24| -3: [TypeAccess] Enu -# 24| 7: [FieldDeclaration] Enu C; +# 24| 8: [FieldDeclaration] Enu C; # 24| -1: [TypeAccess] Enu # 24| 0: [ClassInstanceExpr] new Enu(...) # 24| -3: [TypeAccess] Enu diff --git a/java/ql/test/kotlin/library-tests/methods/exprs.expected b/java/ql/test/kotlin/library-tests/methods/exprs.expected index 5de17a12bf9f..ed0a9fbd6d86 100644 --- a/java/ql/test/kotlin/library-tests/methods/exprs.expected +++ b/java/ql/test/kotlin/library-tests/methods/exprs.expected @@ -225,7 +225,11 @@ | delegates.kt:10:33:10:35 | new | VarAccess | | enumClass.kt:0:0:0:0 | EnumClass | TypeAccess | | enumClass.kt:0:0:0:0 | EnumClass | TypeAccess | +| enumClass.kt:0:0:0:0 | EnumClass | TypeAccess | | enumClass.kt:0:0:0:0 | EnumClass[] | TypeAccess | +| enumClass.kt:0:0:0:0 | EnumEntries | TypeAccess | +| enumClass.kt:0:0:0:0 | EnumEntries | TypeAccess | +| enumClass.kt:0:0:0:0 | EnumWithFunctions | TypeAccess | | enumClass.kt:0:0:0:0 | EnumWithFunctions | TypeAccess | | enumClass.kt:0:0:0:0 | EnumWithFunctions | TypeAccess | | enumClass.kt:0:0:0:0 | EnumWithFunctions[] | TypeAccess | diff --git a/java/ql/test/kotlin/library-tests/methods/methods.expected b/java/ql/test/kotlin/library-tests/methods/methods.expected index 89cdd03f303a..e254e862090f 100644 --- a/java/ql/test/kotlin/library-tests/methods/methods.expected +++ b/java/ql/test/kotlin/library-tests/methods/methods.expected @@ -26,10 +26,12 @@ methods | delegates.kt:8:32:11:5 | new KMutableProperty1(...) { ... } | delegates.kt:8:32:11:5 | set | set(MyClass,java.lang.String) | override, public | | | delegates.kt:8:66:11:5 | new Function3,String,String,Unit>(...) { ... } | delegates.kt:8:66:11:5 | invoke | invoke(kotlin.reflect.KProperty,java.lang.String,java.lang.String) | final, override, public | | | enumClass.kt:1:1:4:1 | EnumClass | enumClass.kt:0:0:0:0 | | () | static | Compiler generated | +| enumClass.kt:1:1:4:1 | EnumClass | enumClass.kt:0:0:0:0 | getEntries | getEntries() | final, public, static | Compiler generated | | enumClass.kt:1:1:4:1 | EnumClass | enumClass.kt:0:0:0:0 | valueOf | valueOf(java.lang.String) | final, public, static | Compiler generated | | enumClass.kt:1:1:4:1 | EnumClass | enumClass.kt:0:0:0:0 | values | values() | final, public, static | Compiler generated | | enumClass.kt:1:1:4:1 | EnumClass | enumClass.kt:1:22:1:31 | getV | getV() | final, public | Compiler generated | | enumClass.kt:6:1:16:1 | EnumWithFunctions | enumClass.kt:0:0:0:0 | | () | static | Compiler generated | +| enumClass.kt:6:1:16:1 | EnumWithFunctions | enumClass.kt:0:0:0:0 | getEntries | getEntries() | final, public, static | Compiler generated | | enumClass.kt:6:1:16:1 | EnumWithFunctions | enumClass.kt:0:0:0:0 | valueOf | valueOf(java.lang.String) | final, public, static | Compiler generated | | enumClass.kt:6:1:16:1 | EnumWithFunctions | enumClass.kt:0:0:0:0 | values | values() | final, public, static | Compiler generated | | enumClass.kt:6:1:16:1 | EnumWithFunctions | enumClass.kt:13:12:13:29 | f | f(int) | abstract, public | |