https://kotlinlang.org logo
Title
d

dasz

11/06/2017, 9:26 AM
Does anyone know why this is still an issue in Kotlin latest version? https://youtrack.jetbrains.com/issue/KT-3212
o

orangy

11/06/2017, 9:29 AM
Use
Foo().repeat(3){ -> println("test") }
to resolve to first one. It’s ambiguous by design.
👏 1
d

dasz

11/06/2017, 9:36 AM
Sounds like workaround..
o

orangy

11/06/2017, 9:41 AM
Why workaround? Full form of lambda is
{ p1,p2,p3 -> … }
and it is assignable to functional type with specified number of parameters. There is a short lambda form, without parameter list and
->
, and it is assignable to any functional type. Hence, when there is an overload with different functional type, it is assignable to both, so it results in ambiguity. It’s just you can’t use short form when there are overloads.
👍 1
d

dasz

11/06/2017, 9:55 AM
ah OK, didn't spot where is the difference, thank you
it is really working yeah 😄