EDIT: I am just dumb. please ignore me :smile: `A`...
# dsl
s
EDIT: I am just dumb. please ignore me ­čśä
A
expands to
Any
and everything is fine... -------------- Original question: I just fiddled around with some DSL stuff and found some weird behavior. Consider these two files. One is inside a library, defining some DSL:
Copy code
package some.library.dsl
class Builder {
    fun <A> foo(first: A, second: A) { println("MEMBER called with $first and $second") }
}
fun build(config: Builder.()->Unit) = Builder().apply(config)
And one is inside a consuming app:
Copy code
package <http://my.app|my.app>
import some.library.dsl.Builder
import some.library.dsl.build
fun <A, B> Builder.foo(first: A, second: B) { println("EXTENSION called with $first and $second") }
fun main() {
    build {
        foo(1, 2)
        foo("hello", 0.4) // ???
    }
}
I expected a compile error at the line marked with
// ???
, but the code compiles, runs and prints the following:
MEMBER called with 1 and 2
MEMBER called with hello and 0.4
Is this expected behavior? As I see it, this could break existing dsl libraries, as they could receive arguments of unexpected types, right?
could make a good kotlin puzzler question though...