Skip to content

Commit 05f5a6f

Browse files
committed
Add regression test for #14821
1 parent b8df544 commit 05f5a6f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/pos/i14821.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
trait Statement
2+
trait Definition extends Statement
3+
4+
trait ClassDef extends Definition:
5+
def constructor: DefDef
6+
7+
object ClassDef:
8+
def copy(constr: DefDef): ClassDef = ???
9+
10+
// >>> This abstract implementation of DefDef causes a compilation error in transform...
11+
type DefDef <: Definition
12+
val DefDef: DefDefModule = ???
13+
trait DefDefModule:
14+
def unapply(ddef: DefDef): (String, List[AnyRef])
15+
// ...unless this given TypeTest is commented out, in which case we get only a type test warning
16+
given scala.reflect.TypeTest[Statement, DefDef] = ???
17+
18+
// >>> This alternative works
19+
// trait DefDef extends Definition
20+
// object DefDef:
21+
// def unapply(ddef: DefDef): (String, List[AnyRef]) = ???
22+
23+
// >>> This alternative also works
24+
// case class DefDef(name: String, paramss: List[AnyRef]) extends Definition
25+
26+
def transform(tree: Statement): Statement = tree match
27+
case tree: ClassDef =>
28+
val constructor @ DefDef(_, _) = transform(tree.constructor): @unchecked
29+
ClassDef.copy(constructor)

0 commit comments

Comments
 (0)