frankelot
10/15/2020, 2:28 PMMarc Knaup
10/15/2020, 2:30 PMflatMap
and the compiler doesn’t know which one to use. It will only know once you write code into { … }
so it knows what return type it’s dealing with.Marc Knaup
10/15/2020, 2:30 PMflatMap
you may either return a List
or a Sequence
.frankelot
10/15/2020, 2:31 PMfrankelot
10/15/2020, 2:31 PMfoo.flatMap { it }
frankelot
10/15/2020, 2:31 PMVampire
10/15/2020, 2:32 PMit
is red, why?frankelot
10/15/2020, 2:32 PMfrankelot
10/15/2020, 2:33 PMVampire
10/15/2020, 2:33 PMflatMap
, not the error on it
Vampire
10/15/2020, 2:33 PMfrankelot
10/15/2020, 2:33 PMMarc Knaup
10/15/2020, 2:33 PMfrankelot
10/15/2020, 2:35 PMval kotlinVersion = "1.3.72"
I could try updatingVampire
10/15/2020, 2:35 PMVampire
10/15/2020, 2:35 PMfoo.flatten()
?Marc Knaup
10/15/2020, 2:35 PMVampire
10/15/2020, 2:36 PMstephanmg
10/15/2020, 2:36 PMfrankelot
10/15/2020, 2:36 PMstephanmg
10/15/2020, 2:36 PMVampire
10/15/2020, 2:36 PMVampire
10/15/2020, 2:37 PMstephanmg
10/15/2020, 2:37 PMstephanmg
10/15/2020, 2:37 PMMarc Knaup
10/15/2020, 2:37 PMVampire
10/15/2020, 2:37 PMMarc Knaup
10/15/2020, 2:38 PMVampire
10/15/2020, 2:38 PMfrankelot
10/15/2020, 2:38 PMVampire
10/15/2020, 2:38 PMMarc Knaup
10/15/2020, 2:39 PMWhy? It works in 1.3.72 with old inference on play.kotl.inThat’s why I suggest it may be an issue with 1.3.72's new inference
stephanmg
10/15/2020, 2:39 PMstephanmg
10/15/2020, 2:39 PMstephanmg
10/15/2020, 2:39 PMMarc Knaup
10/15/2020, 2:40 PMstephanmg
10/15/2020, 2:40 PMVampire
10/15/2020, 2:40 PMMarc Knaup
10/15/2020, 2:41 PMMarc Knaup
10/15/2020, 2:41 PMstephanmg
10/15/2020, 2:41 PMVampire
10/15/2020, 2:41 PMVampire
10/15/2020, 2:41 PMMarc Knaup
10/15/2020, 2:42 PMstephanmg
10/15/2020, 2:42 PMMarc Knaup
10/15/2020, 2:42 PMVampire
10/15/2020, 2:42 PMstephanmg
10/15/2020, 2:42 PMMarc Knaup
10/15/2020, 2:43 PMstephanmg
10/15/2020, 2:43 PMfrankelot
10/15/2020, 2:43 PMVampire
10/15/2020, 2:43 PMstephanmg
10/15/2020, 2:43 PMstephanmg
10/15/2020, 2:43 PMfrankelot
10/15/2020, 2:44 PMVampire
10/15/2020, 2:44 PMMarc Knaup
10/15/2020, 2:45 PMfrankelot
10/15/2020, 2:45 PMVampire
10/15/2020, 2:45 PMfrankelot
10/15/2020, 2:49 PMprintln(list.map { v -> v }) // Works
frankelot
10/15/2020, 2:49 PMfrankelot
10/15/2020, 2:49 PMval foo = listOf(listOf(1, 2, 3), listOf(4, 5, 6))
println(foo.flatMap { v -> v }) // Error
Vampire
10/15/2020, 2:50 PMfrankelot
10/15/2020, 2:50 PMAnd if you switch the inference algorithm in the IDE settings?not sure where to find this
Vampire
10/15/2020, 2:51 PMMarc Knaup
10/15/2020, 2:51 PMfrankelot
10/15/2020, 2:53 PMfrankelot
10/15/2020, 2:53 PMfrankelot
10/15/2020, 2:54 PMfrankelot
10/15/2020, 2:54 PMMarc Knaup
10/15/2020, 2:54 PMVampire
10/15/2020, 2:55 PMVampire
10/15/2020, 2:55 PMVampire
10/15/2020, 2:56 PMVampire
10/15/2020, 2:56 PMfrankelot
10/15/2020, 2:58 PMkotlin_version = "1.4.10"
frankelot
10/15/2020, 2:59 PMfrankelot
10/15/2020, 2:59 PMstephanmg
10/15/2020, 2:59 PMfrankelot
10/15/2020, 3:03 PMfrankelot
10/15/2020, 3:03 PMilya.gorbunov
10/15/2020, 5:50 PMflatMap
in question works in 1.3.72 both with the old and the new inference because there's only one overload of it for the particular receiver.
Then, flatMap
works in 1.4.0 because the compiler knows how to select from its two overloads, one of which was introduced in 1.4.0.
What doesn't work is using the standard library 1.4.0 with the compiler/IDE plugin 1.3.72.Vampire
10/15/2020, 6:01 PMVampire
10/15/2020, 6:02 PMflatMap
with standard library 1.4.0, IDE plugin 1.3.72 and new inference activated have worked?ilya.gorbunov
10/15/2020, 10:09 PM