Any reason why: ```fun interface Foo { ... } // th...
# language-proposals
d
Any reason why:
Copy code
fun interface Foo { ... }
// this works:
data class Baz(val foo: Foo)
val baz = Baz({ ... })
// whereas this doesn't...
fun baz(foo: Foo = { ... })
// it needs to be:
fun baz(foo: Foo = Foo { })
why doesn't the compiler infer Foo as the lambda type in a default value of a function declaration?
s
“this works” — does it? Not for me 🤔 https://pl.kotl.in/Rez5aNt4o
d
Yeah, sorry, I just corrected the example...
It works on initialization of the object, but not as a default value, whether in constructor or in function declarations...
s
It seems there is special handling for “standalone” SAM conversions when used as function arguments… I can’t find any documentation for it, though. There’s even a named language feature
+SamConversionPerArgument
that is enabled by default, but again, no documentation 😞
🤨 1