[FIR2IR] Fix NoSuchMethod for Iterator::next (same issue with invoke)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
8e35545e10
commit
37abdb1732
@@ -902,7 +902,7 @@ class Fir2IrVisitor(
|
||||
}
|
||||
val calleeReference = (functionCall.calleeReference as? FirResolvedNamedReference) ?: return functionCall
|
||||
val resolvedSymbol = (calleeReference.resolvedSymbol as? FirNamedFunctionSymbol) ?: return functionCall
|
||||
if (resolvedSymbol.callableId.isInvoke()) {
|
||||
if (resolvedSymbol.callableId.isInvoke() || resolvedSymbol.callableId.isIteratorNext()) {
|
||||
functionCall.calleeReference =
|
||||
buildResolvedNamedReference {
|
||||
source = calleeReference.source
|
||||
|
||||
@@ -470,4 +470,7 @@ fun CallableId.isInvoke() =
|
||||
fun CallableId.isKFunctionInvoke() =
|
||||
callableName.asString() == "invoke"
|
||||
&& className?.asString()?.startsWith("KFunction") == true
|
||||
&& packageName.asString() == "kotlin.reflect"
|
||||
&& packageName.asString() == "kotlin.reflect"
|
||||
|
||||
fun CallableId.isIteratorNext() =
|
||||
callableName.asString() == "next" && className?.asString()?.equals("Iterator") == true && packageName.asString() == "kotlin.collections"
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
fun returnNullable(): String? = null
|
||||
|
||||
inline fun Array<String>.matchAll(fn: (String) -> Unit) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
fun nil() = null
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
// !LANGUAGE: +StrictJavaNullabilityAssertions
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
// FILE: box.kt
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: WithVarargs.java
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: -ProhibitAssigningSingleElementsToVarargsInNamedForm
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
fun box(): String {
|
||||
if (test1(p = 1) != "1") return "fail 1"
|
||||
|
||||
@@ -69,7 +69,7 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
|
||||
$this: GET_VAR 'val tmp_4: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.test3' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:s type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_4: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.test3' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
FUN name:test4 visibility:public modality:FINAL <> (ss:kotlin.collections.List<kotlin.String>?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List<kotlin.String>?
|
||||
@@ -99,7 +99,7 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
|
||||
$this: GET_VAR 'val tmp_7: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.test4' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:s type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_7: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.test4' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
FUN name:test5 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ FILE fqName:<root> fileName:/for.kt
|
||||
$this: GET_VAR 'val tmp_1: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testEmpty' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:s type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_1: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testEmpty' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
FUN name:testIterable visibility:public modality:FINAL <> (ss:kotlin.collections.List<kotlin.String>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List<kotlin.String>
|
||||
@@ -27,7 +27,7 @@ FILE fqName:<root> fileName:/for.kt
|
||||
$this: GET_VAR 'val tmp_3: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testIterable' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:s type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_3: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testIterable' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null
|
||||
message: GET_VAR 'val s: kotlin.String [val] declared in <root>.testIterable' type=kotlin.String origin=null
|
||||
@@ -44,7 +44,7 @@ FILE fqName:<root> fileName:/for.kt
|
||||
$this: GET_VAR 'val tmp_5: kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> [val] declared in <root>.testDestructuring' type=kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.Pair<kotlin.Int, kotlin.String> [val]
|
||||
CALL 'public abstract fun next (): kotlin.Pair<kotlin.Int, kotlin.String> [operator] declared in kotlin.collections.Iterator' type=kotlin.Pair<kotlin.Int, kotlin.String> origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.Pair<kotlin.Int, kotlin.String> origin=null
|
||||
$this: GET_VAR 'val tmp_5: kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> [val] declared in <root>.testDestructuring' type=kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> origin=null
|
||||
VAR name:i type:kotlin.Int [val]
|
||||
CALL 'public final fun component1 (): kotlin.Int [operator] declared in kotlin.Pair' type=kotlin.Int origin=null
|
||||
|
||||
@@ -12,7 +12,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
||||
$this: GET_VAR 'val tmp_1: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForBreak1' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Nothing origin=null
|
||||
VAR name:s type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_1: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForBreak1' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
BREAK label=null loop.label=null
|
||||
FUN name:testForBreak2 visibility:public modality:FINAL <> (ss:kotlin.collections.List<kotlin.String>) returnType:kotlin.Unit
|
||||
@@ -28,7 +28,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
||||
$this: GET_VAR 'val tmp_3: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForBreak2' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Nothing origin=null
|
||||
VAR name:s1 type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_3: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForBreak2' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.collections.List<kotlin.String> [val]
|
||||
GET_VAR 'ss: kotlin.collections.List<kotlin.String> declared in <root>.testForBreak2' type=kotlin.collections.List<kotlin.String> origin=null
|
||||
@@ -40,7 +40,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
||||
$this: GET_VAR 'val tmp_5: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForBreak2' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Nothing origin=null
|
||||
VAR name:s2 type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_5: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForBreak2' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
BREAK label=OUTER loop.label=OUTER
|
||||
BREAK label=INNER loop.label=INNER
|
||||
@@ -59,7 +59,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
||||
$this: GET_VAR 'val tmp_7: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForContinue1' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Nothing origin=null
|
||||
VAR name:s type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_7: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForContinue1' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
CONTINUE label=null loop.label=null
|
||||
FUN name:testForContinue2 visibility:public modality:FINAL <> (ss:kotlin.collections.List<kotlin.String>) returnType:kotlin.Unit
|
||||
@@ -75,7 +75,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
||||
$this: GET_VAR 'val tmp_9: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForContinue2' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Nothing origin=null
|
||||
VAR name:s1 type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_9: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForContinue2' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:kotlin.collections.List<kotlin.String> [val]
|
||||
GET_VAR 'ss: kotlin.collections.List<kotlin.String> declared in <root>.testForContinue2' type=kotlin.collections.List<kotlin.String> origin=null
|
||||
@@ -87,7 +87,7 @@ FILE fqName:<root> fileName:/forWithBreakContinue.kt
|
||||
$this: GET_VAR 'val tmp_11: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForContinue2' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
body: BLOCK type=kotlin.Nothing origin=null
|
||||
VAR name:s2 type:kotlin.String [val]
|
||||
CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'val tmp_11: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.testForContinue2' type=kotlin.collections.Iterator<kotlin.String> origin=null
|
||||
CONTINUE label=OUTER loop.label=OUTER
|
||||
CONTINUE label=INNER loop.label=INNER
|
||||
|
||||
+6
-6
@@ -14,7 +14,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInForLoop.kt
|
||||
$this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<<root>.P> [val] declared in <root>.testForInListUnused' type=kotlin.collections.MutableIterator<<root>.P> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:x type:<root>.P [val]
|
||||
CALL 'public abstract fun next (): <root>.P [operator] declared in kotlin.collections.Iterator' type=<root>.P origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=<root>.P origin=null
|
||||
$this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<<root>.P> [val] declared in <root>.testForInListUnused' type=kotlin.collections.MutableIterator<<root>.P> origin=null
|
||||
FUN name:testForInListDestructured visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
@@ -28,7 +28,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInForLoop.kt
|
||||
$this: GET_VAR 'val tmp_3: kotlin.collections.MutableIterator<<root>.P> [val] declared in <root>.testForInListDestructured' type=kotlin.collections.MutableIterator<<root>.P> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:<root>.P [val]
|
||||
CALL 'public abstract fun next (): <root>.P [operator] declared in kotlin.collections.Iterator' type=<root>.P origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=<root>.P origin=null
|
||||
$this: GET_VAR 'val tmp_3: kotlin.collections.MutableIterator<<root>.P> [val] declared in <root>.testForInListDestructured' type=kotlin.collections.MutableIterator<<root>.P> origin=null
|
||||
VAR name:x type:kotlin.Int [val]
|
||||
CALL 'public final fun component1 (): kotlin.Int declared in <root>.P' type=kotlin.Int origin=null
|
||||
@@ -46,7 +46,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInForLoop.kt
|
||||
$this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<<root>.P> [val] declared in <root>.testDesugaredForInList' type=kotlin.collections.MutableIterator<<root>.P> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:x type:<root>.P [val]
|
||||
CALL 'public abstract fun next (): <root>.P [operator] declared in kotlin.collections.Iterator' type=<root>.P origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=<root>.P origin=null
|
||||
$this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<<root>.P> [val] declared in <root>.testDesugaredForInList' type=kotlin.collections.MutableIterator<<root>.P> origin=null
|
||||
FUN name:testForInArrayUnused visibility:public modality:FINAL <> (j:<root>.J) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:j index:0 type:<root>.J
|
||||
@@ -62,7 +62,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInForLoop.kt
|
||||
$this: GET_VAR 'val tmp_6: kotlin.collections.Iterator<<root>.P?> [val] declared in <root>.testForInArrayUnused' type=kotlin.collections.Iterator<<root>.P?> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:x type:<root>.P? [val]
|
||||
CALL 'public abstract fun next (): <root>.P? [operator] declared in kotlin.collections.Iterator' type=<root>.P? origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=<root>.P? origin=null
|
||||
$this: GET_VAR 'val tmp_6: kotlin.collections.Iterator<<root>.P?> [val] declared in <root>.testForInArrayUnused' type=kotlin.collections.Iterator<<root>.P?> origin=null
|
||||
FUN name:testForInListUse visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
@@ -76,7 +76,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInForLoop.kt
|
||||
$this: GET_VAR 'val tmp_8: kotlin.collections.MutableIterator<<root>.P> [val] declared in <root>.testForInListUse' type=kotlin.collections.MutableIterator<<root>.P> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:x type:<root>.P [val]
|
||||
CALL 'public abstract fun next (): <root>.P [operator] declared in kotlin.collections.Iterator' type=<root>.P origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=<root>.P origin=null
|
||||
$this: GET_VAR 'val tmp_8: kotlin.collections.MutableIterator<<root>.P> [val] declared in <root>.testForInListUse' type=kotlin.collections.MutableIterator<<root>.P> origin=null
|
||||
CALL 'public final fun use (s: <root>.P): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
s: GET_VAR 'val x: <root>.P [val] declared in <root>.testForInListUse' type=<root>.P origin=null
|
||||
@@ -96,7 +96,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInForLoop.kt
|
||||
$this: GET_VAR 'val tmp_10: kotlin.collections.Iterator<<root>.P?> [val] declared in <root>.testForInArrayUse' type=kotlin.collections.Iterator<<root>.P?> origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
VAR name:x type:<root>.P? [val]
|
||||
CALL 'public abstract fun next (): <root>.P? [operator] declared in kotlin.collections.Iterator' type=<root>.P? origin=null
|
||||
CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=<root>.P? origin=null
|
||||
$this: GET_VAR 'val tmp_10: kotlin.collections.Iterator<<root>.P?> [val] declared in <root>.testForInArrayUse' type=kotlin.collections.Iterator<<root>.P?> origin=null
|
||||
CALL 'public final fun use (s: <root>.P): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
s: GET_VAR 'val x: <root>.P? [val] declared in <root>.testForInArrayUse' type=<root>.P? origin=null
|
||||
|
||||
Reference in New Issue
Block a user