File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import typer.LiftCoverage
1818import util .{SourcePosition , Property }
1919import util .Spans .Span
2020import 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.
Original file line number Diff line number Diff 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:
162162object 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
You can’t perform that action at this time.
0 commit comments