Simplify and fix createReflectionTypeForCallableDescriptor
Previously its call sites needed to determine if the receiver type should be ignored (e.g. if the reference is to static member or nested class constructor, or if it's a bound reference), and 3 of 4 callers did it incorrectly. Simplify this by passing the DoubleColonLHS instance everywhere. Also rename it to createKCallableTypeForReference #KT-12738 Fixed #KT-12751 Fixed #KT-12799 Fixed
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER
|
||||
|
||||
class OverloadTest {
|
||||
fun foo(bar: Boolean) {}
|
||||
fun foo(bar: Any?) {}
|
||||
}
|
||||
|
||||
inline fun <T : Any> OverloadTest.overload(value: T?, function: (T) -> Unit) {
|
||||
}
|
||||
|
||||
fun OverloadTest.overloadBoolean(value: Boolean?) = overload(value, OverloadTest()::foo)
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public inline fun </*0*/ T : kotlin.Any> OverloadTest.overload(/*0*/ value: T?, /*1*/ function: (T) -> kotlin.Unit): kotlin.Unit
|
||||
public fun OverloadTest.overloadBoolean(/*0*/ value: kotlin.Boolean?): kotlin.Unit
|
||||
|
||||
public final class OverloadTest {
|
||||
public constructor OverloadTest()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ bar: kotlin.Any?): kotlin.Unit
|
||||
public final fun foo(/*0*/ bar: kotlin.Boolean): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// KT-12751 Type inference failed with forEach and bound reference
|
||||
|
||||
class L<out T>
|
||||
|
||||
fun <T> L<T>.foo(action: (T) -> Unit): Unit {}
|
||||
|
||||
class B {
|
||||
fun remove(charSequence: CharSequence) {}
|
||||
}
|
||||
|
||||
fun foo(list: L<CharSequence>, b: B) {
|
||||
list.foo(b::remove)
|
||||
list.foo<CharSequence>(b::remove)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ list: L<kotlin.CharSequence>, /*1*/ b: B): kotlin.Unit
|
||||
public fun </*0*/ T> L<T>.foo(/*0*/ action: (T) -> kotlin.Unit): kotlin.Unit
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
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 final fun remove(/*0*/ charSequence: kotlin.CharSequence): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class L</*0*/ out T> {
|
||||
public constructor L</*0*/ out T>()
|
||||
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
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// KT-12799 Bound callable references not resolved for overload
|
||||
|
||||
class C {
|
||||
fun xf1(){}
|
||||
fun xf1(s: String){}
|
||||
}
|
||||
|
||||
fun foo(p: (String) -> Unit){}
|
||||
|
||||
fun bar(c: C) {
|
||||
foo(c::xf1)
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ c: C): kotlin.Unit
|
||||
public fun foo(/*0*/ p: (kotlin.String) -> kotlin.Unit): kotlin.Unit
|
||||
|
||||
public final class C {
|
||||
public constructor C()
|
||||
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 xf1(): kotlin.Unit
|
||||
public final fun xf1(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
}
|
||||
Reference in New Issue
Block a user