Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1109,8 +1109,8 @@ object desugar {
case Block(Nil, expr) => expr // important for interpolated string as patterns, see i1773.scala
case t => t
}

Apply(Select(Apply(Ident(nme.StringContext), strs), id), elems)
// This is a deliberate departure from scalac, where StringContext is not rooted (See #4732)
Apply(Select(Apply(scalaDot(nme.StringContext), strs), id), elems)
case InfixOp(l, op, r) =>
if (ctx.mode is Mode.Type)
AppliedTypeTree(op, l :: r :: Nil) // op[l, r]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ class StringInterpolatorOpt extends MiniPhase {

private object StringContextApply {
def unapply(tree: Select)(implicit ctx: Context): Boolean = {
tree.symbol.eq(defn.StringContextModule_apply) && {
val qualifier = tree.qualifier
qualifier.isInstanceOf[Ident] && qualifier.symbol.eq(defn.StringContextModule)
}
tree.symbol.eq(defn.StringContextModule_apply) &&
tree.qualifier.symbol.eq(defn.StringContextModule)
}
}

Expand Down
10 changes: 10 additions & 0 deletions tests/run/rooted_stringcontext.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object StringContext {
val i = 42
val s = s"Answer: $i"
}

object Test {
def main(args: Array[String]): Unit = {
assert(StringContext.s == "Answer: 42")
}
}