[FIR] Fix mutant extension function types

Consider the following example from
`extensionLambdasAndArrow.kt`:

```
val x4: String.() -> String = if (true) {
    { str: String -> "this" }
} else {
    { str: String -> "this" }
}
```

Because of
`coerceFirstParameterToExtensionReceiver`
the given lambdas must be of the type
`String.() -> String`, but because of a bug
they are `String.(String) -> String`. At the
same time, during inference their expected
types are, indeed, calculated correctly as
`String.() -> String`.

^KT-59394 Declined
(no more compiler crashes, #potential-feature)
This commit is contained in:
Nikolay Lunyak
2023-07-13 14:55:06 +03:00
committed by Space Team
parent bca44e5d8c
commit 9850987415
11 changed files with 96 additions and 20 deletions
@@ -83,7 +83,7 @@ fun test2() { // to extension lambda 1
val i27a: E1 = when (e) { E.VALUE -> { s -> this + s.length } } // oi+ ni+
val w28 = W2 <!ARGUMENT_TYPE_MISMATCH!>{ i: Int, <!CANNOT_INFER_PARAMETER_TYPE!>s<!> -> i <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> s.<!UNRESOLVED_REFERENCE!>length<!> }<!> // oi- ni-
val i28: E1 = id { i: Int, <!CANNOT_INFER_PARAMETER_TYPE!>s<!> -> i <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> s.<!UNRESOLVED_REFERENCE!>length<!> } // oi- ni-
val i28: E1 = id { i: Int, s -> i + s.length } // oi- ni-
val w29 = W2 <!ARGUMENT_TYPE_MISMATCH!>{ i: Int, s: String -> i + s.length }<!> // oi- ni-
val i29: E1 = id { i: Int, s: String -> i + s.length } // oi+ ni+