Skip to content

-Xsource:3 on scala 2.13.6 breaks type inference for e.g. scala.js union #12437

@nafg

Description

@nafg

This succeeds without the flag and fails with it:

  class OptGroup[A]
  type Opt[A] = A | OptGroup[A]

  def setting(v: Boolean | Seq[Opt[Int]]) = ()
  def v: Seq[Opt[Int]] = ???
  setting(v)

This takes about a second to compile (successfully) without it, and about an hour with it (I forgot if it succeeds or fails):

  // Minimized code from Scalably Typed bindings for Ant Design
  trait RenderedCell[RecordType]
  object ColumnType {
    def apply[RecordType](): ColumnType[RecordType] = ???

    implicit class ColumnTypeMutableBuilder[Self <: ColumnType[_], RecordType](
        val x: Self with ColumnType[RecordType]
    ) extends AnyVal {
      def setRender(
          value: (Any, RecordType, Double) => Node | RenderedCell[RecordType]
      ): Self = ???

    }
  }
  trait ColumnType[RecordType]

  // Minimized application code
  def render: Double => VdomNode = ???
  ColumnType[Double]()
    .setRender((_, t, _) => render(t).rawNode
    // .asInstanceOf[Node | RenderedCell[Double]]
    )

A standalone reproduction that does not require scalajs or any library is here: https://gitlab.com/nafg/repro-xsource3-inference

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions