-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type computed to any
, works in Scala 2
#16018
Comments
Here is an attempt to minimize: object Test {
class Box[T](val value: T)
def f[T](l: List[Box[_ <: T]]): List[T] = l.map(_.value)
} I am not sure if this captures every aspect of your problem or if this is over-simplified. The above snippet compiles with Scala 2.12, 3.1.2 and 3.2.0 but fails with Scala 2.13, 3.1.1 and 3.1.3. Output
I believe this is linked to type avoidance and recent related work from @smarter and @odersky; can you please confirm? @He-Pin have you tried to compile with Scala 3.2.0? And with 2.13? |
Hard to tell whether it's avoidance or not. But it works in nightly, right? |
My simplified example compiles with 3.2.0, but I am not sure for the original one. @He-Pin could please try with 3.2.0 and with the latest nightly? |
@mbovel I am trying to get Akka built at: akka/akka#31578 :) ,that will be the first to come, it currently only compiles with scala 3.1.2, |
it's still the same. [info] compiling 186 Scala sources and 3 Java sources to C:\Users\hepin\IdeaProjects\akka\akka-stream\target\scala-3.2.0\classes ...
[error] -- [E007] Type Mismatch Error: C:\Users\hepin\IdeaProjects\akka\akka-stream\src\main\scala\akka\stream\javadsl\Source.scala:682:79
[error] 682 | new Source(scaladsl.Source.combine(seq)(fanInGraph).mapMaterializedValue(_.asJava))
[error] | ^^^^^^^^
[error] | Found: java.util.List[Any]
[error] | Required: java.util.List[M]
[error] |
[error] | longer explanation available when compiling with `-explain`
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 58 s, completed 2022-9-13 14:41:21 I rebased akka/akka#31345 to akka/akka#31579 @mbovel Sorry for not minimize it, you can have a try. |
Mian. import scala.collection.immutable
object Main {
class Source[+Out, +Mat] extends Graph[SourceShape[Out], Mat]
class Shape
class SourceShape[+T] extends Shape
class Graph[+S <: Shape, +M]
def combine[T, U, M](sources: java.util.List[_ <: Graph[SourceShape[T], _ <: M]]): Source[U, java.util.List[M]] = {
val seq: immutable.Seq[Graph[SourceShape[T], M]] = if (sources != null) immutableSeq(sources).collect {
case source: Source[T, M]@unchecked => source
case other => other
} else immutable.Seq()
???
}
def immutableSeq[T](iterable: java.lang.Iterable[T]): immutable.Seq[T] = ???
}
it gives me: C:\Users\hepin\IdeaProjects\MtoAnyTest\src\main\scala\Main.scala:16:21
Found: (other : ?1.CAP)
Required: Main.Source[T, M] & ?1.CAP
where: ?1 is an unknown value of type scala.runtime.TypeBox[Nothing, Main.Graph[Main.SourceShape[T], ? <: M]]
case other => other |
Compiler version
3.1.2
Rrror: https://github.com/akka/akka/runs/8294129202?check_suite_focus=true
From: akka/akka#31345
Minimized code
Sorry I have not minimized it :(
if I change to :
The only difference is
_<:M
andM
.Output
Expectation
Compile as Scala 2.
I think that should be computed to
java.util.List[M]
notjava.util.List[Any]
The text was updated successfully, but these errors were encountered: