Skip to content
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

Fix #4323: enter class type parameters in GADT bounds #4351

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ object Settings {
else update((argRest split ",").toList, args)
case (StringTag, _) if choices.nonEmpty =>
if (argRest.isEmpty) missingArg
else if (!choices.contains(argRest))
else if (!choices.contains(argRest.asInstanceOf[T]))
fail(s"$arg is not a valid choice for $name", args)
else update(argRest, args)
case (StringTag, arg :: args) if name == "-d" =>
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ class Typer extends Namer
val accu = new TypeAccumulator[Set[Symbol]] {
def apply(tsyms: Set[Symbol], t: Type): Set[Symbol] = {
val tsyms1 = t match {
case tr: TypeRef if (tr.symbol is TypeParam) && tr.symbol.owner.isTerm && variance == 0 =>
case tr: TypeRef if (tr.symbol is TypeParam) && variance == 0 =>
tsyms + tr.symbol
case _ =>
tsyms
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CompilationTests extends ParallelTesting {

@Test def compilePos: Unit = {
implicit val testGroup: TestGroup = TestGroup("compilePos")
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline")) +
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline").without("-Yno-deep-subtypes")) +
compileDir("compiler/src/dotty/tools/dotc/ast", defaultOptions) +
compileDir("compiler/src/dotty/tools/dotc/config", defaultOptions) +
compileDir("compiler/src/dotty/tools/dotc/core", defaultOptions) +
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions tests/pos/i4323.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
enum Expr[T] {
case IExpr(value: Int) extends Expr[Int]
case BExpr(value: Boolean) extends Expr[Boolean]

def join(other: Expr[T]): Expr[T] = (this, other) match {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a neg test where this.T is not other.T:

def join[A](other: Expr[A]): Expr[T] = ...

case (IExpr(i1), IExpr(i2)) => IExpr(i1 + i2)
case (BExpr(b1), BExpr(b2)) => BExpr(b1 & b2)
}
}
13 changes: 13 additions & 0 deletions tests/pos/i4323b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sealed trait Expr[T] {
import Expr._

def join(other: Expr[T]): Expr[T] = (this, other) match {
case (IExpr(i1), IExpr(i2)) => IExpr(i1 + i2)
case (BExpr(b1), BExpr(b2)) => BExpr(b1 & b2)
}
}

object Expr {
case class IExpr(value: Int) extends Expr[Int]
case class BExpr(value: Boolean) extends Expr[Boolean]
}
11 changes: 11 additions & 0 deletions tests/pos/i4323c.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sealed trait Expr[T] { outer =>
class Inner {
def join(other: Expr[T]): Expr[T] = (outer, other) match {
case (IExpr(i1), IExpr(i2)) => IExpr(i1 + i2)
case (BExpr(b1), BExpr(b2)) => BExpr(b1 & b2)
}
}
}

case class IExpr(value: Int) extends Expr[Int]
case class BExpr(value: Boolean) extends Expr[Boolean]