Skip to content

Commit 94fbc46

Browse files
committed
Use SourceFile implicits instead of SourceInfo
No need to do the wrapping
1 parent f0d831d commit 94fbc46

File tree

14 files changed

+268
-275
lines changed

14 files changed

+268
-275
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Symbols._, StdNames._, Trees._
88
import Decorators._, transform.SymUtils._
99
import NameKinds.{UniqueName, EvidenceParamName, DefaultGetterName}
1010
import typer.FrontEnd
11-
import util.Property
11+
import util.{Property, SourceFile}
1212
import collection.mutable.ListBuffer
1313
import reporting.diagnostic.messages._
1414
import reporting.trace
@@ -43,23 +43,23 @@ object desugar {
4343

4444
// ----- DerivedTypeTrees -----------------------------------
4545

46-
class SetterParamTree(implicit @transientParam src: SourceInfo) extends DerivedTypeTree {
46+
class SetterParamTree(implicit @transientParam src: SourceFile) extends DerivedTypeTree {
4747
def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.TypeTree = tpd.TypeTree(sym.info.resultType)
4848
}
4949

50-
class TypeRefTree(implicit @transientParam src: SourceInfo) extends DerivedTypeTree {
50+
class TypeRefTree(implicit @transientParam src: SourceFile) extends DerivedTypeTree {
5151
def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.TypeTree = tpd.TypeTree(sym.typeRef)
5252
}
5353

54-
class TermRefTree(implicit @transientParam src: SourceInfo) extends DerivedTypeTree {
54+
class TermRefTree(implicit @transientParam src: SourceFile) extends DerivedTypeTree {
5555
def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.Tree = tpd.ref(sym)
5656
}
5757

5858
/** A type tree that computes its type from an existing parameter.
5959
* @param suffix String difference between existing parameter (call it `P`) and parameter owning the
6060
* DerivedTypeTree (call it `O`). We have: `O.name == P.name + suffix`.
6161
*/
62-
class DerivedFromParamTree(suffix: String)(implicit @transientParam src: SourceInfo) extends DerivedTypeTree {
62+
class DerivedFromParamTree(suffix: String)(implicit @transientParam src: SourceFile) extends DerivedTypeTree {
6363

6464
/** Make sure that for all enclosing module classes their companion classes
6565
* are completed. Reason: We need the constructor of such companion classes to
@@ -1029,7 +1029,7 @@ object desugar {
10291029
mayNeedSetter
10301030
}
10311031

1032-
private def derivedDefDef(original: Tree, named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit src: SourceInfo) =
1032+
private def derivedDefDef(original: Tree, named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit src: SourceFile) =
10331033
DefDef(named.name.asTermName, Nil, Nil, tpt, rhs)
10341034
.withMods(mods)
10351035
.withSpan(original.span.withPoint(named.span.start))
@@ -1393,6 +1393,6 @@ object desugar {
13931393
buf.toList
13941394
}
13951395

1396-
private class IrrefutableGenFrom(pat: Tree, expr: Tree)(implicit @transientParam src: SourceInfo)
1396+
private class IrrefutableGenFrom(pat: Tree, expr: Tree)(implicit @transientParam src: SourceFile)
13971397
extends GenFrom(pat, expr)
13981398
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import core._
66
import util.Spans._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._
77
import Symbols._, StdNames._, Trees._
88
import Decorators._
9-
import util.Property
9+
import util.{Property, SourceFile}
1010
import typer.ErrorReporting._
1111

1212
import scala.annotation.internal.sharable
@@ -73,7 +73,7 @@ object DesugarEnums {
7373
else if (isEnumCase(cdef)) cdef.withMods(cdef.mods.withFlags(cdef.mods.flags | Final))
7474
else cdef
7575

76-
private def valuesDot(name: String)(implicit src: SourceInfo) =
76+
private def valuesDot(name: String)(implicit src: SourceFile) =
7777
Select(Ident(nme.DOLLAR_VALUES), name.toTermName)
7878
private def registerCall(implicit ctx: Context): List[Tree] =
7979
if (enumClass.typeParams.nonEmpty) Nil

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package ast
44

55
import util.Spans._
66
import util.{SourceFile, NoSource, SourcePosition}
7-
import core.Contexts.{Context, SourceInfo}
7+
import core.Contexts.Context
88
import core.Decorators._
99
import core.Flags.{JavaDefined, Extension}
1010
import core.StdNames.nme
@@ -13,7 +13,7 @@ import annotation.internal.sharable
1313

1414
/** A base class for things that have positions (currently: modifiers and trees)
1515
*/
16-
abstract class Positioned(implicit @transientParam src: SourceInfo) extends Product with Cloneable {
16+
abstract class Positioned(implicit @transientParam src: SourceFile) extends Product with Cloneable {
1717

1818
/** A unique identifier. Among other things, used for determining the source file
1919
* component of the position.
@@ -157,7 +157,7 @@ abstract class Positioned(implicit @transientParam src: SourceInfo) extends Prod
157157

158158
/** The initial, synthetic span. This is usually the union of all positioned children's spans.
159159
*/
160-
def initialSpan(si: SourceInfo): Span = {
160+
def initialSpan(givenSource: SourceFile): Span = {
161161

162162
def include(span1: Span, p2: Positioned): Span = {
163163
val span2 = p2.span
@@ -167,7 +167,7 @@ abstract class Positioned(implicit @transientParam src: SourceInfo) extends Prod
167167
if (src `eq` src2) span1.union(span2)
168168
else if (!src.exists) {
169169
setId(src2.nextId)
170-
if (span1.exists) initialSpan(si) // we might have some mis-classified children; re-run everything
170+
if (span1.exists) initialSpan(givenSource) // we might have some mis-classified children; re-run everything
171171
else span2
172172
}
173173
else span1 // sources differ: ignore child span
@@ -197,7 +197,7 @@ abstract class Positioned(implicit @transientParam src: SourceInfo) extends Prod
197197
}
198198
n += 1
199199
}
200-
if (uniqueId == -1) setId(si.source.nextId)
200+
if (uniqueId == -1) setId(givenSource.nextId)
201201
span.toSynthetic
202202
}
203203

0 commit comments

Comments
 (0)