diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index 4ff255a0fd1..a318528010f 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -53,6 +53,8 @@ import org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaClass import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.util.OperatorNameConventions +import org.jetbrains.kotlin.psi.psiUtil.endOffset +import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull open class KotlinFileExtractor( @@ -82,6 +84,8 @@ open class KotlinFileExtractor( val usesK2 = usesK2(pluginContext) val metaAnnotationSupport = MetaAnnotationSupport(logger, pluginContext, this) + private var currentIrFile: IrFile? = null + private inline fun with(kind: String, element: IrElement, f: () -> T): T { val name = when (element) { @@ -108,7 +112,9 @@ open class KotlinFileExtractor( fun extractFileContents(file: IrFile, id: Label) { with("file", file) { - val locId = tw.getWholeFileLocation() + currentIrFile = file + try { + val locId = tw.getWholeFileLocation() val pkg = file.packageFqName.asString() val pkgId = extractPackage(pkg) tw.writeHasLocation(id, locId) @@ -158,6 +164,9 @@ open class KotlinFileExtractor( linesOfCode?.linesOfCodeInFile(id) externalClassExtractor.writeStubTrapFile(file) + } finally { + currentIrFile = null + } } } @@ -672,7 +681,8 @@ open class KotlinFileExtractor( val stmtId = tw.getFreshIdLabel() tw.writeStmts_localtypedeclstmt(stmtId, parent, idx, callable) tw.writeIsLocalClassOrInterface(id, stmtId) - val locId = tw.getLocation(locElement) + val locId = if (usesK2) getPsiBasedLocation(locElement) ?: tw.getLocation(locElement) + else tw.getLocation(locElement) tw.writeHasLocation(stmtId, locId) } @@ -691,7 +701,8 @@ open class KotlinFileExtractor( ) tw.writeMethodsKotlinType(obinitId, returnType.kotlinResult.id) - val locId = tw.getLocation(c) + val locId = if (usesK2) getPsiBasedLocation(c) ?: tw.getLocation(c) + else tw.getLocation(c) tw.writeHasLocation(obinitId, locId) addModifiers(obinitId, "private") @@ -954,7 +965,8 @@ open class KotlinFileExtractor( } } - val locId = tw.getLocation(c) + val locId = if (usesK2) getPsiBasedLocation(c) ?: tw.getLocation(c) + else tw.getLocation(c) tw.writeHasLocation(id, locId) extractEnclosingClass(c.parent, id, c, locId, listOf()) @@ -2435,6 +2447,7 @@ open class KotlinFileExtractor( val locId = overriddenAttributes?.sourceLoc + ?: (if (usesK2) getPsiBasedLocation(f) else null) ?: getLocation(f, classTypeArgsIncludingOuterClasses) if (f.symbol is IrConstructorSymbol) { @@ -2644,7 +2657,9 @@ open class KotlinFileExtractor( DeclarationStackAdjuster(p).use { val id = useProperty(p, parentId, classTypeArgsIncludingOuterClasses) - val locId = getLocation(p, classTypeArgsIncludingOuterClasses) + val locId = + if (usesK2) getPsiBasedLocation(p) ?: getLocation(p, classTypeArgsIncludingOuterClasses) + else getLocation(p, classTypeArgsIncludingOuterClasses) tw.writeKtProperties(id, p.name.asString()) tw.writeHasLocation(id, locId) @@ -2874,6 +2889,16 @@ open class KotlinFileExtractor( return v } + private fun getPsiBasedLocation(element: IrElement): Label? { + val file = currentIrFile ?: return null + val psi2Ir = getPsi2Ir() ?: return null + val psiElement = psi2Ir.findPsiElement(element, file) ?: return null + return tw.getLocation(psiElement.startOffset, psiElement.endOffset) + } + + private fun getPsiBasedLocation(decl: IrDeclaration): Label? = + getPsiBasedLocation(decl as IrElement) + private fun extractVariable( v: IrVariable, callable: Label, @@ -2882,7 +2907,7 @@ open class KotlinFileExtractor( ) { with("variable", v) { val stmtId = tw.getFreshIdLabel() - val locId = tw.getLocation(getVariableLocationProvider(v)) + val locId = getPsiBasedLocation(v) ?: tw.getLocation(getVariableLocationProvider(v)) tw.writeStmts_localvariabledeclstmt(stmtId, parent, idx, callable) tw.writeHasLocation(stmtId, locId) extractVariableExpr(v, callable, stmtId, 1, stmtId) @@ -2900,7 +2925,7 @@ open class KotlinFileExtractor( with("variable expr", v) { val varId = useVariable(v) val exprId = tw.getFreshIdLabel() - val locId = tw.getLocation(getVariableLocationProvider(v)) + val locId = getPsiBasedLocation(v) ?: tw.getLocation(getVariableLocationProvider(v)) val type = useType(v.type) tw.writeLocalvars(varId, v.name.asString(), type.javaResult.id, exprId) tw.writeLocalvarsKotlinType(varId, type.kotlinResult.id) @@ -2972,7 +2997,7 @@ open class KotlinFileExtractor( } is IrLocalDelegatedProperty -> { val blockId = tw.getFreshIdLabel() - val locId = tw.getLocation(s) + val locId = getPsiBasedLocation(s) ?: tw.getLocation(s) tw.writeStmts_block(blockId, parent, idx, callable) tw.writeHasLocation(blockId, locId) // For Kotlin < 2.3, s.delegate is not-nullable, but for Kotlin >= 2.3 @@ -6087,7 +6112,7 @@ open class KotlinFileExtractor( extractVariableAccess( useValueDeclaration(owner), extractType, - tw.getLocation(e), + getPsiBasedLocation(e) ?: tw.getLocation(e), exprParent.parent, exprParent.idx, callable, @@ -6301,7 +6326,7 @@ open class KotlinFileExtractor( ) id } - val locId = tw.getLocation(e) + val locId = getPsiBasedLocation(e) ?: tw.getLocation(e) tw.writeExprsKotlinType(id, type.kotlinResult.id) extractExprContext(id, locId, callable, exprParent.enclosingStmt) @@ -6329,7 +6354,7 @@ open class KotlinFileExtractor( val exprParent = parent.expr(e, callable) val id = tw.getFreshIdLabel() val type = useType(e.type) - val locId = tw.getLocation(e) + val locId = getPsiBasedLocation(e) ?: tw.getLocation(e) tw.writeExprs_whenexpr( id, type.javaResult.id, @@ -6343,7 +6368,7 @@ open class KotlinFileExtractor( } e.branches.forEachIndexed { i, b -> val bId = tw.getFreshIdLabel() - val bLocId = tw.getLocation(b) + val bLocId = getPsiBasedLocation(b) ?: tw.getLocation(b) tw.writeStmts_whenbranch(bId, id, i, callable) tw.writeHasLocation(bId, bLocId) extractExpressionExpr(b.condition, callable, bId, 0, bId) @@ -6450,7 +6475,7 @@ open class KotlinFileExtractor( **/ val ids = getLocallyVisibleFunctionLabels(e.function) - val locId = tw.getLocation(e) + val locId = getPsiBasedLocation(e) ?: tw.getLocation(e) val ext = e.function.codeQlExtensionReceiverParameter val parameters = @@ -6571,7 +6596,7 @@ open class KotlinFileExtractor( callable: Label ) { val id = tw.getFreshIdLabel() - val locId = tw.getLocation(e) + val locId = getPsiBasedLocation(e) ?: tw.getLocation(e) tw.writeStmts_block(id, parent, idx, callable) tw.writeHasLocation(id, locId) statements.forEachIndexed { i, s -> extractStatement(s, callable, id, i) } @@ -6635,7 +6660,7 @@ open class KotlinFileExtractor( callable: Label ) { val containingDeclaration = declarationStack.peek().first - val locId = tw.getLocation(e) + val locId = getPsiBasedLocation(e) ?: tw.getLocation(e) if ( containingDeclaration.shouldExtractAsStatic && @@ -7002,7 +7027,7 @@ open class KotlinFileExtractor( v is String -> { exprIdOrFresh(overrideId).also { id -> val type = useType(e.type) - val locId = tw.getLocation(e) + val locId = getPsiBasedLocation(e) ?: tw.getLocation(e) tw.writeExprs_stringliteral(id, type.javaResult.id, parent, idx) tw.writeExprsKotlinType(id, type.kotlinResult.id) extractExprContext(id, locId, enclosingCallable, enclosingStmt) diff --git a/java/ql/test-kotlin1/library-tests/annotation_classes/PrintAst.expected b/java/ql/test-kotlin1/library-tests/annotation_classes/PrintAst.expected index 0d42d2732c9..f5c40e4a92b 100644 --- a/java/ql/test-kotlin1/library-tests/annotation_classes/PrintAst.expected +++ b/java/ql/test-kotlin1/library-tests/annotation_classes/PrintAst.expected @@ -72,7 +72,7 @@ def.kt: # 57| 0: [AssignExpr] ...=... # 57| 0: [VarAccess] DefKt.p # 57| -1: [TypeAccess] DefKt -# 57| 1: [VarAccess] +# 53| 1: [VarAccess] # 59| 6: [ExtensionMethod] myExtension # 59| 3: [TypeAccess] Unit #-----| 4: (Parameters) diff --git a/java/ql/test-kotlin1/library-tests/classes/genericExprTypes.expected b/java/ql/test-kotlin1/library-tests/classes/genericExprTypes.expected index b350fd8d7bb..135d88fafd1 100644 --- a/java/ql/test-kotlin1/library-tests/classes/genericExprTypes.expected +++ b/java/ql/test-kotlin1/library-tests/classes/genericExprTypes.expected @@ -9,10 +9,10 @@ | generic_anonymous.kt:3:3:5:3 | ...=... | new Object(...) { ... } | | generic_anonymous.kt:3:3:5:3 | T | T | | generic_anonymous.kt:3:3:5:3 | new Object(...) { ... } | new Object(...) { ... } | +| generic_anonymous.kt:3:3:5:3 | this | Generic | | generic_anonymous.kt:3:3:5:3 | x | new Object(...) { ... } | | generic_anonymous.kt:3:11:5:3 | T | T | | generic_anonymous.kt:3:11:5:3 | new Object(...) { ... } | new Object(...) { ... } | -| generic_anonymous.kt:3:11:5:3 | this | Generic | | generic_anonymous.kt:3:11:5:3 | this.x | new Object(...) { ... } | | generic_anonymous.kt:3:19:5:3 | | new Object(...) { ... } | | generic_anonymous.kt:3:19:5:3 | Object | Object | diff --git a/java/ql/test-kotlin1/library-tests/compilation-units/cus.expected b/java/ql/test-kotlin1/library-tests/compilation-units/cus.expected index 6a09d9908c3..97b688e8795 100644 --- a/java/ql/test-kotlin1/library-tests/compilation-units/cus.expected +++ b/java/ql/test-kotlin1/library-tests/compilation-units/cus.expected @@ -2,8 +2,6 @@ | AbstractList$RandomAccessSpliterator | .../AbstractList$RandomAccessSpliterator.class:0:0:0:0 | | ArrayList | .../ArrayList.class:0:0:0:0 | | ArrayList$ArrayListSpliterator | .../ArrayList$ArrayListSpliterator.class:0:0:0:0 | -| CleanerImpl$CleanableList | .../CleanerImpl$CleanableList.class:0:0:0:0 | -| CleanerImpl$CleanableList$Node | .../CleanerImpl$CleanableList$Node.class:0:0:0:0 | | List | .../List.class:0:0:0:0 | | ListIterator | .../ListIterator.class:0:0:0:0 | | MemorySessionImpl$ResourceList | .../MemorySessionImpl$ResourceList.class:0:0:0:0 | diff --git a/java/ql/test-kotlin1/library-tests/controlflow/basic/bbStmts.expected b/java/ql/test-kotlin1/library-tests/controlflow/basic/bbStmts.expected index a3c7b11eb21..61d80537663 100644 --- a/java/ql/test-kotlin1/library-tests/controlflow/basic/bbStmts.expected +++ b/java/ql/test-kotlin1/library-tests/controlflow/basic/bbStmts.expected @@ -315,7 +315,7 @@ | Test.kt:105:5:109:5 | After when ... | 2 | Test.kt:100:25:110:1 | After { ... } | | Test.kt:105:5:109:5 | After when ... | 3 | Test.kt:100:1:110:1 | Normal Exit | | Test.kt:105:9:105:17 | After ... (value not-equals) ... [false] | 0 | Test.kt:105:9:105:17 | After ... (value not-equals) ... [false] | -| Test.kt:105:9:105:17 | After ... (value not-equals) ... [false] | 1 | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:105:9:105:17 | After ... (value not-equals) ... [false] | 1 | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:105:9:105:17 | After ... (value not-equals) ... [false] | 2 | Test.kt:107:16:107:24 | Before ... (value not-equals) ... | | Test.kt:105:9:105:17 | After ... (value not-equals) ... [false] | 3 | Test.kt:107:16:107:16 | y | | Test.kt:105:9:105:17 | After ... (value not-equals) ... [false] | 4 | Test.kt:107:21:107:24 | null | diff --git a/java/ql/test-kotlin1/library-tests/controlflow/basic/bbStrictDominance.expected b/java/ql/test-kotlin1/library-tests/controlflow/basic/bbStrictDominance.expected index 4e66ae0cd04..64f10738cfe 100644 --- a/java/ql/test-kotlin1/library-tests/controlflow/basic/bbStrictDominance.expected +++ b/java/ql/test-kotlin1/library-tests/controlflow/basic/bbStrictDominance.expected @@ -49,14 +49,14 @@ | Test.kt:100:25:110:1 | { ... } | Test.kt:101:33:103:5 | { ... } | | Test.kt:100:25:110:1 | { ... } | Test.kt:105:5:109:5 | ; | | Test.kt:100:25:110:1 | { ... } | Test.kt:105:20:107:5 | { ... } | -| Test.kt:100:25:110:1 | { ... } | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:100:25:110:1 | { ... } | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:100:25:110:1 | { ... } | Test.kt:107:27:109:5 | { ... } | | Test.kt:101:22:101:22 | y | Test.kt:101:33:103:5 | { ... } | | Test.kt:105:5:109:5 | ; | Test.kt:100:1:110:1 | Normal Exit | | Test.kt:105:5:109:5 | ; | Test.kt:105:20:107:5 | { ... } | -| Test.kt:105:5:109:5 | ; | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:105:5:109:5 | ; | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:105:5:109:5 | ; | Test.kt:107:27:109:5 | { ... } | -| Test.kt:107:16:109:5 | ... -> ... | Test.kt:107:27:109:5 | { ... } | +| Test.kt:107:12:109:5 | ... -> ... | Test.kt:107:27:109:5 | { ... } | | Test.kt:112:32:116:1 | { ... } | Test.kt:112:1:116:1 | Normal Exit | | Test.kt:112:32:116:1 | { ... } | Test.kt:113:14:113:14 | y | | Test.kt:112:32:116:1 | { ... } | Test.kt:113:17:115:5 | { ... } | diff --git a/java/ql/test-kotlin1/library-tests/controlflow/basic/bbSuccessor.expected b/java/ql/test-kotlin1/library-tests/controlflow/basic/bbSuccessor.expected index 25b51acefc4..17a8ce76978 100644 --- a/java/ql/test-kotlin1/library-tests/controlflow/basic/bbSuccessor.expected +++ b/java/ql/test-kotlin1/library-tests/controlflow/basic/bbSuccessor.expected @@ -39,11 +39,11 @@ | Test.kt:101:22:101:30 | After ... (value equals) ... [false] | Test.kt:105:5:109:5 | ; | | Test.kt:101:33:103:5 | { ... } | Test.kt:100:1:110:1 | Exit | | Test.kt:105:5:109:5 | ; | Test.kt:105:20:107:5 | { ... } | -| Test.kt:105:5:109:5 | ; | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:105:5:109:5 | ; | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:105:20:107:5 | { ... } | Test.kt:100:1:110:1 | Normal Exit | +| Test.kt:107:12:109:5 | ... -> ... | Test.kt:107:16:107:24 | After ... (value not-equals) ... [false] | +| Test.kt:107:12:109:5 | ... -> ... | Test.kt:107:27:109:5 | { ... } | | Test.kt:107:16:107:24 | After ... (value not-equals) ... [false] | Test.kt:100:1:110:1 | Normal Exit | -| Test.kt:107:16:109:5 | ... -> ... | Test.kt:107:16:107:24 | After ... (value not-equals) ... [false] | -| Test.kt:107:16:109:5 | ... -> ... | Test.kt:107:27:109:5 | { ... } | | Test.kt:107:27:109:5 | { ... } | Test.kt:100:1:110:1 | Normal Exit | | Test.kt:112:32:116:1 | { ... } | Test.kt:113:9:113:9 | After x [false] | | Test.kt:112:32:116:1 | { ... } | Test.kt:113:14:113:14 | y | diff --git a/java/ql/test-kotlin1/library-tests/controlflow/basic/getASuccessor.expected b/java/ql/test-kotlin1/library-tests/controlflow/basic/getASuccessor.expected index 291c07f6857..5f4663d14b5 100644 --- a/java/ql/test-kotlin1/library-tests/controlflow/basic/getASuccessor.expected +++ b/java/ql/test-kotlin1/library-tests/controlflow/basic/getASuccessor.expected @@ -184,17 +184,17 @@ | Test.kt:105:5:109:5 | when ... | WhenExpr | Test.kt:105:9:107:5 | ... -> ... | WhenBranch | | Test.kt:105:9:105:9 | x | VarAccess | Test.kt:105:14:105:17 | null | NullLiteral | | Test.kt:105:9:105:17 | ... (value not-equals) ... | ValueNEExpr | Test.kt:105:20:107:5 | { ... } | BlockStmt | -| Test.kt:105:9:105:17 | ... (value not-equals) ... | ValueNEExpr | Test.kt:107:16:109:5 | ... -> ... | WhenBranch | +| Test.kt:105:9:105:17 | ... (value not-equals) ... | ValueNEExpr | Test.kt:107:12:109:5 | ... -> ... | WhenBranch | | Test.kt:105:9:107:5 | ... -> ... | WhenBranch | Test.kt:105:9:105:9 | x | VarAccess | | Test.kt:105:14:105:17 | null | NullLiteral | Test.kt:105:9:105:17 | ... (value not-equals) ... | ValueNEExpr | | Test.kt:105:20:107:5 | { ... } | BlockStmt | Test.kt:106:9:106:29 | ; | ExprStmt | | Test.kt:106:9:106:29 | ; | ExprStmt | Test.kt:106:17:106:28 | "x not null" | StringLiteral | | Test.kt:106:9:106:29 | println(...) | MethodCall | Test.kt:100:1:110:1 | Normal Exit | Method | | Test.kt:106:17:106:28 | "x not null" | StringLiteral | Test.kt:106:9:106:29 | println(...) | MethodCall | +| Test.kt:107:12:109:5 | ... -> ... | WhenBranch | Test.kt:107:16:107:16 | y | VarAccess | | Test.kt:107:16:107:16 | y | VarAccess | Test.kt:107:21:107:24 | null | NullLiteral | | Test.kt:107:16:107:24 | ... (value not-equals) ... | ValueNEExpr | Test.kt:100:1:110:1 | Normal Exit | Method | | Test.kt:107:16:107:24 | ... (value not-equals) ... | ValueNEExpr | Test.kt:107:27:109:5 | { ... } | BlockStmt | -| Test.kt:107:16:109:5 | ... -> ... | WhenBranch | Test.kt:107:16:107:16 | y | VarAccess | | Test.kt:107:21:107:24 | null | NullLiteral | Test.kt:107:16:107:24 | ... (value not-equals) ... | ValueNEExpr | | Test.kt:107:27:109:5 | { ... } | BlockStmt | Test.kt:108:9:108:29 | ; | ExprStmt | | Test.kt:108:9:108:29 | ; | ExprStmt | Test.kt:108:17:108:28 | "y not null" | StringLiteral | diff --git a/java/ql/test-kotlin1/library-tests/controlflow/basic/strictDominance.expected b/java/ql/test-kotlin1/library-tests/controlflow/basic/strictDominance.expected index 13d018efabd..70846d8964d 100644 --- a/java/ql/test-kotlin1/library-tests/controlflow/basic/strictDominance.expected +++ b/java/ql/test-kotlin1/library-tests/controlflow/basic/strictDominance.expected @@ -496,7 +496,7 @@ | Test.kt:100:25:110:1 | { ... } | Test.kt:105:9:107:5 | ... -> ... | | Test.kt:100:25:110:1 | { ... } | Test.kt:105:20:107:5 | { ... } | | Test.kt:100:25:110:1 | { ... } | Test.kt:106:9:106:29 | ; | -| Test.kt:100:25:110:1 | { ... } | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:100:25:110:1 | { ... } | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:100:25:110:1 | { ... } | Test.kt:107:27:109:5 | { ... } | | Test.kt:100:25:110:1 | { ... } | Test.kt:108:9:108:29 | ; | | Test.kt:101:5:103:5 | ... -> ... | Test.kt:101:33:103:5 | { ... } | @@ -505,7 +505,7 @@ | Test.kt:101:5:103:5 | ... -> ... | Test.kt:105:9:107:5 | ... -> ... | | Test.kt:101:5:103:5 | ... -> ... | Test.kt:105:20:107:5 | { ... } | | Test.kt:101:5:103:5 | ... -> ... | Test.kt:106:9:106:29 | ; | -| Test.kt:101:5:103:5 | ... -> ... | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:101:5:103:5 | ... -> ... | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:101:5:103:5 | ... -> ... | Test.kt:107:27:109:5 | { ... } | | Test.kt:101:5:103:5 | ... -> ... | Test.kt:108:9:108:29 | ; | | Test.kt:101:5:103:5 | ; | Test.kt:101:5:103:5 | ... -> ... | @@ -515,24 +515,24 @@ | Test.kt:101:5:103:5 | ; | Test.kt:105:9:107:5 | ... -> ... | | Test.kt:101:5:103:5 | ; | Test.kt:105:20:107:5 | { ... } | | Test.kt:101:5:103:5 | ; | Test.kt:106:9:106:29 | ; | -| Test.kt:101:5:103:5 | ; | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:101:5:103:5 | ; | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:101:5:103:5 | ; | Test.kt:107:27:109:5 | { ... } | | Test.kt:101:5:103:5 | ; | Test.kt:108:9:108:29 | ; | | Test.kt:101:33:103:5 | { ... } | Test.kt:102:9:102:25 | throw ... | | Test.kt:105:5:109:5 | ; | Test.kt:105:9:107:5 | ... -> ... | | Test.kt:105:5:109:5 | ; | Test.kt:105:20:107:5 | { ... } | | Test.kt:105:5:109:5 | ; | Test.kt:106:9:106:29 | ; | -| Test.kt:105:5:109:5 | ; | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:105:5:109:5 | ; | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:105:5:109:5 | ; | Test.kt:107:27:109:5 | { ... } | | Test.kt:105:5:109:5 | ; | Test.kt:108:9:108:29 | ; | | Test.kt:105:9:107:5 | ... -> ... | Test.kt:105:20:107:5 | { ... } | | Test.kt:105:9:107:5 | ... -> ... | Test.kt:106:9:106:29 | ; | -| Test.kt:105:9:107:5 | ... -> ... | Test.kt:107:16:109:5 | ... -> ... | +| Test.kt:105:9:107:5 | ... -> ... | Test.kt:107:12:109:5 | ... -> ... | | Test.kt:105:9:107:5 | ... -> ... | Test.kt:107:27:109:5 | { ... } | | Test.kt:105:9:107:5 | ... -> ... | Test.kt:108:9:108:29 | ; | | Test.kt:105:20:107:5 | { ... } | Test.kt:106:9:106:29 | ; | -| Test.kt:107:16:109:5 | ... -> ... | Test.kt:107:27:109:5 | { ... } | -| Test.kt:107:16:109:5 | ... -> ... | Test.kt:108:9:108:29 | ; | +| Test.kt:107:12:109:5 | ... -> ... | Test.kt:107:27:109:5 | { ... } | +| Test.kt:107:12:109:5 | ... -> ... | Test.kt:108:9:108:29 | ; | | Test.kt:107:27:109:5 | { ... } | Test.kt:108:9:108:29 | ; | | Test.kt:112:32:116:1 | { ... } | Test.kt:113:5:115:5 | ... -> ... | | Test.kt:112:32:116:1 | { ... } | Test.kt:113:5:115:5 | ; | diff --git a/java/ql/test-kotlin1/library-tests/java-kotlin-collection-type-generic-methods/test.expected b/java/ql/test-kotlin1/library-tests/java-kotlin-collection-type-generic-methods/test.expected index a55e73e283f..cc941f0c44b 100644 --- a/java/ql/test-kotlin1/library-tests/java-kotlin-collection-type-generic-methods/test.expected +++ b/java/ql/test-kotlin1/library-tests/java-kotlin-collection-type-generic-methods/test.expected @@ -16,6 +16,14 @@ methodWithDuplicate | AbstractCollection | removeAll | Collection | | AbstractCollection | retainAll | Collection | | AbstractCollection | toArray | T[] | +| AbstractCollection | add | Runnable | +| AbstractCollection | addAll | Collection | +| AbstractCollection | contains | Object | +| AbstractCollection | containsAll | Collection | +| AbstractCollection | remove | Object | +| AbstractCollection | removeAll | Collection | +| AbstractCollection | retainAll | Collection | +| AbstractCollection | toArray | T[] | | AbstractCollection | add | String | | AbstractCollection | addAll | Collection | | AbstractCollection | contains | Object | @@ -71,14 +79,14 @@ methodWithDuplicate | AbstractMap | put | V | | AbstractMap | putAll | Map | | AbstractMap | remove | Object | -| AbstractMap | containsKey | Object | -| AbstractMap | containsValue | Object | -| AbstractMap | equals | Object | -| AbstractMap | get | Object | -| AbstractMap | put | Identity | -| AbstractMap | put | Object | -| AbstractMap | putAll | Map | -| AbstractMap | remove | Object | +| AbstractMap> | containsKey | Object | +| AbstractMap> | containsValue | Object | +| AbstractMap> | equals | Object | +| AbstractMap> | get | Object | +| AbstractMap> | put | Entry | +| AbstractMap> | put | Identity | +| AbstractMap> | putAll | Map> | +| AbstractMap> | remove | Object | | AbstractMap | containsKey | Object | | AbstractMap | containsValue | Object | | AbstractMap | equals | Object | @@ -147,6 +155,17 @@ methodWithDuplicate | Collection | retainAll | Collection | | Collection | toArray | IntFunction | | Collection | toArray | T[] | +| Collection | add | Runnable | +| Collection | addAll | Collection | +| Collection | contains | Object | +| Collection | containsAll | Collection | +| Collection | equals | Object | +| Collection | remove | Object | +| Collection | removeAll | Collection | +| Collection | removeIf | Predicate | +| Collection | retainAll | Collection | +| Collection | toArray | IntFunction | +| Collection | toArray | T[] | | Collection | add | String | | Collection | addAll | Collection | | Collection | contains | Object | @@ -196,8 +215,6 @@ methodWithDuplicate | List | listIterator | int | | List | of | E | | List | of | E[] | -| List | ofLazy | IntFunction | -| List | ofLazy | int | | List | remove | Object | | List | remove | int | | List | removeAll | Collection | @@ -224,8 +241,6 @@ methodWithDuplicate | List | listIterator | int | | List | of | E | | List | of | E[] | -| List | ofLazy | IntFunction | -| List | ofLazy | int | | List | remove | Object | | List | remove | int | | List | removeAll | Collection | @@ -252,8 +267,6 @@ methodWithDuplicate | List | listIterator | int | | List | of | E | | List | of | E[] | -| List | ofLazy | IntFunction | -| List | ofLazy | int | | List | remove | Object | | List | remove | int | | List | removeAll | Collection | @@ -286,8 +299,6 @@ methodWithDuplicate | Map | of | K | | Map | of | V | | Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | | Map | put | K | | Map | put | V | | Map | putAll | Map | @@ -297,38 +308,37 @@ methodWithDuplicate | Map | replace | K | | Map | replace | V | | Map | replaceAll | BiFunction | -| Map | compute | BiFunction | -| Map | compute | Identity | -| Map | computeIfAbsent | Function | -| Map | computeIfAbsent | Identity | -| Map | computeIfPresent | BiFunction | -| Map | computeIfPresent | Identity | -| Map | containsKey | Object | -| Map | containsValue | Object | -| Map | copyOf | Map | -| Map | entry | K | -| Map | entry | V | -| Map | equals | Object | -| Map | forEach | BiConsumer | -| Map | get | Object | -| Map | getOrDefault | Object | -| Map | merge | BiFunction | -| Map | merge | Identity | -| Map | merge | Object | -| Map | of | K | -| Map | of | V | -| Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | -| Map | put | Identity | -| Map | put | Object | -| Map | putAll | Map | -| Map | putIfAbsent | Identity | -| Map | putIfAbsent | Object | -| Map | remove | Object | -| Map | replace | Identity | -| Map | replace | Object | -| Map | replaceAll | BiFunction | +| Map> | compute | BiFunction,? extends Entry> | +| Map> | compute | Identity | +| Map> | computeIfAbsent | Function> | +| Map> | computeIfAbsent | Identity | +| Map> | computeIfPresent | BiFunction,? extends Entry> | +| Map> | computeIfPresent | Identity | +| Map> | containsKey | Object | +| Map> | containsValue | Object | +| Map> | copyOf | Map | +| Map> | entry | K | +| Map> | entry | V | +| Map> | equals | Object | +| Map> | forEach | BiConsumer> | +| Map> | get | Object | +| Map> | getOrDefault | Entry | +| Map> | getOrDefault | Object | +| Map> | merge | BiFunction,? super Entry,? extends Entry> | +| Map> | merge | Entry | +| Map> | merge | Identity | +| Map> | of | K | +| Map> | of | V | +| Map> | ofEntries | Entry[] | +| Map> | put | Entry | +| Map> | put | Identity | +| Map> | putAll | Map> | +| Map> | putIfAbsent | Entry | +| Map> | putIfAbsent | Identity | +| Map> | remove | Object | +| Map> | replace | Entry | +| Map> | replace | Identity | +| Map> | replaceAll | BiFunction,? extends Entry> | | Map | compute | BiFunction | | Map | compute | K | | Map | computeIfAbsent | Function | @@ -351,8 +361,6 @@ methodWithDuplicate | Map | of | K | | Map | of | V | | Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | | Map | put | K | | Map | put | V | | Map | putAll | Map | @@ -382,8 +390,6 @@ methodWithDuplicate | Map | of | K | | Map | of | V | | Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | | Map | put | Object | | Map | putAll | Map | | Map | putIfAbsent | Object | @@ -411,8 +417,6 @@ methodWithDuplicate | Map | of | K | | Map | of | V | | Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | | Map | put | String | | Map | putAll | Map | | Map | putIfAbsent | String | diff --git a/java/ql/test-kotlin1/library-tests/reflection/reflection.expected b/java/ql/test-kotlin1/library-tests/reflection/reflection.expected index 3bc2f9ce67d..7ce456cdcbb 100644 --- a/java/ql/test-kotlin1/library-tests/reflection/reflection.expected +++ b/java/ql/test-kotlin1/library-tests/reflection/reflection.expected @@ -289,7 +289,6 @@ compGenerated | file:///LongProgression.class:0:0:0:0 | spliterator | Forwarder for a Kotlin class inheriting an interface default method | | file:///LongRange.class:0:0:0:0 | forEach | Forwarder for a Kotlin class inheriting an interface default method | | file:///LongRange.class:0:0:0:0 | spliterator | Forwarder for a Kotlin class inheriting an interface default method | -| file:///String.class:0:0:0:0 | getChars | Forwarder for a Kotlin class inheriting an interface default method | | file:///String.class:0:0:0:0 | isEmpty | Forwarder for a Kotlin class inheriting an interface default method | | reflection.kt:7:49:7:54 | new Function2(...) { ... } | The class around a local function, a lambda, or a function reference | | reflection.kt:10:38:10:42 | new KProperty1(...) { ... } | The class around a local function, a lambda, or a function reference | diff --git a/java/ql/test-kotlin2/library-tests/compilation-units/cus.expected b/java/ql/test-kotlin2/library-tests/compilation-units/cus.expected index 6a09d9908c3..97b688e8795 100644 --- a/java/ql/test-kotlin2/library-tests/compilation-units/cus.expected +++ b/java/ql/test-kotlin2/library-tests/compilation-units/cus.expected @@ -2,8 +2,6 @@ | AbstractList$RandomAccessSpliterator | .../AbstractList$RandomAccessSpliterator.class:0:0:0:0 | | ArrayList | .../ArrayList.class:0:0:0:0 | | ArrayList$ArrayListSpliterator | .../ArrayList$ArrayListSpliterator.class:0:0:0:0 | -| CleanerImpl$CleanableList | .../CleanerImpl$CleanableList.class:0:0:0:0 | -| CleanerImpl$CleanableList$Node | .../CleanerImpl$CleanableList$Node.class:0:0:0:0 | | List | .../List.class:0:0:0:0 | | ListIterator | .../ListIterator.class:0:0:0:0 | | MemorySessionImpl$ResourceList | .../MemorySessionImpl$ResourceList.class:0:0:0:0 | diff --git a/java/ql/test-kotlin2/library-tests/java-kotlin-collection-type-generic-methods/test.expected b/java/ql/test-kotlin2/library-tests/java-kotlin-collection-type-generic-methods/test.expected index 3237c89c8c7..eba4613fba5 100644 --- a/java/ql/test-kotlin2/library-tests/java-kotlin-collection-type-generic-methods/test.expected +++ b/java/ql/test-kotlin2/library-tests/java-kotlin-collection-type-generic-methods/test.expected @@ -16,6 +16,14 @@ methodWithDuplicate | AbstractCollection | removeAll | Collection | | AbstractCollection | retainAll | Collection | | AbstractCollection | toArray | T[] | +| AbstractCollection | add | Runnable | +| AbstractCollection | addAll | Collection | +| AbstractCollection | contains | Object | +| AbstractCollection | containsAll | Collection | +| AbstractCollection | remove | Object | +| AbstractCollection | removeAll | Collection | +| AbstractCollection | retainAll | Collection | +| AbstractCollection | toArray | T[] | | AbstractCollection | add | String | | AbstractCollection | addAll | Collection | | AbstractCollection | contains | Object | @@ -71,14 +79,14 @@ methodWithDuplicate | AbstractMap | put | V | | AbstractMap | putAll | Map | | AbstractMap | remove | Object | -| AbstractMap | containsKey | Object | -| AbstractMap | containsValue | Object | -| AbstractMap | equals | Object | -| AbstractMap | get | Object | -| AbstractMap | put | Identity | -| AbstractMap | put | Object | -| AbstractMap | putAll | Map | -| AbstractMap | remove | Object | +| AbstractMap> | containsKey | Object | +| AbstractMap> | containsValue | Object | +| AbstractMap> | equals | Object | +| AbstractMap> | get | Object | +| AbstractMap> | put | Entry | +| AbstractMap> | put | Identity | +| AbstractMap> | putAll | Map> | +| AbstractMap> | remove | Object | | AbstractMap | containsKey | Object | | AbstractMap | containsValue | Object | | AbstractMap | equals | Object | @@ -144,6 +152,16 @@ methodWithDuplicate | Collection | retainAll | Collection | | Collection | toArray | IntFunction | | Collection | toArray | T[] | +| Collection | add | Runnable | +| Collection | addAll | Collection | +| Collection | contains | Object | +| Collection | containsAll | Collection | +| Collection | remove | Object | +| Collection | removeAll | Collection | +| Collection | removeIf | Predicate | +| Collection | retainAll | Collection | +| Collection | toArray | IntFunction | +| Collection | toArray | T[] | | Collection | add | String | | Collection | addAll | Collection | | Collection | contains | Object | @@ -191,8 +209,6 @@ methodWithDuplicate | List | listIterator | int | | List | of | E | | List | of | E[] | -| List | ofLazy | IntFunction | -| List | ofLazy | int | | List | remove | Object | | List | remove | int | | List | removeAll | Collection | @@ -218,8 +234,6 @@ methodWithDuplicate | List | listIterator | int | | List | of | E | | List | of | E[] | -| List | ofLazy | IntFunction | -| List | ofLazy | int | | List | remove | Object | | List | remove | int | | List | removeAll | Collection | @@ -246,8 +260,6 @@ methodWithDuplicate | List | listIterator | int | | List | of | E | | List | of | E[] | -| List | ofLazy | IntFunction | -| List | ofLazy | int | | List | remove | Object | | List | remove | int | | List | removeAll | Collection | @@ -280,8 +292,6 @@ methodWithDuplicate | Map | of | K | | Map | of | V | | Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | | Map | put | K | | Map | put | V | | Map | putAll | Map | @@ -291,37 +301,36 @@ methodWithDuplicate | Map | replace | K | | Map | replace | V | | Map | replaceAll | BiFunction | -| Map | compute | BiFunction | -| Map | compute | Identity | -| Map | computeIfAbsent | Function | -| Map | computeIfAbsent | Identity | -| Map | computeIfPresent | BiFunction | -| Map | computeIfPresent | Identity | -| Map | containsKey | Object | -| Map | containsValue | Object | -| Map | copyOf | Map | -| Map | entry | K | -| Map | entry | V | -| Map | forEach | BiConsumer | -| Map | get | Object | -| Map | getOrDefault | Object | -| Map | merge | BiFunction | -| Map | merge | Identity | -| Map | merge | Object | -| Map | of | K | -| Map | of | V | -| Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | -| Map | put | Identity | -| Map | put | Object | -| Map | putAll | Map | -| Map | putIfAbsent | Identity | -| Map | putIfAbsent | Object | -| Map | remove | Object | -| Map | replace | Identity | -| Map | replace | Object | -| Map | replaceAll | BiFunction | +| Map> | compute | BiFunction,? extends Entry> | +| Map> | compute | Identity | +| Map> | computeIfAbsent | Function> | +| Map> | computeIfAbsent | Identity | +| Map> | computeIfPresent | BiFunction,? extends Entry> | +| Map> | computeIfPresent | Identity | +| Map> | containsKey | Object | +| Map> | containsValue | Object | +| Map> | copyOf | Map | +| Map> | entry | K | +| Map> | entry | V | +| Map> | forEach | BiConsumer> | +| Map> | get | Object | +| Map> | getOrDefault | Entry | +| Map> | getOrDefault | Object | +| Map> | merge | BiFunction,? super Entry,? extends Entry> | +| Map> | merge | Entry | +| Map> | merge | Identity | +| Map> | of | K | +| Map> | of | V | +| Map> | ofEntries | Entry[] | +| Map> | put | Entry | +| Map> | put | Identity | +| Map> | putAll | Map> | +| Map> | putIfAbsent | Entry | +| Map> | putIfAbsent | Identity | +| Map> | remove | Object | +| Map> | replace | Entry | +| Map> | replace | Identity | +| Map> | replaceAll | BiFunction,? extends Entry> | | Map | compute | BiFunction | | Map | compute | K | | Map | computeIfAbsent | Function | @@ -343,8 +352,6 @@ methodWithDuplicate | Map | of | K | | Map | of | V | | Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | | Map | put | K | | Map | put | V | | Map | putAll | Map | @@ -373,8 +380,6 @@ methodWithDuplicate | Map | of | K | | Map | of | V | | Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | | Map | put | Object | | Map | putAll | Map | | Map | putIfAbsent | Object | @@ -402,8 +407,6 @@ methodWithDuplicate | Map | of | K | | Map | of | V | | Map | ofEntries | Entry[] | -| Map | ofLazy | Function | -| Map | ofLazy | Set | | Map | put | String | | Map | putAll | Map | | Map | putIfAbsent | String | diff --git a/java/ql/test-kotlin2/library-tests/reflection/reflection.expected b/java/ql/test-kotlin2/library-tests/reflection/reflection.expected index 2c0bee11a9e..5ab8541ff95 100644 --- a/java/ql/test-kotlin2/library-tests/reflection/reflection.expected +++ b/java/ql/test-kotlin2/library-tests/reflection/reflection.expected @@ -266,7 +266,6 @@ compGenerated | file:///AccessFlag$Location.class:0:0:0:0 | getEntries | Default property accessor | | file:///AccessFlag.class:0:0:0:0 | getEntries | Default property accessor | | file:///AccessMode.class:0:0:0:0 | getEntries | Default property accessor | -| file:///ByteOrder.class:0:0:0:0 | getEntries | Default property accessor | | file:///CharProgression.class:0:0:0:0 | forEach | Forwarder for a Kotlin class inheriting an interface default method | | file:///CharProgression.class:0:0:0:0 | spliterator | Forwarder for a Kotlin class inheriting an interface default method | | file:///CharRange.class:0:0:0:0 | forEach | Forwarder for a Kotlin class inheriting an interface default method | @@ -330,12 +329,10 @@ compGenerated | file:///SignStyle.class:0:0:0:0 | getEntries | Default property accessor | | file:///StackWalker$ExtendedOption.class:0:0:0:0 | getEntries | Default property accessor | | file:///StackWalker$Option.class:0:0:0:0 | getEntries | Default property accessor | -| file:///String.class:0:0:0:0 | getChars | Forwarder for a Kotlin class inheriting an interface default method | | file:///String.class:0:0:0:0 | isEmpty | Forwarder for a Kotlin class inheriting an interface default method | | file:///TextStyle.class:0:0:0:0 | getEntries | Default property accessor | | file:///Thread$State.class:0:0:0:0 | getEntries | Default property accessor | | file:///TimeUnit.class:0:0:0:0 | getEntries | Default property accessor | -| file:///TypeKind.class:0:0:0:0 | getEntries | Default property accessor | | file:///VarHandle$AccessMode.class:0:0:0:0 | getEntries | Default property accessor | | file:///VarHandle$AccessType.class:0:0:0:0 | getEntries | Default property accessor | | file:///Wrapper.class:0:0:0:0 | getEntries | Default property accessor |