File tree 5 files changed +49
-9
lines changed
compiler/src/dotty/tools/dotc/core/quoted 5 files changed +49
-9
lines changed Original file line number Diff line number Diff line change @@ -139,15 +139,15 @@ object PickledQuotes {
139
139
(tdef.symbol, tree.tpe)
140
140
}.toMap
141
141
class ReplaceSplicedTyped extends TypeMap () {
142
- override def apply (tp : Type ): Type = {
143
- val tp1 = tp match {
144
- case tp : TypeRef =>
145
- typeSpliceMap.get(tp.symbol) match
146
- case Some (t) if tp.typeSymbol.hasAnnotation(defn. InternalQuoted_QuoteTypeTagAnnot ) => t
147
- case _ => tp
148
- case _ => tp
149
- }
150
- mapOver(tp1 )
142
+ override def apply (tp : Type ): Type = tp match {
143
+ case tp : ClassInfo =>
144
+ tp.derivedClassInfo(classParents = tp.classParents.map(apply))
145
+ case tp : TypeRef =>
146
+ typeSpliceMap.get( tp.symbol) match
147
+ case Some (t) if tp.typeSymbol.hasAnnotation(defn. InternalQuoted_QuoteTypeTagAnnot ) => mapOver(t)
148
+ case _ => mapOver(tp)
149
+ case _ =>
150
+ mapOver(tp )
151
151
}
152
152
}
153
153
val expansion2 = new TreeTypeMap (new ReplaceSplicedTyped ).transform(expr1)
Original file line number Diff line number Diff line change
1
+ trait Show [T ] {
2
+ def show (t : T ): String
3
+ }
4
+
5
+ object Show {
6
+ inline def deriveWithMacro [T ]: Show [T ] = $ { impl[T ] }
7
+
8
+ import quoted ._
9
+ def impl [T ](using ctx : QuoteContext , tpe : Type [T ]): Expr [Show [T ]] =
10
+ ' {
11
+ new Show [T ] {
12
+ def show (t : T ): String = " TODO"
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ case class Foo (x : String )
2
+
3
+ object Bar {
4
+ println(Show .deriveWithMacro[Foo ].show(Foo (" " )))
5
+ }
Original file line number Diff line number Diff line change
1
+ trait Show [T ] {
2
+ def show (t : T ): String
3
+ }
4
+
5
+ object Show {
6
+ inline def deriveWithMacro [T ]: Show [T ] = $ { impl[T ] }
7
+
8
+ import quoted ._
9
+ def impl [T ](using ctx : QuoteContext , tpe : Type [T ]): Expr [Show [T ]] =
10
+ ' {
11
+ new Show [$tpe] {
12
+ def show (t : $tpe): String = " TODO"
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ case class Foo (x : String )
2
+
3
+ object Bar {
4
+ println(Show .deriveWithMacro[Foo ].show(Foo (" " )))
5
+ }
You can’t perform that action at this time.
0 commit comments