[FE 1.0] Check callable reference return type safety during resolution

^KT-51844
^KT-52503 Fixed
This commit is contained in:
Victor Petukhov
2022-05-25 11:00:51 +02:00
committed by teamcity
parent 51551998c7
commit 0199c76c06
20 changed files with 140 additions and 33 deletions
@@ -0,0 +1,16 @@
// FIR_IDENTICAL
// WITH_STDLIB
abstract class Foo
object A {
fun Foo.contains(vararg xs: Int) = // 1
xs.forEach(this::<!EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED!>contains<!>) // resolved to (2) in 1.7.0-RC, should be error "Type checking has run into a recursive problem"
}
fun Any.contains(vararg xs: Int) {} // 2
fun box(): String {
object : Foo() {}.contains(1)
return "OK"
}
@@ -0,0 +1,19 @@
package
public fun box(): kotlin.String
public fun kotlin.Any.contains(/*0*/ vararg xs: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
public object A {
private constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final fun Foo.contains(/*0*/ vararg xs: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
}
public abstract class Foo {
public constructor Foo()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,31 +0,0 @@
// FULL_JDK
// WITH_STDLIB
// FILE: Schematic.kt
class Schematic {
var name: String? = null
var error: String? = null
override fun toString(): String {
return name!!
}
}
// FILE: SortedListModel.java
import java.util.Comparator;
public class SortedListModel<T> {
public SortedListModel(Comparator<? super T> comparator) {
}
}
// FILE: main.kt
val model = SortedListModel<Schematic>(Comparator.comparing { b1: Schematic ->
when {
b1.error != null -> 2
b1.name!!.contains(":") -> 1
else -> 0
}
}.thenComparing { b1: Schematic -> b1.name!! })
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FULL_JDK
// WITH_STDLIB