Skip to content

Commit ac11eb3

Browse files
committed
Fix type substitution
1 parent bf815cf commit ac11eb3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/quoted/TreeCleaner.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ class TreeCleaner extends tpd.TreeMap {
1717
/** List of symbols and their types for type aliases `type T = U` */
1818
private[this] var aliasesSyms: List[Symbol] = Nil
1919
private[this] var aliasesTypes: List[Type] = Nil
20+
private[this] val aliases = newMutableSymbolMap[Tree]
2021

2122
override def transform(tree: Tree)(implicit ctx: Context): Tree = {
2223
val tree0 = tree match {
2324
case TypeDef(_, TypeBoundsTree(lo, hi)) if lo == hi =>
2425
aliasesSyms = tree.symbol :: aliasesSyms
2526
aliasesTypes = lo.tpe :: aliasesTypes
27+
aliases(tree.symbol) = ref(lo.tpe.typeSymbol)
2628
Literal(Constant(()))
2729
case _ => tree
2830
}
@@ -40,6 +42,7 @@ class TreeCleaner extends tpd.TreeMap {
4042
case expr3 => Block(flatStats, expr3)
4143
}
4244
case tree1: TypeTree => TypeTree(tree1.tpe.subst(aliasesSyms, aliasesTypes))
45+
case tree1: Ident => aliases.get(tree1.symbol).getOrElse(tree1)
4346
case tree1 => tree1
4447
}
4548
}

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
210210
explicitTags.clear()
211211

212212
// Maps type splices to type references of tags e.g., ~t -> some type T$1
213-
val map: Map[Type, Type] = tagsExplicitTypeDefsPairs.map(x => (x._1, x._2.symbol.typeRef)).toMap
213+
val map: Map[Type, Type] = {
214+
tagsExplicitTypeDefsPairs.map(x => (x._1, x._2.symbol.typeRef)) ++
215+
(itags.map(_._1) zip typeDefs.map(_.symbol.typeRef))
216+
}.toMap
214217
val tMap = new TypeMap() {
215218
override def apply(tp: Type): Type = map.getOrElse(tp, mapOver(tp))
216219
}

0 commit comments

Comments
 (0)