K2: Fix incorrect inference of delegated property type

It was working incorrectly, because we've been trying to fix
P1 variable to intersectTypes(String?, StubForP2) that should result
to String? because we've got stubEqualsToAnything enabled there,
but nullability was being chosen incorrectly because
`StubForP2.isNullableType()` returned false

NB: The code inside `is ConeTypeVariable` case wasn't working properly
because it always `lookupTag.toSymbol(session)` always returned null,
thus there was effectively five dead lines of code there.

^KT-57814 Fixed
^KT-57921 Related
This commit is contained in:
Denis.Zharkov
2023-04-06 18:54:33 +02:00
committed by Space Team
parent e079d9d405
commit 39639e08f9
8 changed files with 58 additions and 8 deletions
@@ -0,0 +1,21 @@
// FIR_IDENTICAL
// ISSUE: KT-57814
import kotlin.reflect.KProperty
fun <P2> xComponent(
builder: (prop1: P2) -> Unit
): (prop1: P2) -> Unit = {}
operator fun <P1> ((prop1: P1) -> Unit).getValue(
thisRef: Any?,
property: KProperty<*>
): (prop1: P1) -> Unit = this
val pdfDocumentViewer by xComponent { _: String? ->
}
fun xPDFDocumentViewer(
href: String?
) = pdfDocumentViewer(
href // Should be OK to pass nullable String? there
)