Skip to content

Possible regression in typer in 2.13.10 (only with Xsource:3) #12671

Closed
scala/scala
#10198
@adampauls

Description

@adampauls

Compiler version

2.13.10 (with -Xsource:3).

Tested with Scastie using options:

scalacOptions ++= Seq(
  "-deprecation",
  "-Xsource:3",
  "-encoding", "UTF-8",
  "-feature",
  "-unchecked"
)

Minimized code

import scala.collection.{mutable, IterableOnce}
import scala.collection.immutable.{AbstractSet, Set, SetOps}

final case class Foo[-T](components: IndexedSeq[Int])

sealed trait FooTrie[T]
    extends AbstractSet[Foo[T]]
    with SetOps[Foo[T], Set, FooTrie[T]] {

  override def fromSpecific(
      coll: IterableOnce[Foo[T]]
  ): FooTrie[T] = {
    coll.iterator.foldLeft(empty)(_ incl _) // error here
  }

  override def newSpecificBuilder
      : mutable.Builder[Foo[T], FooTrie[T]] = ???

  override def incl(elem: Foo[T]): FooTrie[T] = ???

  override def empty = FooTrie.empty[T]
}

object FooTrie {
  def empty[T]: FooTrie[T] = ???
}

Output

type mismatch;
 found   : scala.collection.immutable.Set[Playground.Foo[T]]
 required: Playground.FooTrie[T]

Expectation

This compiles without -Xsource:3 and it compiled under 2.13.8 with -Xsource:3. It will also compile fine override def empty = FooTrie.empty[T] is changed to override def empty: FooTrie[T] = FooTrie.empty[T]

scala/scala#10160 seems like a possible candidate based on the fact that it is specific to -Xsource:3.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions