K2: do not try to resolve invoke on error receiver

If a potential receiver is resolved to an error type, we consider
any other type as a subtype of it and therefore may select
any candidate that we happen to find in a scope.
In particular, in the case of scripts, or code with a context receiver,
the receiver candidate resolved to a cycle was accepted as a receiver
to an invoke on a random class from stdlib.
The fix skips adding invoke resolve task in this case, allowing
the tower to find the correct candidate in another scope.

#KT-64241 fixed
#KT-65576 fixed
This commit is contained in:
Ilya Chernikov
2024-03-13 17:10:40 +01:00
committed by Space Team
parent d5ad41fa28
commit fecc5ba501
8 changed files with 31 additions and 45 deletions
@@ -1,13 +1,13 @@
// WITH_STDLIB
// FILE: test.kt
val bar2 by <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, RECURSION_IN_IMPLICIT_TYPES!>bar2<!><!NO_VALUE_FOR_PARAMETER!>()<!>
val bar2 by <!UNRESOLVED_REFERENCE!>bar2<!>()
// FILE: lt/neworld/compiler/Foo.kt
package lt.neworld.compiler
class Foo {
val bar by <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, RECURSION_IN_IMPLICIT_TYPES!>bar<!><!NO_VALUE_FOR_PARAMETER!>()<!>
val bar by <!UNRESOLVED_REFERENCE!>bar<!>()
}
// FILE: lt/neworld/compiler/bar/Bar.kt