Skip to content

Commit c66b8dc

Browse files
Move isCompilerIntrinsic to StringInterpolatorOpt
1 parent fe9541b commit c66b8dc

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import typer.LiftCoverage
1818
import util.{SourcePosition, Property}
1919
import util.Spans.Span
2020
import coverage.*
21+
import localopt.StringInterpolatorOpt.isCompilerIntrinsic
2122

2223
/** Implements code coverage by inserting calls to scala.runtime.coverage.Invoker
2324
* ("instruments" the source code).
@@ -273,14 +274,9 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
273274
* should not be changed to {val $x = f(); T($x)}(1) but to {val $x = f(); val $y = 1; T($x)($y)}
274275
*/
275276
private def needsLift(tree: Apply)(using Context): Boolean =
276-
inline def isShortCircuitedOp(sym: Symbol) =
277+
def isShortCircuitedOp(sym: Symbol) =
277278
sym == defn.Boolean_&& || sym == defn.Boolean_||
278279

279-
inline def isCompilerIntrinsic(sym: Symbol) =
280-
sym == defn.StringContext_s ||
281-
sym == defn.StringContext_f ||
282-
sym == defn.StringContext_raw
283-
284280
def isUnliftableFun(fun: Tree) =
285281
/*
286282
* We don't want to lift a || getB(), to avoid calling getB if a is true.

compiler/src/dotty/tools/dotc/transform/localopt/StringInterpolatorOpt.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class StringInterpolatorOpt extends MiniPhase:
3131
tree match
3232
case tree: RefTree =>
3333
val sym = tree.symbol
34-
assert(sym != defn.StringContext_raw && sym != defn.StringContext_s && sym != defn.StringContext_f,
34+
assert(!StringInterpolatorOpt.isCompilerIntrinsic(sym),
3535
i"$tree in ${ctx.owner.showLocated} should have been rewritten by phase $phaseName")
3636
case _ =>
3737

@@ -162,3 +162,9 @@ class StringInterpolatorOpt extends MiniPhase:
162162
object StringInterpolatorOpt:
163163
val name: String = "interpolators"
164164
val description: String = "optimize s, f, and raw string interpolators"
165+
166+
/** Is this symbol one of the s, f or raw string interpolator? */
167+
def isCompilerIntrinsic(sym: Symbol)(using Context): Boolean =
168+
sym == defn.StringContext_s ||
169+
sym == defn.StringContext_f ||
170+
sym == defn.StringContext_raw

0 commit comments

Comments
 (0)