File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
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)
You can’t perform that action at this time.
0 commit comments