Skip to content

Commit 96b0854

Browse files
authored
Merge pull request #7114 from dotty-staging/change-indent
Change indentation rules to allow copy-paste
2 parents 6a08e09 + f8bf15b commit 96b0854

File tree

242 files changed

+3644
-2729
lines changed

Some content is hidden

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

242 files changed

+3644
-2729
lines changed

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ class JSCodeGen()(implicit ctx: Context) {
728728
else genExpr(tree)
729729

730730
//if (!isScalaJSDefinedJSClass(currentClassSym)) {
731-
val flags = js.MemberFlags.empty.withNamespace(namespace)
732-
js.MethodDef(flags, methodName, jsParams, resultIRType, Some(genBody()))(
731+
val flags = js.MemberFlags.empty.withNamespace(namespace)
732+
js.MethodDef(flags, methodName, jsParams, resultIRType, Some(genBody()))(
733733
optimizerHints, None)
734734
/*} else {
735735
assert(!namespace.isStatic, tree.span)

compiler/src/dotty/tools/backend/sjs/JSPositions.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class JSPositions()(implicit ctx: Context) {
6666
case ScalaJSOptions.URIMap(from, to) if matches(from) =>
6767
val relURI = from.relativize(srcURI)
6868
to.fold(relURI)(_.resolve(relURI))
69-
} getOrElse*/ srcURI
69+
} getOrElse*/
70+
srcURI
7071
}
7172
}
7273
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,15 @@ class Driver {
5959
MacroClassLoader.init(ctx)
6060
Positioned.updateDebugPos(ctx)
6161

62-
if (!ctx.settings.YdropComments.value(ctx) || ctx.mode.is(Mode.ReadComments)) {
62+
if (!ctx.settings.YdropComments.value(ctx) || ctx.mode.is(Mode.ReadComments))
6363
ctx.setProperty(ContextDoc, new ContextDocstrings)
64-
}
6564

6665
val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)(ctx)
6766
fromTastySetup(fileNames, ctx)
6867
}
6968

7069
/** Setup extra classpath and figure out class names for tasty file inputs */
71-
protected def fromTastySetup(fileNames0: List[String], ctx0: Context): (List[String], Context) = {
70+
protected def fromTastySetup(fileNames0: List[String], ctx0: Context): (List[String], Context) =
7271
if (ctx0.settings.fromTasty.value(ctx0)) {
7372
// Resolve classpath and class names of tasty files
7473
val (classPaths, classNames) = fileNames0.flatMap { name =>
@@ -98,8 +97,8 @@ class Driver {
9897
val fullClassPath = (classPaths1 :+ ctx1.settings.classpath.value(ctx1)).mkString(java.io.File.pathSeparator)
9998
ctx1.setSetting(ctx1.settings.classpath, fullClassPath)
10099
(classNames, ctx1)
101-
} else (fileNames0, ctx0)
102-
}
100+
}
101+
else (fileNames0, ctx0)
103102

104103
/** Entry point to the compiler that can be conveniently used with Java reflection.
105104
*

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
102102
def compile(fileNames: List[String]): Unit = try {
103103
val sources = fileNames.map(ctx.getSource(_))
104104
compileSources(sources)
105-
} catch {
105+
}
106+
catch {
106107
case NonFatal(ex) =>
107108
ctx.echo(i"exception occurred while compiling $units%, %")
108109
throw ex
@@ -157,12 +158,10 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
157158
val profileBefore = profiler.beforePhase(phase)
158159
units = phase.runOn(units)
159160
profiler.afterPhase(phase, profileBefore)
160-
if (ctx.settings.Xprint.value.containsPhase(phase)) {
161-
for (unit <- units) {
161+
if (ctx.settings.Xprint.value.containsPhase(phase))
162+
for (unit <- units)
162163
lastPrintedTree =
163164
printTree(lastPrintedTree)(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
164-
}
165-
}
166165
ctx.informTime(s"$phase ", start)
167166
Stats.record(s"total trees at end of $phase", ast.Trees.ntrees)
168167
for (unit <- units)

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ object desugar {
308308
* case '{ @patternBindHole def `$a`(...) = ...; ... `$a`() ... } => a
309309
* ```
310310
*/
311-
def transformQuotedPatternName(tree: ValOrDefDef)(implicit ctx: Context): ValOrDefDef = {
311+
def transformQuotedPatternName(tree: ValOrDefDef)(implicit ctx: Context): ValOrDefDef =
312312
if (ctx.mode.is(Mode.QuotedPattern) && !isBackquoted(tree) && tree.name != nme.ANON_FUN && tree.name.startsWith("$")) {
313313
val mods = tree.mods.withAddedAnnotation(New(ref(defn.InternalQuoted_patternBindHoleAnnot.typeRef)).withSpan(tree.span))
314314
tree.withMods(mods)
315-
} else tree
316-
}
315+
}
316+
else tree
317317

