Skip to content

Commit

Permalink
refactor names
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed May 31, 2021
1 parent 88b39db commit 3ebfd4a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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 @@ -182,7 +182,7 @@ object desugar {
tpt = TypeTree(defn.UnitType),
rhs = setterRhs
).withMods((mods | Accessor) &~ (CaseAccessor | GivenOrImplicit | Lazy))
.dropEndIndex
.dropEndIndex() // the end marker should only appear on the getter definition
Thicket(vdef1, setter)
}
else vdef1
Expand Down Expand Up @@ -875,7 +875,7 @@ object desugar {
val modul = ValDef(moduleName, clsRef, New(clsRef, Nil))
.withMods(mods.toTermFlags & RetainedModuleValFlags | ModuleValCreationFlags)
.withSpan(mdef.span.startPos)
.withEndIndex(copyFrom=mdef)
.withEndIndex(copyFrom = mdef) // copy over the end market position to the module val
val ValDef(selfName, selfTpt, _) = impl.self
val selfMods = impl.self.mods
if (!selfTpt.isEmpty) report.error(ObjectMayNotHaveSelfType(mdef), impl.self.srcPos)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ object Trees {
self.withAttachment(EndIndex, index)

final def withEndIndex(copyFrom: WithEndMarker): self.type =
copyFrom.endIndex.foreach(index => withEndIndex(index))
copyFrom.endIndex.foreach(withEndIndex)
this

final def dropEndIndex: self.type =
final def dropEndIndex(): self.type =
self.removeAttachment(EndIndex)
this

Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1293,20 +1293,20 @@ object Parsers {
case _: (ForYield | ForDo) => in.token == FOR
case _ => false

def matchesWithUpdated(stat: Tree): Boolean = {
def matchesAndSetEnd(stat: Tree): Boolean = {
val didMatch = matches(stat)
if didMatch then
stat match
case stat: WithEndMarker =>
stat.withEndIndex(index=in.lastCharOffset)
stat.withEndIndex(index = in.lastCharOffset)
case _ =>
()
didMatch
}

if in.token == END then
val start = in.skipToken()
if stats.isEmpty || !matchesWithUpdated(stats.last) then
if stats.isEmpty || !matchesAndSetEnd(stats.last) then
syntaxError("misaligned end marker", Span(start, in.lastCharOffset))
in.token = IDENTIFIER // Leaving it as the original token can confuse newline insertion
in.nextToken()
Expand Down

0 comments on commit 3ebfd4a

Please sign in to comment.