File tree 2 files changed +9
-7
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import typer.LiftCoverage
18
18
import util .{SourcePosition , Property }
19
19
import util .Spans .Span
20
20
import coverage .*
21
+ import localopt .StringInterpolatorOpt .isCompilerIntrinsic
21
22
22
23
/** Implements code coverage by inserting calls to scala.runtime.coverage.Invoker
23
24
* ("instruments" the source code).
@@ -278,14 +279,9 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
278
279
* should not be changed to {val $x = f(); T($x)}(1) but to {val $x = f(); val $y = 1; T($x)($y)}
279
280
*/
280
281
private def needsLift (tree : Apply )(using Context ): Boolean =
281
- inline def isShortCircuitedOp (sym : Symbol ) =
282
+ def isShortCircuitedOp (sym : Symbol ) =
282
283
sym == defn.Boolean_&& || sym == defn.Boolean_||
283
284
284
- inline def isCompilerIntrinsic (sym : Symbol ) =
285
- sym == defn.StringContext_s ||
286
- sym == defn.StringContext_f ||
287
- sym == defn.StringContext_raw
288
-
289
285
def isUnliftableFun (fun : Tree ) =
290
286
/*
291
287
* 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:
31
31
tree match
32
32
case tree : RefTree =>
33
33
val sym = tree.symbol
34
- assert(sym != defn. StringContext_raw && sym != defn. StringContext_s && sym != defn. StringContext_f ,
34
+ assert(! StringInterpolatorOpt .isCompilerIntrinsic( sym) ,
35
35
i " $tree in ${ctx.owner.showLocated} should have been rewritten by phase $phaseName" )
36
36
case _ =>
37
37
@@ -162,3 +162,9 @@ class StringInterpolatorOpt extends MiniPhase:
162
162
object StringInterpolatorOpt :
163
163
val name : String = " interpolators"
164
164
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