Skip to content

Commit

Permalink
Add regression test for scala#14821
Browse files Browse the repository at this point in the history
  • Loading branch information
griggt committed Apr 10, 2022
1 parent b8df544 commit 05f5a6f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/pos/i14821.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
trait Statement
trait Definition extends Statement

trait ClassDef extends Definition:
def constructor: DefDef

object ClassDef:
def copy(constr: DefDef): ClassDef = ???

// >>> This abstract implementation of DefDef causes a compilation error in transform...
type DefDef <: Definition
val DefDef: DefDefModule = ???
trait DefDefModule:
def unapply(ddef: DefDef): (String, List[AnyRef])
// ...unless this given TypeTest is commented out, in which case we get only a type test warning
given scala.reflect.TypeTest[Statement, DefDef] = ???

// >>> This alternative works
// trait DefDef extends Definition
// object DefDef:
// def unapply(ddef: DefDef): (String, List[AnyRef]) = ???

// >>> This alternative also works
// case class DefDef(name: String, paramss: List[AnyRef]) extends Definition

def transform(tree: Statement): Statement = tree match
case tree: ClassDef =>
val constructor @ DefDef(_, _) = transform(tree.constructor): @unchecked
ClassDef.copy(constructor)

0 comments on commit 05f5a6f

Please sign in to comment.