@@ -21,7 +21,8 @@ import Types._
21
21
import Symbols ._
22
22
import Phases ._
23
23
24
- import dotty .tools .dotc .util .{SourcePosition , NoSourcePosition }
24
+ import dotty .tools .dotc .util
25
+ import dotty .tools .dotc .util .Spans
25
26
import Decorators ._
26
27
import tpd ._
27
28
@@ -41,7 +42,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
41
42
type CompilationUnit = dotc.CompilationUnit
42
43
type Constant = Constants .Constant
43
44
type Literal = tpd.Literal
44
- type Position = SourcePosition
45
+ type Position = Spans . Span
45
46
type Name = Names .Name
46
47
type ClassDef = tpd.TypeDef
47
48
type TypeDef = tpd.TypeDef
@@ -77,7 +78,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
77
78
type Closure = tpd.Closure
78
79
79
80
val NoSymbol : Symbol = Symbols .NoSymbol
80
- val NoPosition : Position = NoSourcePosition
81
+ val NoPosition : Position = Spans . NoSpan
81
82
val EmptyTree : Tree = tpd.EmptyTree
82
83
83
84
@@ -383,12 +384,14 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
383
384
def debuglog (msg : => String ): Unit = ctx.debuglog(msg)
384
385
def informProgress (msg : String ): Unit = ctx.informProgress(msg)
385
386
def log (msg : => String ): Unit = ctx.log(msg)
386
- def error (pos : SourcePosition , msg : String ): Unit = ctx.error(msg, pos)
387
- def warning (pos : SourcePosition , msg : String ): Unit = ctx.warning(msg, pos)
387
+ def error (pos : Position , msg : String ): Unit = ctx.error(msg, sourcePos( pos) )
388
+ def warning (pos : Position , msg : String ): Unit = ctx.warning(msg, sourcePos( pos) )
388
389
def abort (msg : String ): Nothing = {
389
390
ctx.error(msg)
390
391
throw new RuntimeException (msg)
391
392
}
393
+ def sourcePos (pos : Position )(implicit ctx : Context ): util.SourcePosition =
394
+ ctx.source.atSpan(pos)
392
395
393
396
def emitAsmp : Option [String ] = None
394
397
@@ -562,7 +565,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
562
565
563
566
implicit def positionHelper (a : Position ): PositionHelper = new PositionHelper {
564
567
def isDefined : Boolean = a.exists
565
- def line : Int = a .line + 1
568
+ def line : Int = sourcePos(a) .line + 1
566
569
def finalPosition : Position = a
567
570
}
568
571
@@ -586,7 +589,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
586
589
implicit def treeHelper (a : Tree ): TreeHelper = new TreeHelper {
587
590
def symbol : Symbol = a.symbol
588
591
589
- def pos : Position = a.sourcePos
592
+ def pos : Position = a.span
590
593
591
594
def isEmpty : Boolean = a.isEmpty
592
595
@@ -800,15 +803,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
800
803
801
804
802
805
def freshLocal (cunit : CompilationUnit , name : String , tpe : Type , pos : Position , flags : Flags ): Symbol = {
803
- ctx.newSymbol(sym, name.toTermName, termFlagSet(flags), tpe, NoSymbol , pos.span )
806
+ ctx.newSymbol(sym, name.toTermName, termFlagSet(flags), tpe, NoSymbol , pos)
804
807
}
805
808
806
809
def getter (clz : Symbol ): Symbol = decorateSymbol(sym).getter
807
810
def setter (clz : Symbol ): Symbol = decorateSymbol(sym).setter
808
811
809
812
def moduleSuffix : String = " " // todo: validate that names already have $ suffix
810
813
def outputDirectory : AbstractFile = DottyBackendInterface .this .outputDirectory
811
- def pos : Position = sym.sourcePos
814
+ def pos : Position = sym.span
812
815
813
816
def throwsAnnotations : List [Symbol ] = Nil
814
817
@@ -1104,7 +1107,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1104
1107
def _1 : Type = field.tpe match {
1105
1108
case JavaArrayType (elem) => elem
1106
1109
case _ =>
1107
- error(field.sourcePos , s " JavaSeqArray with type ${field.tpe} reached backend: $field" )
1110
+ error(field.span , s " JavaSeqArray with type ${field.tpe} reached backend: $field" )
1108
1111
UnspecifiedErrorType
1109
1112
}
1110
1113
def _2 : List [Tree ] = field.elems
0 commit comments