K2: Adjust invoke priorities with K1
- At first, get rid of a kind of interceptTowerGroup callback and use explicit towerGroup construction instead - Get rid of INVOKE_RECEIVER (not sure exactly why it was needed) - Make comparison consistent with tower-levels priority of K2 (see the comments in the compareTo code) ^KT-37375 Fixed ^KT-58940 Open
This commit is contained in:
committed by
Space Team
parent
04dd209f8d
commit
1f120ecd20
+23
@@ -0,0 +1,23 @@
|
||||
// ISSUE: KT-58940
|
||||
|
||||
// FILE: JavaIndex.java
|
||||
public class JavaIndex {
|
||||
public String getIndexer() { return ""; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
abstract class KotlinIndex : JavaIndex() {
|
||||
fun indexer(x: Int): String = ""
|
||||
}
|
||||
|
||||
class MyKotlinIndex : KotlinIndex() {
|
||||
// `indexer(1)` call should just request the member function that might be resolved successfully
|
||||
// and should not request `indexer` variable (as invoke candidates are anyway less prioritized), thus avoiding TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM
|
||||
val INDEXER = indexer(1)
|
||||
|
||||
override fun getIndexer() = INDEXER
|
||||
}
|
||||
|
||||
fun main() {
|
||||
MyKotlinIndex().getIndexer().length
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// ISSUE: KT-58940
|
||||
|
||||
// FILE: JavaIndex.java
|
||||
public class JavaIndex {
|
||||
public String getIndexer() { return ""; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
abstract class KotlinIndex : JavaIndex() {
|
||||
fun indexer(x: Int): String = ""
|
||||
}
|
||||
|
||||
class MyKotlinIndex : KotlinIndex() {
|
||||
// `indexer(1)` call should just request the member function that might be resolved successfully
|
||||
// and should not request `indexer` variable (as invoke candidates are anyway less prioritized), thus avoiding TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM
|
||||
val INDEXER = <!DEBUG_INFO_LEAKING_THIS!>indexer<!>(1)
|
||||
|
||||
override fun getIndexer() = INDEXER
|
||||
}
|
||||
|
||||
fun main() {
|
||||
MyKotlinIndex().getIndexer().length
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// ISSUE: KT-37375
|
||||
|
||||
val foo: Any = Any()
|
||||
|
||||
fun bar() {
|
||||
operator fun Any.invoke(): String = ""
|
||||
|
||||
fun baz() {
|
||||
operator fun Any.invoke(): Int = 1
|
||||
|
||||
fun barbaz() {
|
||||
takeInt(<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-37375
|
||||
|
||||
val foo: Any = Any()
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// ISSUE: KT-37375
|
||||
|
||||
fun takeDouble(x: Double) {}
|
||||
|
||||
val bar: Int = 1
|
||||
operator fun Double.invoke(): Double = 1.0 // (1)
|
||||
|
||||
fun test_1() {
|
||||
val bar: Double = 2.0
|
||||
operator fun Int.invoke(): Int = 1 // (2)
|
||||
|
||||
val res = bar() // should resolve to (1)
|
||||
takeDouble(<!ARGUMENT_TYPE_MISMATCH!>res<!>) // should be OK
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-37375
|
||||
|
||||
fun takeDouble(x: Double) {}
|
||||
|
||||
Reference in New Issue
Block a user