Skip to content

Commit 6540ad7

Browse files
committed
Address view: avoid accidental usage of Context inside class
1 parent f4ecf94 commit 6540ad7

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,21 @@ import dotty.tools.tasty.TastyBuffer
88
import TastyBuffer._
99

1010
import ast._
11-
import ast.Trees._
12-
import ast.Trees.WithLazyField
11+
import Trees.WithLazyField
1312
import util.{SourceFile, NoSource}
1413
import core._
15-
import Contexts._, Symbols._, Annotations._, Decorators._
14+
import Annotations._, Decorators._
1615
import collection.mutable
1716
import util.Spans._
1817

19-
import scala.annotation.constructorOnly
20-
2118
class PositionPickler(
2219
pickler: TastyPickler,
2320
addrOfTree: PositionPickler.TreeToAddr,
24-
treeAnnots: untpd.MemberDef => List[tpd.Tree])(using @constructorOnly ctx: Context) {
21+
treeAnnots: untpd.MemberDef => List[tpd.Tree],
22+
relativePathReference: String){
2523

2624
import ast.tpd._
2725

28-
val relativePathReference = ctx.settings.sourceroot.value
29-
3026
val buf: TastyBuffer = new TastyBuffer(5000)
3127
pickler.newSection(PositionsSection, buf)
3228

compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ object PickledQuotes {
167167
treePkl.compactify()
168168
if tree.span.exists then
169169
val positionWarnings = new mutable.ListBuffer[String]()
170-
new PositionPickler(pickler, treePkl.buf.addrOfTree, treePkl.treeAnnots)
170+
val reference = ctx.settings.sourceroot.value
171+
new PositionPickler(pickler, treePkl.buf.addrOfTree, treePkl.treeAnnots, reference)
171172
.picklePositions(ctx.compilationUnit.source, tree :: Nil, positionWarnings)
172173
positionWarnings.foreach(report.warning(_))
173174

compiler/src/dotty/tools/dotc/transform/Pickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class Pickler extends Phase {
7272
Future {
7373
treePkl.compactify()
7474
if tree.span.exists then
75-
new PositionPickler(pickler, treePkl.buf.addrOfTree, treePkl.treeAnnots)
75+
val reference = ctx.settings.sourceroot.value
76+
new PositionPickler(pickler, treePkl.buf.addrOfTree, treePkl.treeAnnots, reference)
7677
.picklePositions(unit.source, tree :: Nil, positionWarnings)
7778

7879
if !ctx.settings.YdropComments.value then

0 commit comments

Comments
 (0)