FIR resolve: introduce argument mapper
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
fun foo(first: Int, second: Double = 3.14, third: Boolean = false) {}
|
||||
fun bar(first: Int, second: Double = 2.71, third: Boolean, fourth: String = "") {}
|
||||
fun baz(x: Int, vararg y: String, z: Boolean = false) {}
|
||||
|
||||
fun test() {
|
||||
foo(1)
|
||||
foo(1, 2.0)
|
||||
foo(1, 2.0, true)
|
||||
foo(1, third = true)
|
||||
|
||||
foo()
|
||||
foo(0, 0.0, false, "")
|
||||
|
||||
bar(1, third = true)
|
||||
bar(1, 2.0, true)
|
||||
bar(1, 2.0, true, "my")
|
||||
|
||||
bar(1, true)
|
||||
|
||||
baz(1)
|
||||
baz(1, "my", "yours")
|
||||
baz(1, z = true)
|
||||
|
||||
baz(0, "", false)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
FILE: default.kt
|
||||
public final fun foo(first: R|kotlin/Int|, second: R|kotlin/Double| = Double(3.14), third: R|kotlin/Boolean| = Boolean(false)): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun bar(first: R|kotlin/Int|, second: R|kotlin/Double| = Double(2.71), third: R|kotlin/Boolean|, fourth: R|kotlin/String| = String()): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun baz(x: R|kotlin/Int|, vararg y: R|kotlin/String|, z: R|kotlin/Boolean| = Boolean(false)): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/foo|(Int(1))
|
||||
R|/foo|(Int(1), Double(2.0))
|
||||
R|/foo|(Int(1), Double(2.0), Boolean(true))
|
||||
R|/foo|(Int(1), third = Boolean(true))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#()
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(0), Double(0.0), Boolean(false), String())
|
||||
R|/bar|(Int(1), third = Boolean(true))
|
||||
R|/bar|(Int(1), Double(2.0), Boolean(true))
|
||||
R|/bar|(Int(1), Double(2.0), Boolean(true), String(my))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(Int(1), Boolean(true))
|
||||
R|/baz|(Int(1))
|
||||
R|/baz|(Int(1), String(my), String(yours))
|
||||
R|/baz|(Int(1), z = Boolean(true))
|
||||
<Inapplicable(INAPPLICABLE): [/baz]>#(Int(0), String(), Boolean(false))
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
fun foo(f: () -> Unit) {}
|
||||
fun bar(x: Int, f: () -> Unit) {}
|
||||
fun baz(f: () -> Unit, other: Boolean = true) {}
|
||||
|
||||
|
||||
fun test() {
|
||||
foo {}
|
||||
foo() {}
|
||||
foo({})
|
||||
|
||||
foo(1) {}
|
||||
foo(f = {}) {}
|
||||
|
||||
bar(1) {}
|
||||
bar(x = 1) {}
|
||||
bar(1, {})
|
||||
bar(x = 1, f = {})
|
||||
|
||||
bar {}
|
||||
bar({})
|
||||
|
||||
baz(other = false, f = {})
|
||||
baz({}, false)
|
||||
|
||||
baz {}
|
||||
baz() {}
|
||||
baz(other = false) {}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
FILE: lambda.kt
|
||||
public final fun foo(f: R|kotlin/Function0|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun bar(x: R|kotlin/Int|, f: R|kotlin/Function0|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun baz(f: R|kotlin/Function0|, other: R|kotlin/Boolean| = Boolean(true)): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/foo|(<L> = foo@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|/foo|(<L> = foo@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|/foo|(foo@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(1), <L> = foo@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(f = foo@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
, <L> = foo@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|/bar|(Int(1), <L> = bar@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|/bar|(x = Int(1), <L> = bar@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|/bar|(Int(1), bar@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|/bar|(x = Int(1), f = bar@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(<L> = bar@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(bar@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|/baz|(other = Boolean(false), f = baz@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|/baz|(baz@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
, Boolean(false))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(other = Boolean(false), <L> = baz@fun <implicit>.<anonymous>(): <implicit> {
|
||||
^ {
|
||||
Unit
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
fun foo(first: Int, second: Double, third: Boolean, fourth: String) {}
|
||||
|
||||
fun test() {
|
||||
foo(1, 2.0, true, "")
|
||||
foo(1, 2.0, true, fourth = "!")
|
||||
foo(1, 2.0, fourth = "???", third = false)
|
||||
foo(1, second = 3.14, third = false, fourth = "!?")
|
||||
foo(third = false, second = 2.71, fourth = "?!", first = 0)
|
||||
|
||||
foo()
|
||||
foo(0.0, false, 0, "")
|
||||
foo(1, 2.0, third = true, "")
|
||||
foo(second = 0.0, first = 0, fourth = "")
|
||||
foo(first = 0.0, second = 0, third = "", fourth = false)
|
||||
foo(first = 0, second = 0.0, third = false, fourth = "", first = 1)
|
||||
foo(0, 0.0, false, foth = "")
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
FILE: simple.kt
|
||||
public final fun foo(first: R|kotlin/Int|, second: R|kotlin/Double|, third: R|kotlin/Boolean|, fourth: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/foo|(Int(1), Double(2.0), Boolean(true), String())
|
||||
R|/foo|(Int(1), Double(2.0), Boolean(true), fourth = String(!))
|
||||
R|/foo|(Int(1), Double(2.0), fourth = String(???), third = Boolean(false))
|
||||
R|/foo|(Int(1), second = Double(3.14), third = Boolean(false), fourth = String(!?))
|
||||
R|/foo|(third = Boolean(false), second = Double(2.71), fourth = String(?!), first = Int(0))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#()
|
||||
<Inapplicable(INAPPLICABLE): [/foo]>#(Double(0.0), Boolean(false), Int(0), String())
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(1), Double(2.0), third = Boolean(true), String())
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(second = Double(0.0), first = Int(0), fourth = String())
|
||||
<Inapplicable(INAPPLICABLE): [/foo]>#(first = Double(0.0), second = Int(0), third = String(), fourth = Boolean(false))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(first = Int(0), second = Double(0.0), third = Boolean(false), fourth = String(), first = Int(1))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(0), Double(0.0), Boolean(false), foth = String())
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fun foo(x: Int, vararg y: String) {}
|
||||
fun bar(x: Int, vararg y: String, z: Boolean) {}
|
||||
|
||||
fun test() {
|
||||
foo(1)
|
||||
foo(1, "")
|
||||
foo(1, "my", "yours")
|
||||
|
||||
foo("")
|
||||
foo(1, 2)
|
||||
|
||||
bar(1, z = true, y = *arrayOf("my", "yours"))
|
||||
|
||||
bar(0, z = false, y = "", y = "other")
|
||||
bar(0, "", true)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
FILE: vararg.kt
|
||||
public final fun foo(x: R|kotlin/Int|, vararg y: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun bar(x: R|kotlin/Int|, vararg y: R|kotlin/String|, z: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/foo|(Int(1))
|
||||
R|/foo|(Int(1), String())
|
||||
R|/foo|(Int(1), String(my), String(yours))
|
||||
<Inapplicable(INAPPLICABLE): [/foo]>#(String())
|
||||
<Inapplicable(INAPPLICABLE): [/foo]>#(Int(1), Int(2))
|
||||
R|/bar|(Int(1), z = Boolean(true), y = <Inapplicable(INAPPLICABLE): [kotlin/arrayOf]>#(String(my), String(yours)))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(Int(0), z = Boolean(false), y = String(), y = String(other))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(Int(0), String(), Boolean(true))
|
||||
}
|
||||
@@ -37,7 +37,7 @@ FILE: simple.kt
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/B.foo|()
|
||||
R|/B.bar|()
|
||||
<Ambiguity: buz, [/B.buz, /A.buz]>#()
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/B.buz, /A.buz]>#()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user