7b46c59d57
Before this commit, for property candidates in K2 their types wasn't inferred/susbtituted properly. So, when candidate for fooBar.liveLoaded.invoke() was created, the type of `fooBar.liveLoaded` was just X type parameter for which there is no any `bar()` functions in its member scope. While proposed semantics is a bit different from K1, where both property and invoke candidates are united into common system, it doesn't contradict to the specification (https://kotlinlang.org/spec/overload-resolution.html#callables-and-invoke-convention) which says explicitly that invoke-convention should be desugared as `r.foo.invoke()`, thus `r.foo` should be completed independently. Also, this strategy supports some reasonable use-cases like KT-58259 while it's still a breaking change but for more artificial-looking situations (see KT-58260) and should be passed through the language committee. The changes in stubTypeReceiverRestriction* tests looks consistent because of how `genericLambda` now works (with full completion of property call). NB: The code is going to be red once KT-54667 is fixed and also there's already similar diagnostic in K1 (INFERRED_INTO_DECLARED_UPPER_BOUNDS) ^KT-58142 Fixed ^KT-58259 Fixed ^KT-58260 Related
15 lines
223 B
Kotlin
Vendored
15 lines
223 B
Kotlin
Vendored
// MODULE: lib
|
|
// FILE: l1.kt
|
|
|
|
val <T : CharSequence> T.z
|
|
get() = { x: T -> this }
|
|
|
|
// FILE: l2.kt
|
|
|
|
fun test(ok: String, fail: String) = ok.z(fail)
|
|
|
|
// MODULE: main(lib)
|
|
// FILE: main.kt
|
|
|
|
fun box() = test("OK", "FAIL")
|