Skip to content

Commit 22eaebb

Browse files
Move isCompilerIntrinsic to StringInterpolatorOpt
1 parent c40b652 commit 22eaebb

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).
@@ -278,14 +279,9 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
278279
* should not be changed to {val $x = f(); T($x)}(1) but to {val $x = f(); val $y = 1; T($x)($y)}
279280
*/
280281
private def needsLift(tree: Apply)(using Context): Boolean =
281-
inline def isShortCircuitedOp(sym: Symbol) =
282+
def isShortCircuitedOp(sym: Symbol) =
282283
sym == defn.Boolean_&& || sym == defn.Boolean_||
283284

284-
inline def isCompilerIntrinsic(sym: Symbol) =
285-
sym == defn.StringContext_s ||
286-
sym == defn.StringContext_f ||
287-
sym == defn.StringContext_raw
288-
289285
def isUnliftableFun(fun: Tree) =
290286
/*
291287
* 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)