Skip to content

Commit 5ae7861

Browse files
committed
Remove tpt from Quote
1 parent 1f62049 commit 5ae7861

22 files changed

+69
-67
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ object CompilationUnit {
157157
if tree.symbol.is(Flags.Inline) then
158158
containsInline = true
159159
tree match
160-
case tpd.Quote(_, _) =>
160+
case tpd.Quote(_) =>
161161
containsQuote = true
162162
case tree: tpd.Apply if tree.symbol == defn.QuotedTypeModule_of =>
163163
containsQuote = true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ object desugar {
19861986
trees foreach collect
19871987
case Block(Nil, expr) =>
19881988
collect(expr)
1989-
case Quote(expr, _) =>
1989+
case Quote(expr) =>
19901990
new UntypedTreeTraverser {
19911991
def traverse(tree: untpd.Tree)(using Context): Unit = tree match {
19921992
case Splice(expr, _) => collect(expr)

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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -678,23 +678,33 @@ object Trees {
678678
}
679679

680680
/** A tree representing a quote `'{ expr }`
681-
* `Quote`s are created by the `Parser` with an empty `tpt`. In typer
682-
* they can be typed as a `Quote` with a known `tpt` or desugared and
683-
* typed as a quote pattern.
681+
* `Quote`s are created by the `Parser`. In typer they can be typed as a
682+
* `Quote` with a known `tpt` or desugared and typed as a quote pattern.
684683
*
685684
* `Quotes` are checked and transformed in the `staging`, `splicing` and `pickleQuotes`
686685
* phases. After `pickleQuotes` phase, the only quotes that exist are in `inline`
687686
* methods. These are dropped when we remove the inline method implementations.
688687
*
689-
* The `tpt` will be transformed in `staging` and used in `pickleQuotes` to create the
690-
* pickled representation of the quote.
691-
*
692688
* @param expr The tree that was quoted
693-
* @param tpt The type of the tree that was quoted
694689
*/
695-
case class Quote[+T <: Untyped] private[ast] (expr: Tree[T], tpt: Tree[T])(implicit @constructorOnly src: SourceFile)
690+
case class Quote[+T <: Untyped] private[ast] (expr: Tree[T])(implicit @constructorOnly src: SourceFile)
696691
extends TermTree[T] {
697692
type ThisTree[+T <: Untyped] = Quote[T]
693+
694+
/** Type of the quoted expression as seen from outside the quote */
695+
def exprType(using Context): Type =
696+
val quoteType = typeOpt // Quotes ?=> Expr[T]
697+
val exprType = quoteType.argInfos.last // Expr[T]
698+
exprType.argInfos.head // T
699+
700+
/** Set the type of the quoted expression as seen from outside the quote */
701+
def withExprType(tpe: Type)(using Context): Quote[Type] =
702+
val exprType = // Expr[T]
703+
defn.QuotedExprClass.typeRef.appliedTo(tpe)
704+
val quoteType = // Quotes ?=> Expr[T]
705+
defn.FunctionType(1, isContextual = true)
706+
.appliedTo(defn.QuotesClass.typeRef, exprType)
707+
withType(quoteType)
698708
}
699709

700710
/** A tree representing a splice `${ expr }`
@@ -1299,9 +1309,9 @@ object Trees {
12991309
case tree: Inlined if (call eq tree.call) && (bindings eq tree.bindings) && (expansion eq tree.expansion) => tree
13001310
case _ => finalize(tree, untpd.Inlined(call, bindings, expansion)(sourceFile(tree)))
13011311
}
1302-
def Quote(tree: Tree)(expr: Tree, tpt: Tree)(using Context): Quote = tree match {
1303-
case tree: Quote if (expr eq tree.expr) && (tpt eq tree.tpt) => tree
1304-
case _ => finalize(tree, untpd.Quote(expr, tpt)(sourceFile(tree)))
1312+
def Quote(tree: Tree)(expr: Tree)(using Context): Quote = tree match {
1313+
case tree: Quote if (expr eq tree.expr) => tree
1314+
case _ => finalize(tree, untpd.Quote(expr)(sourceFile(tree)))
13051315
}
13061316
def Splice(tree: Tree)(expr: Tree, tpt: Tree)(using Context): Splice = tree match {
13071317
case tree: Splice if (expr eq tree.expr) && (tpt eq tree.tpt) => tree
@@ -1546,8 +1556,8 @@ object Trees {
15461556
case Thicket(trees) =>
15471557
val trees1 = transform(trees)
15481558
if (trees1 eq trees) tree else Thicket(trees1)
1549-
case tree @ Quote(expr, tpt) =>
1550-
cpy.Quote(tree)(transform(expr), transform(tpt))
1559+
case tree @ Quote(expr) =>
1560+
cpy.Quote(tree)(transform(expr))
15511561
case tree @ Splice(expr, tpt) =>
15521562
cpy.Splice(tree)(transform(expr), transform(tpt))
15531563
case tree @ Hole(_, _, args, content, tpt) =>
@@ -1691,8 +1701,8 @@ object Trees {
16911701
this(this(x, arg), annot)
16921702
case Thicket(ts) =>
16931703
this(x, ts)
1694-
case Quote(expr, tpt) =>
1695-
this(this(x, expr), tpt)
1704+
case Quote(expr) =>
1705+
this(x, expr)
16961706
case Splice(expr, tpt) =>
16971707
this(this(x, expr), tpt)
16981708
case Hole(_, _, args, content, tpt) =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
170170
def Inlined(call: Tree, bindings: List[MemberDef], expansion: Tree)(using Context): Inlined =
171171
ta.assignType(untpd.Inlined(call, bindings, expansion), bindings, expansion)
172172

173-
def Quote(expr: Tree, tpt: Tree)(using Context): Quote =
174-
ta.assignType(untpd.Quote(expr, tpt), tpt)
173+
def Quote(expr: Tree, tpe: Type)(using Context): Quote =
174+
untpd.Quote(expr).withExprType(tpe)
175175

176176
def Splice(expr: Tree, tpt: Tree)(using Context): Splice =
177177
ta.assignType(untpd.Splice(expr, tpt), tpt)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
397397
def SeqLiteral(elems: List[Tree], elemtpt: Tree)(implicit src: SourceFile): SeqLiteral = new SeqLiteral(elems, elemtpt)
398398
def JavaSeqLiteral(elems: List[Tree], elemtpt: Tree)(implicit src: SourceFile): JavaSeqLiteral = new JavaSeqLiteral(elems, elemtpt)
399399
def Inlined(call: tpd.Tree, bindings: List[MemberDef], expansion: Tree)(implicit src: SourceFile): Inlined = new Inlined(call, bindings, expansion)
400-
def Quote(expr: Tree, tpt: Tree)(implicit src: SourceFile): Quote = new Quote(expr, tpt)
400+
def Quote(expr: Tree)(implicit src: SourceFile): Quote = new Quote(expr)
401401
def Splice(expr: Tree, tpt: Tree)(implicit src: SourceFile): Splice = new Splice(expr, tpt)
402402
def TypeTree()(implicit src: SourceFile): TypeTree = new TypeTree()
403403
def InferredTypeTree()(implicit src: SourceFile): TypeTree = new InferredTypeTree()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,11 @@ class TreePickler(pickler: TastyPickler) {
665665
pickleTree(hi)
666666
pickleTree(alias)
667667
}
668-
case Quote(expr, tpt) =>
668+
case tree @ Quote(expr) =>
669669
pickleTree(
670-
// scala.quoted.runtime.Expr.quoted[<tpt>](<expr>)
670+
// scala.quoted.runtime.Expr.quoted[<exprType>](<expr>)
671671
ref(defn.QuotedRuntime_exprQuote)
672-
.appliedToTypeTree(tpt)
672+
.appliedToType(tree.exprType)
673673
.appliedTo(expr)
674674
.withSpan(tree.span)
675675
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ class TreeUnpickler(reader: TastyReader,
12691269

12701270
def quotedExpr(fn: Tree, args: List[Tree]): Tree =
12711271
val TypeApply(_, targs) = fn: @unchecked
1272-
Quote(args.head, targs.head)
1272+
Quote(args.head, targs.head.tpe)
12731273

12741274
def splicedExpr(fn: Tree, args: List[Tree]): Tree =
12751275
val TypeApply(_, targs) = fn: @unchecked

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ class Inliner(val call: tpd.Tree)(using Context):
827827

828828
override def typedQuote(tree: untpd.Quote, pt: Type)(using Context): Tree =
829829
super.typedQuote(tree, pt) match
830-
case Quote(Splice(inner, _), _) => inner
830+
case Quote(Splice(inner, _)) => inner
831831
case tree1 =>
832832
ctx.compilationUnit.needsStaging = true
833833
tree1
@@ -1070,7 +1070,7 @@ class Inliner(val call: tpd.Tree)(using Context):
10701070
else tree match {
10711071
case tree: RefTree if tree.isTerm && tree.symbol.isDefinedInCurrentRun && !tree.symbol.isLocal =>
10721072
foldOver(tree.symbol :: syms, tree)
1073-
case Quote(body, _) =>
1073+
case Quote(body) =>
10741074
level += 1
10751075
try apply(syms, body)
10761076
finally level -= 1

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ object Parsers {
12621262
}
12631263
}
12641264
in.nextToken()
1265-
Quote(t, EmptyTree)
1265+
Quote(t)
12661266
}
12671267
else
12681268
if !in.featureEnabled(Feature.symbolLiterals) then
@@ -2497,7 +2497,7 @@ object Parsers {
24972497
val expr =
24982498
if (in.token == LBRACKET) inBrackets(typ())
24992499
else stagedBlock()
2500-
Quote(expr, EmptyTree)
2500+
Quote(expr)
25012501
}
25022502
}
25032503
case NEW =>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,9 +716,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
716716
"Thicket {" ~~ toTextGlobal(trees, "\n") ~~ "}"
717717
case MacroTree(call) =>
718718
keywordStr("macro ") ~ toTextGlobal(call)
719-
case Quote(expr, tpt) =>
720-
val tptText = (keywordStr("[") ~ toTextGlobal(tpt) ~ keywordStr("]")).provided(!tpt.isEmpty && printDebug)
721-
keywordStr("'") ~ tptText ~ keywordStr("{") ~ toTextGlobal(expr) ~ keywordStr("}")
719+
case tree @ Quote(expr) =>
720+
val exprTypeText = (keywordStr("[") ~ toTextGlobal(tree.exprType) ~ keywordStr("]")).provided(printDebug)
721+
keywordStr("'") ~ exprTypeText ~ keywordStr("{") ~ toTextGlobal(expr) ~ keywordStr("}")
722722
case Splice(expr, tpt) =>
723723
val tptText = (keywordStr("[") ~ toTextGlobal(tpt) ~ keywordStr("]")).provided(!tpt.isEmpty && printDebug)
724724
keywordStr("$") ~ tptText ~ keywordStr("{") ~ toTextGlobal(expr) ~ keywordStr("}")

compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class CrossStageSafety extends TreeMapWithStages {
103103
val transformedBody = transformQuoteBody(body, quote.span)
104104
val stripAnnotsDeep: TypeMap = new TypeMap:
105105
def apply(tp: Type): Type = mapOver(tp.stripAnnots)
106-
val tpt1 = TypeTree(healType(quote.tpt.srcPos)(stripAnnotsDeep(quote.tpt.tpe)))
107-
cpy.Quote(quote)(transformedBody, tpt1)
106+
val exprType1 = healType(quote.srcPos)(stripAnnotsDeep(quote.exprType))
107+
cpy.Quote(quote)(transformedBody).withExprType(exprType1)
108108
}
109109

110110
override protected def transformQuotedType(body: Tree, quote: Apply)(using Context): Tree = {

compiler/src/dotty/tools/dotc/staging/TreeMapWithStages.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ abstract class TreeMapWithStages extends TreeMapWithImplicits {
2626
* - `quoted.runtime.Expr.quote[T](<body0>)` --> `quoted.runtime.Expr.quote[T](<body>)`
2727
*/
2828
protected def transformQuote(body: Tree, quote: Quote)(using Context): Tree =
29-
cpy.Quote(quote)(body, quote.tpt)
29+
cpy.Quote(quote)(body)
3030

3131
/** Transform the quote `quote` which contains the quoted `body`.
3232
*
@@ -62,7 +62,7 @@ abstract class TreeMapWithStages extends TreeMapWithImplicits {
6262
try transformQuotedType(quotedTree, tree)
6363
finally inQuoteOrSplice = old
6464

65-
case tree @ Quote(quotedTree, _) =>
65+
case tree @ Quote(quotedTree) =>
6666
val old = inQuoteOrSplice
6767
inQuoteOrSplice = true
6868
try dropEmptyBlocks(quotedTree) match {
@@ -79,7 +79,7 @@ abstract class TreeMapWithStages extends TreeMapWithImplicits {
7979
val old = inQuoteOrSplice
8080
inQuoteOrSplice = true
8181
try dropEmptyBlocks(splicedTree) match {
82-
case Quote(t, _) =>
82+
case Quote(t) =>
8383
// Optimization: `${ 'x }` --> `x`
8484
transform(t)
8585
case _ =>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,7 @@ class MegaPhase(val miniPhases: Array[MiniPhase]) extends Phase {
402402
case tree: Quote =>
403403
inContext(prepQuote(tree, start)(using outerCtx)) {
404404
val expr = transformTree(tree.expr, start)(using quoteContext)
405-
val tpt = transformTree(tree.tpt, start)
406-
goQuote(cpy.Quote(tree)(expr, tpt), start)
405+
goQuote(cpy.Quote(tree)(expr), start)
407406
}
408407
case tree: Splice =>
409408
inContext(prepSplice(tree, start)(using outerCtx)) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ class PickleQuotes extends MacroTransform {
100100
protected def newTransformer(using Context): Transformer = new Transformer {
101101
override def transform(tree: tpd.Tree)(using Context): tpd.Tree =
102102
tree match
103-
case Apply(Select(Quote(expr, tpt), nme.apply), List(quotes)) =>
104-
val (contents, codeWithHoles) = makeHoles(expr)
103+
case Apply(Select(quote: Quote, nme.apply), List(quotes)) =>
104+
val (contents, codeWithHoles) = makeHoles(quote.expr)
105105
val sourceRef = Inlines.inlineCallTrace(ctx.owner, tree.sourcePos)
106106
val codeWithHoles2 = Inlined(sourceRef, Nil, codeWithHoles)
107-
val pickled = PickleQuotes(quotes, codeWithHoles2, contents, tpt.tpe, false)
107+
val pickled = PickleQuotes(quotes, codeWithHoles2, contents, quote.exprType, false)
108108
transform(pickled) // pickle quotes that are in the contents
109109
case Apply(TypeApply(_, List(tpt)), List(quotes)) if tree.symbol == defn.QuotedTypeModule_of =>
110110
tpt match

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
485485
)
486486
case Block(_, Closure(_, _, tpt)) if ExpandSAMs.needsWrapperClass(tpt.tpe) =>
487487
superAcc.withInvalidCurrentClass(super.transform(tree))
488-
case Quote(expr, _) =>
488+
case Quote(expr) =>
489489
ctx.compilationUnit.needsStaging = true
490490
super.transform(tree)
491491
case tree =>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ object Splicer {
4444
* See: `Staging`
4545
*/
4646
def splice(tree: Tree, splicePos: SrcPos, spliceExpansionPos: SrcPos, classLoader: ClassLoader)(using Context): Tree = tree match {
47-
case Quote(quotedTree, _) => quotedTree
47+
case Quote(quotedTree) => quotedTree
4848
case _ =>
4949
val macroOwner = newSymbol(ctx.owner, nme.MACROkw, Macro | Synthetic, defn.AnyType, coord = tree.span)
5050
try
@@ -136,7 +136,7 @@ object Splicer {
136136
* See: `Staging`
137137
*/
138138
def checkValidMacroBody(tree: Tree)(using Context): Unit = tree match {
139-
case Quote(_, _) => // ok
139+
case Quote(_) => // ok
140140
case _ =>
141141
type Env = Set[Symbol]
142142

@@ -155,7 +155,7 @@ object Splicer {
155155
case Block(Nil, expr) => checkIfValidArgument(expr)
156156
case Typed(expr, _) => checkIfValidArgument(expr)
157157

158-
case Apply(Select(Quote(expr, tpt), nme.apply), _) =>
158+
case Apply(Select(Quote(expr), nme.apply), _) =>
159159
val noSpliceChecker = new TreeTraverser {
160160
def traverse(tree: Tree)(using Context): Unit = tree match
161161
case Splice(_, _) =>
@@ -203,7 +203,7 @@ object Splicer {
203203
case Typed(expr, _) =>
204204
checkIfValidStaticCall(expr)
205205

206-
case Apply(Select(Quote(quoted, tpt), nme.apply), _) =>
206+
case Apply(Select(Quote(quoted), nme.apply), _) =>
207207
// OK, canceled and warning emitted
208208

209209
case Call(fn, args)
@@ -240,7 +240,7 @@ object Splicer {
240240

241241
override protected def interpretTree(tree: Tree)(implicit env: Env): Object = tree match {
242242
// Interpret level -1 quoted code `'{...}` (assumed without level 0 splices)
243-
case Apply(Select(Quote(expr, _), nme.apply), _) =>
243+
case Apply(Select(Quote(expr), nme.apply), _) =>
244244
val expr1 = expr match {
245245
case expr: Ident if expr.symbol.isAllOf(InlineByNameProxy) =>
246246
// inline proxy for by-name parameter

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Splicing extends MacroTransform:
8686
override def transform(tree: tpd.Tree)(using Context): tpd.Tree =
8787
assert(level == 0)
8888
tree match
89-
case Apply(Select(Quote(expr, _), nme.apply),List(quotes)) =>
89+
case Apply(Select(Quote(expr), nme.apply),List(quotes)) =>
9090
QuoteTransformer().transform(tree)
9191
case TypeApply(_, _) if tree.symbol == defn.QuotedTypeModule_of =>
9292
QuoteTransformer().transform(tree)
@@ -134,7 +134,7 @@ class Splicing extends MacroTransform:
134134
typeHoles.put(qual, hole)
135135
hole
136136
cpy.TypeDef(tree)(rhs = hole)
137-
case Apply(Select(Quote(expr, tpt), nme.apply),List(quotes)) =>
137+
case Apply(Select(Quote(expr), nme.apply),List(quotes)) =>
138138
super.transform(tree)(using quoteContext)
139139
case _: Template =>
140140
for sym <- tree.symbol.owner.info.decls do
@@ -237,7 +237,7 @@ class Splicing extends MacroTransform:
237237
case Splice(expr, tpt) =>
238238
val expr1 = transform(expr)(using spliceContext)
239239
cpy.Splice(tree)(expr1, tpt)
240-
case Apply(sel @ Select(app @ Quote(expr, tpt), nme.apply), quotesArgs) =>
240+
case Apply(sel @ Select(app @ Quote(expr), nme.apply), quotesArgs) =>
241241
expr match
242242
case expr: RefTree if isCaptured(expr.symbol) =>
243243
capturedTerm(expr)
@@ -246,7 +246,7 @@ class Splicing extends MacroTransform:
246246
if level > 1 then transform(expr)(using quoteContext)
247247
else transformLevel0QuoteContent(expr)(using quoteContext)
248248
}
249-
cpy.Apply(tree)(cpy.Select(sel)(cpy.Quote(app)(newExpr, tpt), nme.apply), quotesArgs)
249+
cpy.Apply(tree)(cpy.Select(sel)(cpy.Quote(app)(newExpr), nme.apply), quotesArgs)
250250
case Apply(TypeApply(typeof, List(tpt)), List(quotes))
251251
if tree.symbol == defn.QuotedTypeModule_of && containsCapturedType(tpt.tpe) =>
252252
val newContent = capturedPartTypes(tpt)
@@ -412,7 +412,7 @@ class Splicing extends MacroTransform:
412412
Splice(closure, TypeTree(tpe))
413413

414414
private def quoted(expr: Tree)(using Context): Tree =
415-
Quote(expr, TypeTree(expr.tpe.widenTermRefExpr))
415+
Quote(expr, expr.tpe.widenTermRefExpr)
416416
.select(nme.apply)
417417
.appliedTo(quotes.nn)
418418

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ object SpaceEngine {
312312
def isIrrefutableQuotedPattern(unapp: tpd.Tree, implicits: List[tpd.Tree], pt: Type)(using Context): Boolean = {
313313
implicits.headOption match
314314
// pattern '{ $x: T }
315-
case Some(tpd.Apply(tpd.Select(tpd.Quote(tpd.TypeApply(fn, List(tpt)), _), nme.apply), _))
315+
case Some(tpd.Apply(tpd.Select(tpd.Quote(tpd.TypeApply(fn, List(tpt))), nme.apply), _))
316316
if unapp.symbol.owner.eq(defn.QuoteMatching_ExprMatchModule)
317317
&& fn.symbol.eq(defn.QuotedRuntimePatterns_patternHole) =>
318318
pt <:< defn.QuotedExprClass.typeRef.appliedTo(tpt.tpe)

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ trait QuotesAndSplices {
3636
*/
3737
def typedQuote(tree: untpd.Quote, pt: Type)(using Context): Tree = {
3838
record("typedQuote")
39-
assert(tree.tpt.isEmpty)
4039
tree.expr match {
4140
case untpd.Splice(innerExpr, _) if tree.isTerm && !ctx.mode.is(Mode.Pattern) =>
4241
report.warning("Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ.", tree.srcPos)
@@ -62,7 +61,7 @@ trait QuotesAndSplices {
6261
// TODO typecheck directly (without `exprQuote`)
6362
val exprQuoteTree = untpd.Apply(untpd.ref(defn.QuotedRuntime_exprQuote.termRef), tree.expr)
6463
val quotedExpr = typedApply(exprQuoteTree, pt)(using quoteContext) match
65-
case Apply(TypeApply(fn, tpt :: Nil), quotedExpr :: Nil) => Quote(quotedExpr, tpt)
64+
case Apply(TypeApply(fn, tpt :: Nil), quotedExpr :: Nil) => Quote(quotedExpr, tpt.tpe)
6665
makeInlineable(quotedExpr.select(nme.apply).appliedTo(quotes).withSpan(tree.span))
6766
}
6867

@@ -77,7 +76,7 @@ trait QuotesAndSplices {
7776
assert(tree.tpt.isEmpty)
7877
checkSpliceOutsideQuote(tree)
7978
tree.expr match {
80-
case untpd.Quote(innerExpr, _) if innerExpr.isTerm =>
79+
case untpd.Quote(innerExpr) if innerExpr.isTerm =>
8180
report.warning("Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ.", tree.srcPos)
8281
return typed(innerExpr, pt)
8382
case _ =>
@@ -446,7 +445,7 @@ trait QuotesAndSplices {
446445

447446
val quoteClass = if (quoted.isTerm) defn.QuotedExprClass else defn.QuotedTypeClass
448447
val quotedPattern =
449-
if (quoted.isTerm) tpd.Quote(shape, TypeTree(defn.AnyType)).select(nme.apply).appliedTo(qctx)
448+
if (quoted.isTerm) tpd.Quote(shape, defn.AnyType).select(nme.apply).appliedTo(qctx)
450449
else ref(defn.QuotedTypeModule_of.termRef).appliedToTypeTree(shape).appliedTo(qctx)
451450

452451
val matchModule = if quoted.isTerm then defn.QuoteMatching_ExprMatch else defn.QuoteMatching_TypeMatch

0 commit comments

Comments
 (0)