Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 9 additions & 9 deletions compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ object PickledQuotes {
(tdef.symbol, tree.tpe)
}.toMap
class ReplaceSplicedTyped extends TypeMap() {
override def apply(tp: Type): Type = {
val tp1 = tp match {
case tp: TypeRef =>
typeSpliceMap.get(tp.symbol) match
case Some(t) if tp.typeSymbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot) => t
case _ => tp
case _ => tp
}
mapOver(tp1)
override def apply(tp: Type): Type = tp match {
case tp: ClassInfo =>
tp.derivedClassInfo(classParents = tp.classParents.map(apply))
case tp: TypeRef =>
typeSpliceMap.get(tp.symbol) match
case Some(t) if tp.typeSymbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot) => mapOver(t)
case _ => mapOver(tp)
case _ =>
mapOver(tp)
}
}
val expansion2 = new TreeTypeMap(new ReplaceSplicedTyped).transform(expr1)
Expand Down
15 changes: 15 additions & 0 deletions tests/pos-macros/i9020-a/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
trait Show[T] {
def show(t: T): String
}

object Show {
inline def deriveWithMacro[T]: Show[T] = ${ impl[T] }

import quoted._
def impl[T](using ctx: QuoteContext, tpe: Type[T]): Expr[Show[T]] =
'{
new Show[T] {
def show(t: T): String = "TODO"
}
}
}
5 changes: 5 additions & 0 deletions tests/pos-macros/i9020-a/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
case class Foo(x: String)

object Bar {
println(Show.deriveWithMacro[Foo].show(Foo("")))
}
15 changes: 15 additions & 0 deletions tests/pos-macros/i9020-b/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
trait Show[T] {
def show(t: T): String
}

object Show {
inline def deriveWithMacro[T]: Show[T] = ${ impl[T] }

import quoted._
def impl[T](using ctx: QuoteContext, tpe: Type[T]): Expr[Show[T]] =
'{
new Show[$tpe] {
def show(t: $tpe): String = "TODO"
}
}
}
5 changes: 5 additions & 0 deletions tests/pos-macros/i9020-b/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
case class Foo(x: String)

object Bar {
println(Show.deriveWithMacro[Foo].show(Foo("")))
}