I don't understand why the following two into
functions, would cause an Overload resolution ambiguity:
public fun <Fiz> Boo.into(block: FizMorphBuilder.() -> Unit): FizMorphBuilder defined in com.ltrojanowski.morph
public fun <Foo> Boo.into(block: FooMorphBuilder.() -> Unit): FooMorphBuilder defined in com.ltrojanowski.morph
Why doesn't kotlin know given the type parameter which one to choose when I explicitly specify the type boo.into<Foo>{}.morph()
?
class FooMorphBuilder(
var a: String?,
var b: Double?,
var c: Int?,
var d: Float?,
var e: List<String>?
) : MorphBuilder<Foo> {
override fun morph(): Foo = Foo(a = a!!, b = b!!, c = c!!, d = d!!, e = e!!)
}
fun <Foo> Boo.into(block: FooMorphBuilder.() -> Unit): FooMorphBuilder = FooMorphBuilder(this.a,
this.b, this.c, this.d, this.e).apply(block)
And
class FizMorphBuilder(
var a: String?,
var b: Double?,
var c: Int?,
var d: Float?,
var e: List<String>?
) : MorphBuilder<Fiz> {
override fun morph(): Fiz = Fiz(a = a!!, b = b!!, c = c!!, d = d!!, e = e!!)
}
fun <Fiz> Boo.into(block: FizMorphBuilder.() -> Unit): FizMorphBuilder = FizMorphBuilder(this.a,
this.b, this.c, this.d, this.e).apply(block)
Can I resolve this somehow?