Skip to content

Commit 0b0b37b

Browse files
committed
Don't recompute symbols per run
1 parent 7d4c8fe commit 0b0b37b

File tree

7 files changed

+229
-248
lines changed

7 files changed

+229
-248
lines changed

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

Lines changed: 208 additions & 221 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,10 @@ object Denotations {
335335
val name = pname.toTypeName
336336
info.member(name).requiredSymbol("class", name, this)(_.isClass).asClass
337337
}
338-
def requiredClassRef(pname: PreName)(implicit ctx: Context): TypeRef =
339-
requiredClass(pname).typeRef
340-
341338
def requiredType(pname: PreName)(implicit ctx: Context): TypeSymbol = {
342339
val name = pname.toTypeName
343340
info.member(name).requiredSymbol("type", name, this)(_.isType).asType
344341
}
345-
def requiredTypeRef(pname: PreName)(implicit ctx: Context): TypeRef =
346-
requiredType(pname).typeRef
347-
348342

349343
/** The alternative of this denotation that has a type matching `targetType` when seen
350344
* as a member of type `site`, `NoDenotation` if none exists.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ object Erasure {
260260
case (JavaArrayType(treeElem), JavaArrayType(ptElem))
261261
if treeElem.widen.isPrimitiveValueType && !ptElem.isPrimitiveValueType =>
262262
// See SI-2386 for one example of when this might be necessary.
263-
cast(ref(defn.runtimeMethodRef(nme.toObjectArray)).appliedTo(tree), pt)
263+
cast(ref(defn.runtimeMethod(nme.toObjectArray)).appliedTo(tree), pt)
264264

265265
// When casting between two EVTs, we need to check which one underlies the other to determine
266266
// whether u2evt or evt2u should be used.
@@ -507,9 +507,9 @@ object Erasure {
507507
}
508508

509509
private def runtimeCallWithProtoArgs(name: Name, pt: Type, args: Tree*)(implicit ctx: Context): Tree = {
510-
val meth = defn.runtimeMethodRef(name)
511-
val followingParams = meth.symbol.info.firstParamTypes.drop(args.length)
512-
val followingArgs = protoArgs(pt, meth.widen).zipWithConserve(followingParams)(typedExpr).asInstanceOf[List[tpd.Tree]]
510+
val meth = defn.runtimeMethod(name)
511+
val followingParams = meth.info.firstParamTypes.drop(args.length)
512+
val followingArgs = protoArgs(pt, meth.info).zipWithConserve(followingParams)(typedExpr).asInstanceOf[List[tpd.Tree]]
513513
ref(meth).appliedToArgs(args.toList ++ followingArgs)
514514
}
515515

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class InterceptedMethods extends MiniPhase {
5353
val s = tree.tpe.widen.typeSymbol
5454

5555
def staticsCall(methodName: TermName): Tree =
56-
ref(defn.staticsMethodRef(methodName)).appliedTo(tree)
56+
ref(defn.staticsMethod(methodName)).appliedTo(tree)
5757

5858
if (s == defn.NullClass) Literal(Constant(0))
5959
else if (s == defn.DoubleClass) staticsCall(nme.doubleHash)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
112112
coord = clazz.coord).enteredAfter(thisPhase).asTerm
113113

114114
def forwardToRuntime(vrefs: List[Tree]): Tree =
115-
ref(defn.runtimeMethodRef("_" + sym.name.toString)).appliedToArgs(This(clazz) :: vrefs)
115+
ref(defn.runtimeMethod("_" + sym.name.toString)).appliedToArgs(This(clazz) :: vrefs)
116116

117117
def ownName: Tree =
118118
Literal(Constant(clazz.name.stripModuleClassSuffix.toString))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ object TypeTestsCasts {
286286
}
287287
case defn.MultiArrayOf(elem, ndims) if isUnboundedGeneric(elem) =>
288288
def isArrayTest(arg: Tree) =
289-
ref(defn.runtimeMethodRef(nme.isArray)).appliedTo(arg, Literal(Constant(ndims)))
289+
ref(defn.runtimeMethod(nme.isArray)).appliedTo(arg, Literal(Constant(ndims)))
290290
if (ndims == 1) isArrayTest(expr)
291291
else evalOnce(expr) { e =>
292292
derivedTree(e, defn.Any_isInstanceOf, e.tpe)

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ trait QuotesAndSplices { self: Typer =>
3535
* while tracking the quotation level in the context.
3636
*/
3737
def typedQuote(tree: untpd.Quote, pt: Type)(implicit ctx: Context): Tree = track("typedQuote") {
38-
val qctx = inferImplicitArg(defn.QuoteContextType, tree.span)
38+
val qctx = inferImplicitArg(defn.QuoteContextClass.typeRef, tree.span)
3939
if (level == 0 && qctx.tpe.isInstanceOf[SearchFailureType])
40-
ctx.error(missingArgMsg(qctx, defn.QuoteContextType, ""), ctx.source.atSpan(tree.span))
40+
ctx.error(missingArgMsg(qctx, defn.QuoteContextClass.typeRef, ""), ctx.source.atSpan(tree.span))
4141

4242
tree.quoted match {
4343
case untpd.Splice(innerExpr) if tree.isTerm =>
@@ -49,9 +49,9 @@ trait QuotesAndSplices { self: Typer =>
4949
case quoted =>
5050
ctx.compilationUnit.needsStaging = true
5151
val tree1 =
52-
if (quoted.isType) typedTypeApply(untpd.TypeApply(untpd.ref(defn.InternalQuoted_typeQuoteR), quoted :: Nil), pt)(quoteContext)
52+
if (quoted.isType) typedTypeApply(untpd.TypeApply(untpd.ref(defn.InternalQuoted_typeQuote.termRef), quoted :: Nil), pt)(quoteContext)
5353
else if (ctx.mode.is(Mode.Pattern) && level == 0) typedQuotePattern(quoted, pt, qctx)
54-
else typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuoteR), quoted), pt)(quoteContext)
54+
else typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuote.termRef), quoted), pt)(quoteContext)
5555
tree1.withSpan(tree.span)
5656
}
5757
}
@@ -69,7 +69,7 @@ trait QuotesAndSplices { self: Typer =>
6969
if (isFullyDefined(pt, ForceDegree.all)) {
7070
def spliceOwner(ctx: Context): Symbol =
7171
if (ctx.mode.is(Mode.QuotedPattern)) spliceOwner(ctx.outer) else ctx.owner
72-
val pat = typedPattern(expr, defn.QuotedExprType.appliedTo(pt))(
72+
val pat = typedPattern(expr, defn.QuotedExprClass.typeRef.appliedTo(pt))(
7373
spliceContext.retractMode(Mode.QuotedPattern).withOwner(spliceOwner(ctx)))
7474
Splice(pat)
7575
} else {
@@ -86,7 +86,7 @@ trait QuotesAndSplices { self: Typer =>
8686
else if (!c.outer.owner.is(Package)) markAsMacro(c.outer)
8787
markAsMacro(ctx)
8888
}
89-
typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprSpliceR), tree.expr), pt)(spliceContext).withSpan(tree.span)
89+
typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprSplice.termRef), tree.expr), pt)(spliceContext).withSpan(tree.span)
9090
}
9191
}
9292
}
@@ -115,7 +115,7 @@ trait QuotesAndSplices { self: Typer =>
115115
}
116116
val typeSym = ctx.newSymbol(spliceOwner(ctx), name, EmptyFlags, TypeBounds.empty, NoSymbol, expr.span)
117117
typeSym.addAnnotation(Annotation(New(ref(defn.InternalQuoted_patternBindHoleAnnot.typeRef)).withSpan(expr.span)))
118-
val pat = typedPattern(expr, defn.QuotedTypeType.appliedTo(typeSym.typeRef))(
118+
val pat = typedPattern(expr, defn.QuotedTypeClass.typeRef.appliedTo(typeSym.typeRef))(
119119
spliceContext.retractMode(Mode.QuotedPattern).withOwner(spliceOwner(ctx)))
120120
pat.select(tpnme.splice)
121121
}
@@ -175,10 +175,10 @@ trait QuotesAndSplices { self: Typer =>
175175
override def transform(tree: Tree)(implicit ctx: Context) = tree match {
176176
case Typed(Splice(pat), tpt) if !tpt.tpe.derivesFrom(defn.RepeatedParamClass) =>
177177
val tpt1 = transform(tpt) // Transform type bindings
178-
val exprTpt = AppliedTypeTree(TypeTree(defn.QuotedExprType), tpt1 :: Nil)
178+
val exprTpt = AppliedTypeTree(TypeTree(defn.QuotedExprClass.typeRef), tpt1 :: Nil)
179179
transform(Splice(Typed(pat, exprTpt)))
180180
case Splice(pat) =>
181-
try ref(defn.InternalQuoted_patternHoleR).appliedToType(tree.tpe).withSpan(tree.span)
181+
try ref(defn.InternalQuoted_patternHole.termRef).appliedToType(tree.tpe).withSpan(tree.span)
182182
finally {
183183
val patType = pat.tpe.widen
184184
val patType1 = patType.underlyingIfRepeated(isJava = false)
@@ -202,7 +202,7 @@ trait QuotesAndSplices { self: Typer =>
202202
x => t.resType.subst(t, x).toFunctionType())
203203
case t => t
204204
}
205-
val bindingExprTpe = AppliedType(defn.QuotedMatchingBindingType, bindingType :: Nil)
205+
val bindingExprTpe = AppliedType(defn.QuotedMatchingBindingClass.typeRef, bindingType :: Nil)
206206
assert(ddef.name.startsWith("$"))
207207
val bindName = ddef.name.toString.stripPrefix("$").toTermName
208208
val sym = ctx0.newPatternBoundSymbol(bindName, bindingExprTpe, ddef.span)
@@ -217,7 +217,7 @@ trait QuotesAndSplices { self: Typer =>
217217

218218
def transformTypeBindingTypeDef(tdef: TypeDef, buff: mutable.Builder[Tree, List[Tree]]): Tree = {
219219
val bindingType = getBinding(tdef.symbol).symbol.typeRef
220-
val bindingTypeTpe = AppliedType(defn.QuotedTypeType, bindingType :: Nil)
220+
val bindingTypeTpe = AppliedType(defn.QuotedTypeClass.typeRef, bindingType :: Nil)
221221
assert(tdef.name.startsWith("$"))
222222
val bindName = tdef.name.toString.stripPrefix("$").toTermName
223223
val sym = ctx0.newPatternBoundSymbol(bindName, bindingTypeTpe, tdef.span, flags = ImplicitTerm)
@@ -347,13 +347,13 @@ trait QuotesAndSplices { self: Typer =>
347347
val splicePat = typed(untpd.Tuple(splices.map(x => untpd.TypedSplice(replaceBindingsInTree.transform(x)))).withSpan(quoted.span), patType)
348348

349349
UnApply(
350-
fun = ref(defn.InternalQuotedMatcher_unapplyR).appliedToTypeTrees(typeBindingsTuple :: TypeTree(patType) :: Nil),
350+
fun = ref(defn.InternalQuotedMatcher_unapply.termRef).appliedToTypeTrees(typeBindingsTuple :: TypeTree(patType) :: Nil),
351351
implicits =
352-
ref(defn.InternalQuoted_exprQuoteR).appliedToType(shape.tpe).appliedTo(shape) ::
352+
ref(defn.InternalQuoted_exprQuote.termRef).appliedToType(shape.tpe).appliedTo(shape) ::
353353
Literal(Constant(typeBindings.nonEmpty)) ::
354354
qctx :: Nil,
355355
patterns = splicePat :: Nil,
356-
proto = defn.QuotedExprType.appliedTo(replaceBindings(quoted1.tpe) & quotedPt))
356+
proto = defn.QuotedExprClass.typeRef.appliedTo(replaceBindings(quoted1.tpe) & quotedPt))
357357
}
358358

359359
}

0 commit comments

Comments
 (0)