Skip to content

Commit 8a04428

Browse files
committed
Remove tpd.Splice.apply
Inline, remove dead code and simplify computations splice type
1 parent a322bb5 commit 8a04428

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,17 +1224,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12241224
}
12251225
}
12261226

1227-
/** An extractor for typed splices */
1228-
object Splice {
1229-
def apply(tree: Tree)(implicit ctx: Context): Tree = {
1230-
val baseType = tree.tpe.baseType(defn.QuotedExprClass).orElse(tree.tpe.baseType(defn.QuotedTypeClass))
1231-
val argType =
1232-
if (baseType != NoType) baseType.argTypesHi.head
1233-
else defn.NothingType
1234-
ref(defn.InternalQuoted_exprSplice).appliedToTypes(List(argType, defn.QuoteContextClass.typeRef)).appliedTo(tree)
1235-
}
1236-
}
1237-
12381227
/** A key to be used in a context property that tracks enclosing inlined calls */
12391228
private val InlinedCalls = Property.Key[List[Tree]]()
12401229

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ trait QuotesAndSplices {
7474
if (ctx.mode.is(Mode.QuotedPattern)) spliceOwner(ctx.outer) else ctx.owner
7575
val pat = typedPattern(tree.expr, defn.QuotedExprClass.typeRef.appliedTo(pt))(
7676
spliceContext.retractMode(Mode.QuotedPattern).withOwner(spliceOwner(ctx)))
77-
Splice(pat)
77+
val argType = pat.tpe.baseType(defn.QuotedExprClass).argTypesHi.head
78+
ref(defn.InternalQuoted_exprSplice).appliedToTypes(List(argType, defn.QuoteContextClass.typeRef)).appliedTo(pat)
7879
}
7980
else {
8081
ctx.error(i"Type must be fully defined.\nConsider annotating the splice using a type ascription:\n ($tree: XYZ).", tree.expr.sourcePos)
@@ -204,7 +205,11 @@ trait QuotesAndSplices {
204205
case Typed(Apply(fn, pat :: Nil), tpt) if fn.symbol == defn.InternalQuoted_exprSplice && !tpt.tpe.derivesFrom(defn.RepeatedParamClass) =>
205206
val tpt1 = transform(tpt) // Transform type bindings
206207
val exprTpt = AppliedTypeTree(TypeTree(defn.QuotedExprClass.typeRef), tpt1 :: Nil)
207-
transform(Splice(Typed(pat, exprTpt)))
208+
val newSplice =
209+
ref(defn.InternalQuoted_exprSplice)
210+
.appliedToTypes(List(tpt1.tpe, defn.QuoteContextClass.typeRef))
211+
.appliedTo(Typed(pat, exprTpt))
212+
transform(newSplice)
208213
case Apply(fn, pat :: Nil) if fn.symbol == defn.InternalQuoted_exprSplice =>
209214
try ref(defn.InternalQuoted_patternHole.termRef).appliedToType(tree.tpe).withSpan(tree.span)
210215
finally {

0 commit comments

Comments
 (0)