interface A {
fun f() : String
}
val B = { attr : String ->
object : A {
override fun f() = attr
}
}
I'm getting this error at the definition of B
:
'public' property exposes its 'local' type argument <no name provided>
What is the cause of this error?
You are returning an anonymous singleton object, and kotlin is not able to figure out the type for which no name is provided. You can specify the type of B
explicitly to fix this issue
val B: (String) -> A = { attr: String ->
object : A {
override fun f() = attr
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With