318318
/** Add an explicit ascription to the `expectedTpt` to every tail splice.
319319
*
@@ -926,7 +926,8 @@ object desugar {
926926
val patternBindHoleAnnot = New(ref(defn.InternalQuoted_patternBindHoleAnnot.typeRef)).withSpan(tree.span)
927927
val mods = tree.mods.withAddedAnnotation(patternBindHoleAnnot)
928928
tree.withMods(mods)
929-
} else tree
929+
}
930+
else tree
930931
}
931932

932933
/** The normalized name of `mdef`. This means
@@ -953,7 +954,8 @@ object desugar {
953954
impl.body.find {
954955
case dd: DefDef if dd.mods.is(Extension) => true
955956
case _ => false
956-
} match {
957+
}
958+
match {
957959
case Some(DefDef(name, _, (vparam :: _) :: _, _, _)) =>
958960
s"${name}_of_${inventTypeName(vparam.tpt)}"
959961
case _ =>
@@ -1007,7 +1009,7 @@ object desugar {
10071009
case id: Ident =>
10081010
expandSimpleEnumCase(id.name.asTermName, mods,
10091011
Span(id.span.start, id.span.end, id.span.start))
1010-
}
1012+
}
10111013
else {
10121014
val pats1 = if (tpt.isEmpty) pats else pats map (Typed(_, tpt))
10131015
pats1 map (makePatDef(pdef, mods, _, rhs))
@@ -1068,7 +1070,7 @@ object desugar {
10681070
if (tupleOptimizable) // include `_`
10691071
pat match {
10701072
case Tuple(pats) =>
1071-
pats.map { case id: Ident => id -> TypeTree() }
1073+
pats.map { case id: Ident => id -> TypeTree() }
10721074
}
10731075
else getVariables(pat) // no `_`
10741076

@@ -1127,11 +1129,12 @@ object desugar {
11271129
case tree: MemberDef =>
11281130
var tested: MemberDef = tree
11291131
def fail(msg: String) = ctx.error(msg, tree.sourcePos)
1130-
def checkApplicable(flag: Flag, test: MemberDefTest): Unit =
1132+
def checkApplicable(flag: Flag, test: MemberDefTest): Unit = {
11311133
if (tested.mods.is(flag) && !test.applyOrElse(tree, (md: MemberDef) => false)) {
11321134
fail(i"modifier `${flag.flagsString}` is not allowed for this definition")
11331135
tested = tested.withMods(tested.mods.withoutFlags(flag))
11341136
}
1137+
}
11351138
checkApplicable(Opaque, legalOpaque)
11361139
tested
11371140
case _ =>
@@ -1296,7 +1299,7 @@ object desugar {
12961299
if (isGenericTuple) Apply(Select(refOfDef(param), nme.apply), Literal(Constant(n)))
12971300
else Select(refOfDef(param), nme.selectorName(n))
12981301
val vdefs =
1299-
params.zipWithIndex.map{
1302+
params.zipWithIndex.map {
13001303
case (param, idx) =>
13011304
DefDef(param.name, Nil, Nil, TypeTree(), selector(idx)).withSpan(param.span)
13021305
}
@@ -1338,7 +1341,7 @@ object desugar {
13381341
.withSpan(original.span.withPoint(named.span.start))
13391342
val mayNeedSetter = valDef(vdef)
13401343
mayNeedSetter
1341-
}
1344+
}
13421345

13431346
private def derivedDefDef(original: Tree, named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit src: SourceFile) =
13441347
DefDef(named.name.asTermName, Nil, Nil, tpt, rhs)
@@ -1551,7 +1554,8 @@ object desugar {
15511554
RefinedTypeTree(polyFunctionTpt, List(
15521555
DefDef(nme.apply, applyTParams, List(applyVParams), res, EmptyTree)
15531556
))
1554-
} else {
1557+
}
1558+
else {
15551559
// Desugar [T_1, ..., T_M] -> (x_1: P_1, ..., x_N: P_N) => body
15561560
// Into new scala.PolyFunction { def apply[T_1, ..., T_M](x_1: P_1, ..., x_N: P_N) = body }
15571561

@@ -1606,7 +1610,8 @@ object desugar {
16061610
Annotated(
16071611
AppliedTypeTree(ref(seqType), t),
16081612
New(ref(defn.RepeatedAnnot.typeRef), Nil :: Nil))
1609-
} else {
1613+
}
1614+
else {
16101615
assert(ctx.mode.isExpr || ctx.reporter.errorsReported || ctx.mode.is(Mode.Interactive), ctx.mode)
16111616
Select(t, op.name)
16121617
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ object MainProxies {
4545
def pos = mainFun.sourcePos
4646
val argsRef = Ident(nme.args)
4747

48-
def addArgs(call: untpd.Tree, mt: MethodType, idx: Int): untpd.Tree = {
48+
def addArgs(call: untpd.Tree, mt: MethodType, idx: Int): untpd.Tree =
4949
if (mt.isImplicitMethod) {
5050
ctx.error(s"@main method cannot have implicit parameters", pos)
5151
call
@@ -71,7 +71,6 @@ object MainProxies {
7171
call1
7272
}
7373
}
74-
}
7574

7675
var result: List[TypeDef] = Nil
7776
if (!mainFun.owner.isStaticOwner)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ object NavigateAST {
9797
case _ =>
9898
}
9999
childPath(p.productIterator, p :: path)
100-
} else path
100+
}
101+
else path
101102
singlePath(from, Nil)
102103
}
103104
}

0 commit comments

Comments
 (0)