-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)typer
Milestone
Description
reproduction steps
using Scala 2.13.6,
trait iType {
type Bug
}
type iGood[X] = iType { type Bug = X }
type iBug[X] = iType { type Bug = X }
class Box[X]
def Box[X](bug :iBug[X]) :Box[X] = ???
trait Super {
def apply[X](arg :iGood[X]) :Box[X]
}
class Impl extends Super {
override def apply[X](arg :iGood[X]) = Box(arg)
}problem
ncompatible type in overriding
def apply[X](arg: Playground.iGood[X]): Playground.Box[X] (defined in trait Super);
found : [X(in method apply)](arg: Playground.iGood[X(in method apply)]): Playground.Box[this.Bug]
(which expands to) [X(in method apply)](arg: Playground.iType{type Bug = X(in method apply)}): Playground.Box[X]
required: [X(in method apply)](arg: Playground.iGood[X(in method apply)]): Playground.Box[X(in method apply)]
(which expands to) [X(in method apply)](arg: Playground.iType{type Bug = X(in method apply)}): Playground.Box[X(in method apply)]
override def apply[X](arg :iGood[X]) = Box(arg)
The crucial part to the reproduction is that the type argumet of the returned Box is inferred based on an argument of a different type alias than its formal parameter (iGood vs. iBug). Switching from iBug to iGood makes it work and so does explicitly specifying the return type as Box[S].
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)typer