Skip to content

Commit 043c92f

Browse files
committed
Re-architecture quote pickling
Separate the logic that creates holes in quotes from the logic that pickles the quotes. Holes are created in the `Splicer` phase and the result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes` phase only needs to extract the contents of the holes, pickle the quote and put them into a call to `unpickleExprV2`/`unpickleTypeV2`. We add `unpickleExprV2` to support some optimization in the encoding of the pickled quote. Namely we removed an unnecessary lambda from the arguments of the hole passed into the contents of the hole. By not changing `unpickleExpr` the current compiler will be able to handle the old encoding in binaries compiled with older compilers. The `unpickleTypeV2` is just a version of `unpickleType` that does not take the `termHole` parameter which is always `null`. Fixes scala#8100 Fixes scala#12440 Fixes scala#13563
1 parent 5ed0586 commit 043c92f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1136
-514
lines changed

compiler/src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,10 @@ class CompilationUnit protected (val source: SourceFile) {
4747
var needsMirrorSupport: Boolean = false
4848

4949
/** Will be set to `true` if contains `Quote`.
50-
* The information is used in phase `Staging` in order to avoid traversing trees that need no transformations.
50+
* The information is used in phase `Staging`/`Splicing`/`PickleQuotes` in order to avoid traversing trees that need no transformations.
5151
*/
5252
var needsStaging: Boolean = false
5353

54-
/** Will be set to `true` if contains `Quote` that needs to be pickled
55-
* The information is used in phase `PickleQuotes` in order to avoid traversing trees that need no transformations.
56-
*/
57-
var needsQuotePickling: Boolean = false
58-
5954
var suspended: Boolean = false
6055
var suspendedAtInliningPhase: Boolean = false
6156

@@ -104,7 +99,6 @@ object CompilationUnit {
10499
val force = new Force
105100
force.traverse(unit1.tpdTree)
106101
unit1.needsStaging = force.containsQuote
107-
unit1.needsQuotePickling = force.containsQuote
108102
unit1.needsInlining = force.containsInline
109103
}
110104
unit1

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Compiler {
5454
List(new Inlining) :: // Inline and execute macros
5555
List(new PostInlining) :: // Add mirror support for inlined code
5656
List(new Staging) :: // Check staging levels and heal staged types
57+
List(new Splicing) :: // Replace level 1 splices with holes
5758
List(new PickleQuotes) :: // Turn quoted trees into explicit run-time data structures
5859
Nil
5960

compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ class TreeTypeMap(
133133
val bind1 = tmap.transformSub(bind)
134134
val expr1 = tmap.transform(expr)
135135
cpy.Labeled(labeled)(bind1, expr1)
136-
case Hole(isTermHole, n, args) =>
137-
Hole(isTermHole, n, args.mapConserve(transform)).withSpan(tree.span).withType(mapType(tree.tpe))
136+
case tree @ Hole(_, _, args, content, tpt) =>
137+
val args1 = args.mapConserve(transform)
138+
val content1 = transform(content)
139+
val tpt1 = transform(tpt)
140+
cpy.Hole(tree)(args = args1, content = content1, tpt = tpt1)
138141
case lit @ Literal(Constant(tpe: Type)) =>
139142
cpy.Literal(lit)(Constant(mapType(tpe)))
140143
case tree1 =>

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ object Trees {
503503
def forwardTo: Tree[T] = fun
504504
}
505505

506+
object GenericApply:
507+
def unapply[T >: Untyped](tree: Tree[T]): Option[(Tree[T], List[Tree[T]])] = tree match
508+
case tree: GenericApply[T] => Some((tree.fun, tree.args))
509+
case _ => None
510+
506511
/** The kind of application */
507512
enum ApplyKind:
508513
case Regular // r.f(x)
@@ -525,8 +530,6 @@ object Trees {
525530
attachmentOrElse(untpd.KindOfApply, ApplyKind.Regular)
526531
}
527532

528-
529-
530533
/** fun[args] */
531534
case class TypeApply[-T >: Untyped] private[ast] (fun: Tree[T], args: List[Tree[T]])(implicit @constructorOnly src: SourceFile)
532535
extends GenericApply[T] {
@@ -972,10 +975,16 @@ object Trees {
972975
def genericEmptyValDef[T >: Untyped]: ValDef[T] = theEmptyValDef.asInstanceOf[ValDef[T]]
973976
def genericEmptyTree[T >: Untyped]: Thicket[T] = theEmptyTree.asInstanceOf[Thicket[T]]
974977

975-
/** Tree that replaces a splice in pickled quotes.
976-
* It is only used when picking quotes (Will never be in a TASTy file).
978+
/** Tree that replaces a level 1 splices in pickled (level 0) quotes.
979+
* It is only used when picking quotes (will never be in a TASTy file).
980+
*
981+
* @param isTermHole If this hole is a term, otherwise it is a type hole.
982+
* @param idx The index of the hole in it's enclosing level 0 quote.
983+
* @param args The arguments of the splice to compute its content
984+
* @param content Lambda that computes the content of the hole. This tree is empty when in a quote pickle.
985+
* @param tpt Type of the hole
977986
*/
978-
case class Hole[-T >: Untyped](isTermHole: Boolean, idx: Int, args: List[Tree[T]])(implicit @constructorOnly src: SourceFile) extends Tree[T] {
987+
case class Hole[-T >: Untyped](isTermHole: Boolean, idx: Int, args: List[Tree[T]], content: Tree[T], tpt: Tree[T])(implicit @constructorOnly src: SourceFile) extends Tree[T] {
979988
type ThisTree[-T >: Untyped] <: Hole[T]
980989
override def isTerm: Boolean = isTermHole
981990
override def isType: Boolean = !isTermHole
@@ -1331,6 +1340,10 @@ object Trees {
13311340
case tree: Thicket if (trees eq tree.trees) => tree
13321341
case _ => finalize(tree, untpd.Thicket(trees)(sourceFile(tree)))
13331342
}
1343+
def Hole(tree: Tree)(isTerm: Boolean, idx: Int, args: List[Tree], content: Tree, tpt: Tree)(using Context): Hole = tree match {
1344+
case tree: Hole if isTerm == tree.isTerm && idx == tree.idx && args.eq(tree.args) && content.eq(tree.content) && content.eq(tree.content) => tree
1345+
case _ => finalize(tree, untpd.Hole(isTerm, idx, args, content, tpt)(sourceFile(tree)))
1346+
}
13341347

13351348
// Copier methods with default arguments; these demand that the original tree
13361349
// is of the same class as the copy. We only include trees with more than 2 elements here.
@@ -1352,6 +1365,9 @@ object Trees {
13521365
TypeDef(tree: Tree)(name, rhs)
13531366
def Template(tree: Template)(constr: DefDef = tree.constr, parents: List[Tree] = tree.parents, derived: List[untpd.Tree] = tree.derived, self: ValDef = tree.self, body: LazyTreeList = tree.unforcedBody)(using Context): Template =
13541367
Template(tree: Tree)(constr, parents, derived, self, body)
1368+
def Hole(tree: Hole)(isTerm: Boolean = tree.isTerm, idx: Int = tree.idx, args: List[Tree] = tree.args, content: Tree = tree.content, tpt: Tree = tree.tpt)(using Context): Hole =
1369+
Hole(tree: Tree)(isTerm, idx, args, content, tpt)
1370+
13551371
}
13561372

13571373
/** Hook to indicate that a transform of some subtree should be skipped */
@@ -1481,6 +1497,8 @@ object Trees {
14811497
case Thicket(trees) =>
14821498
val trees1 = transform(trees)
14831499
if (trees1 eq trees) tree else Thicket(trees1)
1500+
case tree @ Hole(_, _, args, content, tpt) =>
1501+
cpy.Hole(tree)(args = transform(args), content = transform(content), tpt = transform(tpt))
14841502
case _ =>
14851503
transformMoreCases(tree)
14861504
}
@@ -1618,8 +1636,8 @@ object Trees {
16181636
this(this(x, arg), annot)
16191637
case Thicket(ts) =>
16201638
this(x, ts)
1621-
case Hole(_, _, args) =>
1622-
this(x, args)
1639+
case Hole(_, _, args, content, tpt) =>
1640+
this(this(this(x, args), content), tpt)
16231641
case _ =>
16241642
foldMoreCases(x, tree)
16251643
}

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
374374
def Throw(expr: Tree)(using Context): Tree =
375375
ref(defn.throwMethod).appliedTo(expr)
376376

377+
def Hole(isTermHole: Boolean, idx: Int, args: List[Tree], content: Tree, tpt: Tree)(using Context): Hole =
378+
ta.assignType(untpd.Hole(isTermHole, idx, args, content, tpt), tpt)
379+
377380
// ------ Making references ------------------------------------------------------
378381

379382
def prefixIsElidable(tp: NamedType)(using Context): Boolean = {
@@ -1448,10 +1451,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
14481451
* @param tpe the type of the elements of the resulting list.
14491452
*
14501453
*/
1451-
def mkList(trees: List[Tree], tpe: Tree)(using Context): Tree =
1454+
def mkList(trees: List[Tree], tpt: Tree)(using Context): Tree =
14521455
ref(defn.ListModule).select(nme.apply)
1453-
.appliedToTypeTree(tpe)
1454-
.appliedToVarargs(trees, tpe)
1456+
.appliedToTypeTree(tpt)
1457+
.appliedToVarargs(trees, tpt)
14551458

14561459

14571460
protected def FunProto(args: List[Tree], resType: Type)(using Context) =

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
411411
def Export(expr: Tree, selectors: List[ImportSelector])(implicit src: SourceFile): Export = new Export(expr, selectors)
412412
def PackageDef(pid: RefTree, stats: List[Tree])(implicit src: SourceFile): PackageDef = new PackageDef(pid, stats)
413413
def Annotated(arg: Tree, annot: Tree)(implicit src: SourceFile): Annotated = new Annotated(arg, annot)
414+
def Hole(isTermHole: Boolean, idx: Int, args: List[Tree], content: Tree, tpt: Tree)(implicit src: SourceFile): Hole = new Hole(isTermHole, idx, args, content, tpt)
414415

415416
// ------ Additional creation methods for untyped only -----------------
416417

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,44 @@ class Definitions {
793793
@tu lazy val QuotedExprModule: Symbol = QuotedExprClass.companionModule
794794

795795
@tu lazy val QuotesClass: ClassSymbol = requiredClass("scala.quoted.Quotes")
796+
@tu lazy val Quotes_reflect: Symbol = QuotesClass.requiredValue("reflect")
797+
@tu lazy val Quotes_reflect_asTerm: Symbol = Quotes_reflect.requiredMethod("asTerm")
798+
@tu lazy val Quotes_reflect_Apply: Symbol = Quotes_reflect.requiredValue("Apply")
799+
@tu lazy val Quotes_reflect_Apply_apply: Symbol = Quotes_reflect_Apply.requiredMethod(nme.apply)
800+
@tu lazy val Quotes_reflect_TypeApply: Symbol = Quotes_reflect.requiredValue("TypeApply")
801+
@tu lazy val Quotes_reflect_TypeApply_apply: Symbol = Quotes_reflect_TypeApply.requiredMethod(nme.apply)
802+
@tu lazy val Quotes_reflect_Assign: Symbol = Quotes_reflect.requiredValue("Assign")
803+
@tu lazy val Quotes_reflect_Assign_apply: Symbol = Quotes_reflect_Assign.requiredMethod(nme.apply)
804+
@tu lazy val Quotes_reflect_Inferred: Symbol = Quotes_reflect.requiredValue("Inferred")
805+
@tu lazy val Quotes_reflect_Inferred_apply: Symbol = Quotes_reflect_Inferred.requiredMethod(nme.apply)
806+
@tu lazy val Quotes_reflect_Literal: Symbol = Quotes_reflect.requiredValue("Literal")
807+
@tu lazy val Quotes_reflect_Literal_apply: Symbol = Quotes_reflect_Literal.requiredMethod(nme.apply)
808+
@tu lazy val Quotes_reflect_TreeMethods: Symbol = Quotes_reflect.requiredMethod("TreeMethods")
809+
@tu lazy val Quotes_reflect_TreeMethods_asExpr: Symbol = Quotes_reflect_TreeMethods.requiredMethod("asExpr")
810+
@tu lazy val Quotes_reflect_TypeRepr: Symbol = Quotes_reflect.requiredValue("TypeRepr")
811+
@tu lazy val Quotes_reflect_TypeRepr_of: Symbol = Quotes_reflect_TypeRepr.requiredMethod("of")
812+
@tu lazy val Quotes_reflect_TypeRepr_typeConstructorOf: Symbol = Quotes_reflect_TypeRepr.requiredMethod("typeConstructorOf")
813+
@tu lazy val Quotes_reflect_TypeReprMethods: Symbol = Quotes_reflect.requiredValue("TypeReprMethods")
814+
@tu lazy val Quotes_reflect_TypeReprMethods_asType: Symbol = Quotes_reflect_TypeReprMethods.requiredMethod("asType")
815+
@tu lazy val Quotes_reflect_TypeTreeType: Symbol = Quotes_reflect.requiredType("TypeTree")
816+
@tu lazy val Quotes_reflect_TermType: Symbol = Quotes_reflect.requiredType("Term")
817+
@tu lazy val Quotes_reflect_BooleanConstant: Symbol = Quotes_reflect.requiredValue("BooleanConstant")
818+
@tu lazy val Quotes_reflect_ByteConstant: Symbol = Quotes_reflect.requiredValue("ByteConstant")
819+
@tu lazy val Quotes_reflect_ShortConstant: Symbol = Quotes_reflect.requiredValue("ShortConstant")
820+
@tu lazy val Quotes_reflect_IntConstant: Symbol = Quotes_reflect.requiredValue("IntConstant")
821+
@tu lazy val Quotes_reflect_LongConstant: Symbol = Quotes_reflect.requiredValue("LongConstant")
822+
@tu lazy val Quotes_reflect_FloatConstant: Symbol = Quotes_reflect.requiredValue("FloatConstant")
823+
@tu lazy val Quotes_reflect_DoubleConstant: Symbol = Quotes_reflect.requiredValue("DoubleConstant")
824+
@tu lazy val Quotes_reflect_CharConstant: Symbol = Quotes_reflect.requiredValue("CharConstant")
825+
@tu lazy val Quotes_reflect_StringConstant: Symbol = Quotes_reflect.requiredValue("StringConstant")
826+
@tu lazy val Quotes_reflect_UnitConstant: Symbol = Quotes_reflect.requiredValue("UnitConstant")
827+
@tu lazy val Quotes_reflect_NullConstant: Symbol = Quotes_reflect.requiredValue("NullConstant")
828+
@tu lazy val Quotes_reflect_ClassOfConstant: Symbol = Quotes_reflect.requiredValue("ClassOfConstant")
829+
796830

797831
@tu lazy val QuoteUnpicklerClass: ClassSymbol = requiredClass("scala.quoted.runtime.QuoteUnpickler")
798-
@tu lazy val QuoteUnpickler_unpickleExpr: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleExpr")
799-
@tu lazy val QuoteUnpickler_unpickleType: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleType")
832+
@tu lazy val QuoteUnpickler_unpickleExprV2: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleExprV2")
833+
@tu lazy val QuoteUnpickler_unpickleTypeV2: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleTypeV2")
800834

801835
@tu lazy val QuoteMatchingClass: ClassSymbol = requiredClass("scala.quoted.runtime.QuoteMatching")
802836
@tu lazy val QuoteMatching_ExprMatch: Symbol = QuoteMatchingClass.requiredMethod("ExprMatch")

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ object Phases {
201201
private var mySbtExtractDependenciesPhase: Phase = _
202202
private var myPicklerPhase: Phase = _
203203
private var myInliningPhase: Phase = _
204-
private var myPickleQuotesPhase: Phase = _
204+
private var mySplicingPhase: Phase = _
205205
private var myFirstTransformPhase: Phase = _
206206
private var myCollectNullableFieldsPhase: Phase = _
207207
private var myRefChecksPhase: Phase = _
@@ -223,7 +223,7 @@ object Phases {
223223
final def sbtExtractDependenciesPhase: Phase = mySbtExtractDependenciesPhase
224224
final def picklerPhase: Phase = myPicklerPhase
225225
final def inliningPhase: Phase = myInliningPhase
226-
final def pickleQuotesPhase: Phase = myPickleQuotesPhase
226+
final def splicingPhase: Phase = mySplicingPhase
227227
final def firstTransformPhase: Phase = myFirstTransformPhase
228228
final def collectNullableFieldsPhase: Phase = myCollectNullableFieldsPhase
229229
final def refchecksPhase: Phase = myRefChecksPhase
@@ -248,7 +248,7 @@ object Phases {
248248
mySbtExtractDependenciesPhase = phaseOfClass(classOf[sbt.ExtractDependencies])
249249
myPicklerPhase = phaseOfClass(classOf[Pickler])
250250
myInliningPhase = phaseOfClass(classOf[Inlining])
251-
myPickleQuotesPhase = phaseOfClass(classOf[PickleQuotes])
251+
mySplicingPhase = phaseOfClass(classOf[Splicing])
252252
myFirstTransformPhase = phaseOfClass(classOf[FirstTransform])
253253
myCollectNullableFieldsPhase = phaseOfClass(classOf[CollectNullableFields])
254254
myRefChecksPhase = phaseOfClass(classOf[RefChecks])
@@ -423,7 +423,7 @@ object Phases {
423423
def sbtExtractDependenciesPhase(using Context): Phase = ctx.base.sbtExtractDependenciesPhase
424424
def picklerPhase(using Context): Phase = ctx.base.picklerPhase
425425
def inliningPhase(using Context): Phase = ctx.base.inliningPhase
426-
def pickleQuotesPhase(using Context): Phase = ctx.base.pickleQuotesPhase
426+
def splicingPhase(using Context): Phase = ctx.base.splicingPhase
427427
def firstTransformPhase(using Context): Phase = ctx.base.firstTransformPhase
428428
def refchecksPhase(using Context): Phase = ctx.base.refchecksPhase
429429
def elimRepeatedPhase(using Context): Phase = ctx.base.elimRepeatedPhase

compiler/src/dotty/tools/dotc/core/StagingContext.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import scala.collection.mutable
1313

1414
object StagingContext {
1515

16-
/** A key to be used in a context property that tracks the quoteation level */
16+
/** A key to be used in a context property that tracks the quotation level */
1717
private val QuotationLevel = new Property.Key[Int]
1818

19-
/** A key to be used in a context property that tracks the quoteation stack.
20-
* Stack containing the Quotes references recieved by the surrounding quotes.
19+
/** A key to be used in a context property that tracks the quotation stack.
20+
* Stack containing the Quotes references received by the surrounding quotes.
2121
*/
2222
private val QuotesStack = new Property.Key[List[tpd.Tree]]
2323

@@ -31,7 +31,7 @@ object StagingContext {
3131
def quoteContext(using Context): Context =
3232
ctx.fresh.setProperty(QuotationLevel, level + 1)
3333

34-
/** Context with an incremented quotation level and pushes a refecence to a Quotes on the quote context stack */
34+
/** Context with an incremented quotation level and pushes a reference to a Quotes on the quote context stack */
3535
def pushQuotes(qctxRef: tpd.Tree)(using Context): Context =
3636
val old = ctx.property(QuotesStack).getOrElse(List.empty)
3737
ctx.fresh.setProperty(QuotationLevel, level + 1)
@@ -48,7 +48,7 @@ object StagingContext {
4848
ctx.property(TaggedTypes).get
4949

5050
/** Context with a decremented quotation level and pops the Some of top of the quote context stack or None if the stack is empty.
51-
* The quotation stack could be empty if we are in a top level splice or an eroneous splice directly witin a top level splice.
51+
* The quotation stack could be empty if we are in a top level splice or an erroneous splice directly within a top level splice.
5252
*/
5353
def popQuotes()(using Context): (Option[tpd.Tree], Context) =
5454
val ctx1 = ctx.fresh.setProperty(QuotationLevel, level - 1)

compiler/src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ object StdNames {
454454
val common: N = "common"
455455
val compiletime : N = "compiletime"
456456
val conforms_ : N = "$conforms"
457+
val contents: N = "contents"
457458
val copy: N = "copy"
458459
val currentMirror: N = "currentMirror"
459460
val create: N = "create"
@@ -507,6 +508,7 @@ object StdNames {
507508
val hash_ : N = "hash"
508509
val head: N = "head"
509510
val higherKinds: N = "higherKinds"
511+
val idx: N = "idx"
510512
val identity: N = "identity"
511513
val implicitConversions: N = "implicitConversions"
512514
val implicitly: N = "implicitly"
@@ -573,6 +575,7 @@ object StdNames {
573575
val productElementName: N = "productElementName"
574576
val productIterator: N = "productIterator"
575577
val productPrefix: N = "productPrefix"
578+
val quotes : N = "quotes"
576579
val raw_ : N = "raw"
577580
val refl: N = "refl"
578581
val reflect: N = "reflect"

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,11 @@ class TreePickler(pickler: TastyPickler) {
641641
pickleTree(hi)
642642
pickleTree(alias)
643643
}
644-
case Hole(_, idx, args) =>
644+
case Hole(_, idx, args, _, tpt) =>
645645
writeByte(HOLE)
646646
withLength {
647647
writeNat(idx)
648-
pickleType(tree.tpe, richTypes = true)
648+
pickleType(tpt.tpe, richTypes = true)
649649
args.foreach(pickleTree)
650650
}
651651
}

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ class TreeUnpickler(reader: TastyReader,
12881288
val idx = readNat()
12891289
val tpe = readType()
12901290
val args = until(end)(readTerm())
1291-
Hole(true, idx, args).withType(tpe)
1291+
Hole(true, idx, args, EmptyTree, TypeTree(tpe)).withType(tpe)
12921292
case _ =>
12931293
readPathTerm()
12941294
}
@@ -1324,7 +1324,7 @@ class TreeUnpickler(reader: TastyReader,
13241324
val idx = readNat()
13251325
val tpe = readType()
13261326
val args = until(end)(readTerm())
1327-
Hole(false, idx, args).withType(tpe)
1327+
Hole(false, idx, args, EmptyTree, TypeTree(tpe)).withType(tpe)
13281328
case _ =>
13291329
if (isTypeTreeTag(nextByte)) readTerm()
13301330
else {

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
699699
"Thicket {" ~~ toTextGlobal(trees, "\n") ~~ "}"
700700
case MacroTree(call) =>
701701
keywordStr("macro ") ~ toTextGlobal(call)
702-
case Hole(isTermHole, idx, args) =>
703-
val (prefix, postfix) = if isTermHole then ("{{{ ", " }}}") else ("[[[ ", " ]]]")
702+
case Hole(isTermHole, idx, args, content, tpt) =>
703+
val (prefix, postfix) = if isTermHole then ("{{{", "}}}") else ("[[[", "]]]")
704704
val argsText = toTextGlobal(args, ", ")
705-
prefix ~~ idx.toString ~~ "|" ~~ argsText ~~ postfix
705+
val contentText = toTextGlobal(content)
706+
val tptText = toTextGlobal(tpt)
707+
prefix ~~ idx.toString ~~ "|" ~~ tptText ~~ "|" ~~ argsText ~~ "|" ~~ contentText ~~ postfix
706708
case _ =>
707709
tree.fallbackToText(this)
708710
}

0 commit comments

Comments
 (0)