Skip to content

Commit 6181525

Browse files
committed
Address reviewers comments
1 parent 4825980 commit 6181525

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,8 @@ object JavaParsers {
605605
makeTemplate(List(), statics, List(), false)).withMods((cdef.mods & (Flags.AccessFlags | Flags.JavaDefined)).toTermFlags)
606606
}
607607

608-
private def wild = Ident(nme.WILDCARD)
609-
private def wildList = List(wild) // OPT This list is shared for performance.
610-
611608
def importCompanionObject(cdef: TypeDef): Tree =
612-
Import(Ident(cdef.name.toTermName).withPos(NoPosition), wildList)
609+
Import(Ident(cdef.name.toTermName).withPos(NoPosition), Ident(nme.WILDCARD) :: Nil)
613610

614611
// Importing the companion object members cannot be done uncritically: see
615612
// ticket #2377 wherein a class contains two static inner classes, each of which

src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,28 @@ object Parsers {
5959

6060
/* ------------- POSITIONS ------------------------------------------- */
6161

62+
/** Positions tree.
63+
* If `t` does not have a position yet, set its position to the given one.
64+
*/
65+
def atPos[T <: Positioned](pos: Position)(t: T): T =
66+
if (t.pos.isSourceDerived) t else t.withPos(pos)
67+
6268
def atPos[T <: Positioned](start: Offset, point: Offset, end: Offset)(t: T): T =
6369
atPos(Position(start, end, point))(t)
6470

71+
/** If the last read offset is strictly greater than `start`, position tree
72+
* to position spanning from `start` to last read offset, with given point.
73+
* If the last offset is less than or equal to start, the tree `t` did not
74+
* consume any source for its construction. In this case, don't position it yet,
75+
* but wait for its position to be determined by `setChildPositions` when the
76+
* parent node is positioned.
77+
*/
6578
def atPos[T <: Positioned](start: Offset, point: Offset)(t: T): T =
6679
if (in.lastOffset > start) atPos(start, point, in.lastOffset)(t) else t
6780

6881
def atPos[T <: Positioned](start: Offset)(t: T): T =
6982
atPos(start, start)(t)
7083

71-
def atPos[T <: Positioned](pos: Position)(t: T): T =
72-
if (t.pos.isSourceDerived) t else t.withPos(pos)
73-
7484
def nameStart: Offset =
7585
if (in.token == BACKQUOTED_IDENT) in.offset + 1 else in.offset
7686

0 commit comments

Comments
 (0)