NI: don't do substitution for unsupported callable descriptors to use as callable references

^KT-41729 Fixed
This commit is contained in:
Victor Petukhov
2020-09-09 11:55:18 +03:00
parent 668098f3a8
commit 685d16ec68
27 changed files with 247 additions and 55 deletions
@@ -0,0 +1,14 @@
// Issue: KT-41729
import kotlin.reflect.KProperty
class Foo {
operator fun <T> getValue(thisRef: Any?, property: KProperty<*>) = 1
}
fun main() {
val f = Foo()
val a: Int
<!VARIABLE_EXPECTED!>get()<!> = f.getValue(null, ::a) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
}
@@ -0,0 +1,14 @@
// Issue: KT-41729
import kotlin.reflect.KProperty
class Foo {
operator fun <T> getValue(thisRef: Any?, property: KProperty<*>) = 1
}
fun main() {
val f = Foo()
val a: Int
<!UNRESOLVED_REFERENCE!>get<!>() = f.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getValue<!>(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
}
@@ -0,0 +1,11 @@
package
public fun main(): kotlin.Unit
public final class Foo {
public constructor Foo()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun </*0*/ T> getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,14 @@
// Issue: KT-41729
import kotlin.reflect.KProperty
class Foo {
operator fun <T> getValue(thisRef: Any?, property: KProperty<*>) = 1
}
fun main(x: Int) {
val f = Foo()
val a: Int
<!VARIABLE_EXPECTED!>get()<!> = f.getValue(null, ::x) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
}
@@ -0,0 +1,14 @@
// Issue: KT-41729
import kotlin.reflect.KProperty
class Foo {
operator fun <T> getValue(thisRef: Any?, property: KProperty<*>) = 1
}
fun main(<!UNUSED_PARAMETER!>x<!>: Int) {
val f = Foo()
val a: Int
<!UNRESOLVED_REFERENCE!>get<!>() = f.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getValue<!>(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
}
@@ -0,0 +1,11 @@
package
public fun main(/*0*/ x: kotlin.Int): kotlin.Unit
public final class Foo {
public constructor Foo()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun </*0*/ T> getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,8 @@
// Issue: KT-37736
internal class Z<K> {
val map = HashMap<String, String>()
inline fun compute(key: String, producer: () -> String): String {
return map.getOrPut(key, ::producer)
}
}
@@ -0,0 +1,8 @@
// Issue: KT-37736
internal class Z<K> {
val map = HashMap<String, String>()
inline fun compute(key: String, <!UNUSED_PARAMETER!>producer<!>: () -> String): String {
return map.getOrPut(key, ::<!UNSUPPORTED, USAGE_IS_NOT_INLINABLE!>producer<!>)
}
}
@@ -0,0 +1,10 @@
package
internal final class Z</*0*/ K> {
public constructor Z</*0*/ K>()
public final val map: kotlin.collections.HashMap<kotlin.String, kotlin.String> /* = java.util.HashMap<kotlin.String, kotlin.String> */
public final inline fun compute(/*0*/ key: kotlin.String, /*1*/ producer: () -> kotlin.String): kotlin.String
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
}