https://kotlinlang.org logo
#announcements
Title
# announcements
b

bod

06/27/2019, 8:24 AM
Hello, World! I have a strange issue, wondering if it's already known. I have a method with this signature:
Copy code
fun foo(vararg pairs: Pair<String, (String) -> FooBar>)
When I call it like this:
Copy code
foo(
           "a" to { _ -> FooBar() },
           "b" to { _ -> FooBar() }
      )
I get warning saying that
_ ->
is redundant. But, if I remove it I get
Copy code
Type inference failed. Expected type mismatch: inferred type is Pair<String, () -> FooBar> but Pair<String, (String) -> FooBar> was expected
Could this be a problem with the "new type inference algorithm"?
k

karelpeeters

06/27/2019, 9:34 AM
Does it still compile? If the errors differ between IDE and compiler then it's new type inference.
b

bod

06/27/2019, 9:54 AM
It does not compile (same message) when removing the
_ ->
k

karelpeeters

06/27/2019, 10:11 AM
Then it's just an issue in both, report on youtrack.
r

Ruckus

06/27/2019, 3:33 PM
@bod It is a known issue, though I'm not sure what the status is. I submitted a similar ticket a week ago: https://youtrack.jetbrains.com/issue/KT-32080, but (as I mentioned in that issue) there is another issue that claims it was fixed (though it clearly isn't) https://youtrack.jetbrains.com/issue/KT-19462
b

bod

06/27/2019, 3:39 PM
Thanks for the info!
3 Views