FIR resolve: use proper argument mapping in FlatSignature for constructor

This commit is contained in:
Simon Ogorodnik
2019-04-18 18:15:54 +03:00
committed by Mikhail Glukhikh
parent d89913dc8d
commit e6b9c41f3a
4 changed files with 62 additions and 1 deletions
@@ -59,7 +59,7 @@ class ConeOverloadConflictResolver(
return FlatSignature(
call,
constructor.typeParameters.map { it.symbol },
constructor.valueParameters.map { it.returnTypeRef.coneTypeUnsafe() },
call.argumentMapping!!.map { it.value.returnTypeRef.coneTypeUnsafe() },
//constructor.receiverTypeRef != null,
false,
constructor.valueParameters.any { it.isVararg },
@@ -0,0 +1,17 @@
interface B
interface C {
val b: B
}
fun A(b: B?, flag: Boolean = true) = A(b!!, flag)
fun A(c: C, flag: Boolean = true) = A(c.b, flag)
class A(val b: B, val flag: Boolean = true)
fun foo(c: C, b: B, bn: B?) {
val x = A(c)
val y = A(b)
val z = A(bn)
}
@@ -0,0 +1,39 @@
FILE: factoryFunctionOverloads.kt
public abstract interface B : R|kotlin/Any| {
}
public abstract interface C : R|kotlin/Any| {
public abstract val b: R|B|
public get(): R|B|
}
public final fun A(b: R|B|?, flag: R|kotlin/Boolean| = Boolean(true)): R|A| {
^A R|/A.A|(when (lval <bangbang>: R|B|? = R|<local>/b|) {
==($subj$, Null(null)) -> {
throw <Unresolved name: KotlinNullPointerException>#()
}
else -> {
R|<local>/<bangbang>|
}
}
, R|<local>/flag|)
}
public final fun A(c: R|C|, flag: R|kotlin/Boolean| = Boolean(true)): R|A| {
^A R|/A.A|(R|<local>/c|.R|/C.b|, R|<local>/flag|)
}
public final class A : R|kotlin/Any| {
public constructor(b: R|B|, flag: R|kotlin/Boolean| = Boolean(true)): R|A| {
super<R|kotlin/Any|>()
}
public final val b: R|B| = R|<local>/b|
public get(): R|B|
public final val flag: R|kotlin/Boolean| = R|<local>/flag|
public get(): R|kotlin/Boolean|
}
public final fun foo(c: R|C|, b: R|B|, bn: R|B|?): R|kotlin/Unit| {
lval x: R|A| = R|/A|(R|<local>/c|)
lval y: R|A| = R|/A.A|(R|<local>/b|)
lval z: R|A| = R|/A.A|(R|<local>/bn|)
}
@@ -217,6 +217,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
runTest("compiler/fir/resolve/testData/resolve/expresssions/dispatchReceiver.kt");
}
@TestMetadata("factoryFunctionOverloads.kt")
public void testFactoryFunctionOverloads() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/expresssions/factoryFunctionOverloads.kt");
}
@TestMetadata("lambda.kt")
public void testLambda() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/expresssions/lambda.kt");