PSI2IR: Generate adapted callable references

Callable reference is "adapted" if it requires some adaptation to an
expected function type - e.g., when a reference to
```
  fun foo(vararg xs: Int): Int
```
is used where `(Int, Int, Int) -> Int` is expected.

For such callable references we generate the following IR (in
pseudo-Kotlin):
```
  {
    fun foo'(p0: Int, p1: Int, p2: Int): Int {
      return [| foo(p0, p1, p2) |]
    }
    ::foo'
  }
```

where `[| foo(p0, p1, p2) |]` is calling function `foo` with arguments
`p0`, `p1`, and `p2`, as they were mapped by callable reference
resolution.
This commit is contained in:
Dmitry Petrov
2020-01-15 11:49:50 +03:00
parent 89c832b5a0
commit c5f14a29a4
15 changed files with 729 additions and 19 deletions
@@ -801,6 +801,16 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
runTest("compiler/testData/ir/irText/expressions/callableReferenceTypeArguments.kt");
}
@TestMetadata("callableReferenceWithArgumentsConversion.kt")
public void testCallableReferenceWithArgumentsConversion() throws Exception {
runTest("compiler/testData/ir/irText/expressions/callableReferenceWithArgumentsConversion.kt");
}
@TestMetadata("callableReferenceWithVarargViewedAsArray.kt")
public void testCallableReferenceWithVarargViewedAsArray() throws Exception {
runTest("compiler/testData/ir/irText/expressions/callableReferenceWithVarargViewedAsArray.kt");
}
@TestMetadata("calls.kt")
public void testCalls() throws Exception {
runTest("compiler/testData/ir/irText/expressions/calls.kt");