mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-13 00:21:28 +00:00
Resolve callable references taking into account expected callable types. This affects call resolution procedure (resolve 'foo' in for 'foo(::bar)') similar to the approach used for function literals: * During "shape arguments" phase of call resolution, callable references are resolved in independent context without expected type. If the callable reference is ambiguous, its shape type is a function placeholder type without parameter types and return type information. Otherwise, it is a reflection type for the resolved function or property. Upper-level call is resolved without taking into account ambiguous callable references. * During "complete call" phase of call resolution, resolve callable reference arguments to actual descriptors (if possible), and update constraint system for the given call accordingly. #KT-6982 Fixed #KT-5780 Fixed
23 lines
368 B
Kotlin
Vendored
23 lines
368 B
Kotlin
Vendored
// FILE: A.kt
|
|
|
|
open class A<T>(val x: T)
|
|
|
|
// FILE: AFactory.kt
|
|
|
|
abstract class AFactory {
|
|
abstract fun create(): A<Int>?
|
|
}
|
|
|
|
// FILE: Util.kt
|
|
|
|
inline fun <reified T> createWith(x: T, f: (T) -> A<T>?)
|
|
= f(x)
|
|
|
|
// FILE: B.kt
|
|
|
|
class B(x: Int) : A<Int>(x) {
|
|
companion object : AFactory() {
|
|
override fun create(): A<Int>? = createWith(0, ::B)
|
|
}
|
|
}
|