Skip to content

Commit b81a6c7

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

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
@@ -78,7 +78,8 @@ trait QuotesAndSplices {
7878
if (ctx.mode.is(Mode.QuotedPattern)) spliceOwner(ctx.outer) else ctx.owner
7979
val pat = typedPattern(tree.expr, defn.QuotedExprClass.typeRef.appliedTo(pt))(
8080
spliceContext.retractMode(Mode.QuotedPattern).withOwner(spliceOwner(ctx)))
81-
Splice(pat)
81+
val argType = pat.tpe.baseType(defn.QuotedExprClass).argTypesHi.head
82+
ref(defn.InternalQuoted_exprSplice).appliedToTypes(List(argType, defn.QuoteContextClass.typeRef)).appliedTo(pat)
8283
}
8384
else {
8485
ctx.error(i"Type must be fully defined.\nConsider annotating the splice using a type ascription:\n ($tree: XYZ).", tree.expr.sourcePos)
@@ -208,7 +209,11 @@ trait QuotesAndSplices {
208209
case Typed(Apply(fn, pat :: Nil), tpt) if fn.symbol == defn.InternalQuoted_exprSplice && !tpt.tpe.derivesFrom(defn.RepeatedParamClass) =>
209210
val tpt1 = transform(tpt) // Transform type bindings
210211
val exprTpt = AppliedTypeTree(TypeTree(defn.QuotedExprClass.typeRef), tpt1 :: Nil)
211-
transform(Splice(Typed(pat, exprTpt)))
212+
val newSplice =
213+
ref(defn.InternalQuoted_exprSplice)
214+
.appliedToTypes(List(tpt1.tpe, defn.QuoteContextClass.typeRef))
215+
.appliedTo(Typed(pat, exprTpt))
216+
transform(newSplice)
212217
case Apply(fn, pat :: Nil) if fn.symbol == defn.InternalQuoted_exprSplice =>
213218
try ref(defn.InternalQuoted_patternHole.termRef).appliedToType(tree.tpe).withSpan(tree.span)
214219
finally {

0 commit comments

Comments
 (0)