Closed
Description
Compiler version
3.1.1
Minimized code
class OptGroup1[A]
type Opt1[A] = A | OptGroup1[A]
def Opt1[A](value: A): Opt1[A] = ???
class WithOptions1[A]
def creatable1[A](options: Seq[Opt1[A]]): WithOptions1[A] = new WithOptions1[A]
val x = creatable1(Seq(Opt1("hello"), Opt1("goodbye")))
val y: WithOptions1[String] = x
Output
[error] -- [E007] Type Mismatch Error: /home/naftoli/dev/github.com/nafg/scalajs-facades/reactSelect/src/test/scala/io/github/nafg/scalajs/facades/reactselect/CompileTimeTests.scala:18:32
[error] 18 | val y: WithOptions1[String] = x
[error] | ^
[error] |Found: (io.github.nafg.scalajs.facades.reactselect.CompileTimeTests.x :
[error] | io.github.nafg.scalajs.facades.reactselect.CompileTimeTests.WithOptions1[Any]
[error] |)
[error] |Required: io.github.nafg.scalajs.facades.reactselect.CompileTimeTests.WithOptions1[String]
Expectation
In Scala 3.1.0 it correctly infers that x
is WithOptions1[String]