Skip to content

Commit 25af286

Browse files
committed
Make files invariant under rewriting
1 parent 5802f0e commit 25af286

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+196
-261
lines changed

compiler/src/dotty/tools/dotc/Driver.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,21 @@ class Driver {
7272
// Resolve classpath and class names of tasty files
7373
val (classPaths, classNames) = fileNames0.flatMap { name =>
7474
val path = Paths.get(name)
75-
if (name.endsWith(".jar")) {
75+
if (name.endsWith(".jar"))
7676
new dotty.tools.io.Jar(File(name)).toList.collect {
7777
case e if e.getName.endsWith(".tasty") =>
7878
(name, e.getName.stripSuffix(".tasty").replace("/", "."))
7979
}
80-
}
8180
else if (!name.endsWith(".tasty"))
8281
("", name) :: Nil
83-
else if (Files.exists(path)) {
82+
else if (Files.exists(path))
8483
TastyFileUtil.getClassName(path) match {
8584
case Some(res) => res:: Nil
8685
case _ =>
8786
ctx0.error(s"Could not load classname from $name.")
8887
("", name) :: Nil
8988
}
90-
} else {
89+
else {
9190
ctx0.error(s"File $name does not exist.")
9291
("", name) :: Nil
9392
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,9 @@ object desugar {
454454
if (isCaseClass)
455455
ctx.error(CaseClassMissingParamList(cdef), namePos)
456456
ListOfNil
457-
} else if (isCaseClass && originalVparamss.head.exists(_.mods.isOneOf(GivenOrImplicit))) {
458-
ctx.error("Case classes should have a non-implicit parameter list", namePos)
457+
}
458+
else if (isCaseClass && originalVparamss.head.exists(_.mods.isOneOf(GivenOrImplicit))) {
459+
ctx.error("Case classes should have a non-implicit parameter list", namePos)
459460
ListOfNil
460461
}
461462
else originalVparamss.nestedMap(toDefParam(_, keepAnnotations = false))
@@ -717,12 +718,11 @@ object desugar {
717718
}
718719
else if (companionMembers.nonEmpty || companionDerived.nonEmpty || isEnum)
719720
companionDefs(anyRef, companionMembers)
720-
else if (isValueClass) {
721+
else if (isValueClass)
721722
impl.constr.vparamss match {
722723
case (_ :: Nil) :: _ => companionDefs(anyRef, Nil)
723724
case _ => Nil // error will be emitted in typer
724725
}
725-
}
726726
else Nil
727727

728728
enumCompanionRef match {
@@ -1133,12 +1133,11 @@ object desugar {
11331133
case tree: MemberDef =>
11341134
var tested: MemberDef = tree
11351135
def fail(msg: String) = ctx.error(msg, tree.sourcePos)
1136-
def checkApplicable(flag: Flag, test: MemberDefTest): Unit = {
1136+
def checkApplicable(flag: Flag, test: MemberDefTest): Unit =
11371137
if (tested.mods.is(flag) && !test.applyOrElse(tree, (md: MemberDef) => false)) {
11381138
fail(i"modifier `${flag.flagsString}` is not allowed for this definition")
11391139
tested = tested.withMods(tested.mods.withoutFlags(flag))
11401140
}
1141-
}
11421141
checkApplicable(Opaque, legalOpaque)
11431142
tested
11441143
case _ =>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
4242
if (param.info.isRepeatedParam) {
4343
for (arg <- args) f(param, arg)
4444
true
45-
} else args match {
45+
}
46+
else args match {
4647
case Nil => false
4748
case arg :: args1 =>
4849
f(param, args.head)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ object Trees {
14681468
case _ =>
14691469
foldMoreCases(x, tree)
14701470
}
1471-
}
1471+
}
14721472

14731473
def foldMoreCases(x: X, tree: Tree)(implicit ctx: Context): X = {
14741474
assert(ctx.reporter.errorsReported || ctx.mode.is(Mode.Interactive), tree)

compiler/src/dotty/tools/dotc/core/CheckRealizable.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class CheckRealizable(implicit ctx: Context) {
107107
if (tp.info.isStable && tpInfoRealizable == Realizable) {
108108
sym.setFlag(StableRealizable)
109109
Realizable
110-
} else r
110+
}
111+
else r
111112
}
112113
}
113114
case _: SingletonType | NoPrefix =>

compiler/src/dotty/tools/dotc/core/Comments.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,8 @@ object Comments {
371371
superComment(sym) foreach { sc =>
372372
val superSections = tagIndex(sc)
373373
replaceWith(sc.substring(3, startTag(sc, superSections)))
374-
for (sec @ (start, end) <- superSections) {
374+
for (sec @ (start, end) <- superSections)
375375
if (!isMovable(sc, sec)) out append sc.substring(start, end)
376-
}
377376
}
378377
case "" => idx += 1
379378
case vname =>

compiler/src/dotty/tools/dotc/core/Names.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ object Names {
390390
override def toString: String =
391391
if (length == 0) ""
392392
else {
393-
if (Config.checkBackendNames) {
393+
if (Config.checkBackendNames)
394394
if (!toStringOK) {
395395
// We print the stacktrace instead of doing an assert directly,
396396
// because asserts are caught in exception handlers which might
@@ -400,7 +400,6 @@ object Names {
400400
Thread.dumpStack()
401401
assert(false)
402402
}
403-
}
404403
new String(chrs, start, length)
405404
}
406405

compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,11 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
484484

485485
def foreachTypeVar(op: TypeVar => Unit): Unit =
486486
boundsMap.foreachBinding { (poly, entries) =>
487-
for (i <- 0 until paramCount(entries)) {
487+
for (i <- 0 until paramCount(entries))
488488
typeVar(entries, i) match {
489489
case tv: TypeVar if !tv.inst.exists => op(tv)
490490
case _ =>
491491
}
492-
}
493492
}
494493

495494
def & (other: Constraint, otherHasErrors: Boolean)(implicit ctx: Context): OrderingConstraint = {

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,19 @@ trait SymDenotations { this: Context =>
8686
else {
8787
implicit val ctx = this
8888
val initial = denot.initial
89-
if ((initial ne denot) || ctx.phaseId != initial.validFor.firstPhaseId) {
89+
if ((initial ne denot) || ctx.phaseId != initial.validFor.firstPhaseId)
9090
ctx.withPhase(initial.validFor.firstPhaseId).traceInvalid(initial)
91-
} else try {
91+
else try {
9292
val owner = denot.owner.denot
9393
if (!traceInvalid(owner)) explainSym("owner is invalid")
9494
else if (!owner.isClass || owner.isRefinementClass || denot.isSelfSym) true
9595
else if (owner.unforcedDecls.lookupAll(denot.name) contains denot.symbol) true
9696
else explainSym(s"decls of ${show(owner)} are ${owner.unforcedDecls.lookupAll(denot.name).toList}, do not contain ${denot.symbol}")
97-
} catch {
97+
}
98+
catch {
9899
case ex: StaleSymbol => explainSym(s"$ex was thrown")
99100
}
100-
}
101+
}
101102
case _ =>
102103
explain("denotation is not a SymDenotation")
103104
}

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
466466

467467
case _ =>
468468
val cls2 = tp2.symbol
469-
if (cls2.isClass) {
469+
if (cls2.isClass)
470470
if (cls2.typeParams.isEmpty) {
471471
if (cls2 eq AnyKindClass) return true
472472
if (tp1.isRef(NothingClass)) return true
@@ -485,7 +485,6 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
485485
}
486486
else if (tp1.isLambdaSub && !tp1.isRef(AnyKindClass))
487487
return recur(tp1, EtaExpansion(cls2.typeRef))
488-
}
489488
fourthTry
490489
}
491490

0 commit comments

Comments
 (0)