Skip to content

Commit 086c891

Browse files
committed
Address review comments
* Simplify grabbing of rooted handle to StringContext * Simplify StringContext tree unapply * Remove check file for test and use an assert instead
1 parent 426011b commit 086c891

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,12 +1110,7 @@ object desugar {
11101110
case t => t
11111111
}
11121112
// This is a deliberate departure from scalac, where StringContext is not rooted (See #4732)
1113-
val rootedStringContext = {
1114-
val rootPkg = Ident(nme.ROOTPKG)
1115-
val scalaPkg = Select(rootPkg, nme.scala_)
1116-
Select(scalaPkg, nme.StringContext)
1117-
}
1118-
Apply(Select(Apply(rootedStringContext, strs), id), elems)
1113+
Apply(Select(Apply(scalaDot(nme.StringContext), strs), id), elems)
11191114
case InfixOp(l, op, r) =>
11201115
if (ctx.mode is Mode.Type)
11211116
AppliedTypeTree(op, l :: r :: Nil) // op[l, r]

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ class StringInterpolatorOpt extends MiniPhase {
3434

3535
private object StringContextApply {
3636
def unapply(tree: Select)(implicit ctx: Context): Boolean = {
37-
tree.symbol.eq(defn.StringContextModule_apply) && {
38-
val qualifier = tree.qualifier
39-
qualifier.isInstanceOf[Select] && qualifier.symbol.eq(defn.StringContextModule)
40-
}
37+
tree.symbol.eq(defn.StringContextModule_apply) &&
38+
tree.qualifier.symbol.eq(defn.StringContextModule)
4139
}
4240
}
4341

tests/run/rooted_stringcontext.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/run/rooted_stringcontext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ object StringContext {
55

66
object Test {
77
def main(args: Array[String]): Unit = {
8-
println(StringContext.s)
8+
assert(StringContext.s == "Answer: 42")
99
}
1010
}

0 commit comments

Comments
 (0)