Hello, World! I have a strange issue, wondering i...
# announcements
b
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
Does it still compile? If the errors differ between IDE and compiler then it's new type inference.
b
It does not compile (same message) when removing the
_ ->
k
Then it's just an issue in both, report on youtrack.
r
@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
Thanks for the info!