Skip to content

Commit dc787d5

Browse files
Merge pull request #9711 from kpbochenek/fix-then-syntax-2
Align if then syntax without parens batch2
2 parents 68d5d68 + c8e4fdb commit dc787d5

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ trait ConstraintHandling {
372372
*/
373373
def instanceType(param: TypeParamRef, fromBelow: Boolean)(using Context): Type = {
374374
val approx = approximation(param, fromBelow).simplified
375-
if (fromBelow)
375+
if fromBelow then
376376
val widened = widenInferred(approx, param)
377377
// Widening can add extra constraints, in particular the widened type might
378378
// be a type variable which is now instantiated to `param`, and therefore

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ object Parsers {
20742074
if isIdent(nme.raw.STAR) then
20752075
in.nextToken()
20762076
if !(location.inArgs && in.token == RPAREN) then
2077-
if opStack.nonEmpty
2077+
if opStack.nonEmpty then
20782078
report.errorOrMigrationWarning(
20792079
em"""`_*` can be used only for last argument of method application.
20802080
|It is no longer allowed in operands of infix operations.""",
@@ -2151,7 +2151,7 @@ object Parsers {
21512151
val name = bindingName()
21522152
val t =
21532153
if (in.token == COLON && location == Location.InBlock) {
2154-
if sourceVersion.isAtLeast(`3.1`)
2154+
if sourceVersion.isAtLeast(`3.1`) then
21552155
// Don't error in non-strict mode, as the alternative syntax "implicit (x: T) => ... "
21562156
// is not supported by Scala2.x
21572157
report.errorOrMigrationWarning(
@@ -3331,21 +3331,19 @@ object Parsers {
33313331
}
33323332
if (migrateTo3) newLineOptWhenFollowedBy(LBRACE)
33333333
val rhs =
3334-
if (in.token == EQUALS)
3334+
if in.token == EQUALS then
33353335
in.nextToken()
33363336
subExpr()
3337-
else if (!tpt.isEmpty)
3337+
else if !tpt.isEmpty then
33383338
EmptyTree
3339-
else if (scala2ProcedureSyntax(": Unit")) {
3339+
else if scala2ProcedureSyntax(": Unit") then
33403340
tpt = scalaUnit
33413341
if (in.token == LBRACE) expr()
33423342
else EmptyTree
3343-
}
3344-
else {
3343+
else
33453344
if (!isExprIntro) syntaxError(MissingReturnType(), in.lastOffset)
33463345
accept(EQUALS)
33473346
expr()
3348-
}
33493347

33503348
val ddef = DefDef(name, tparams, vparamss, tpt, rhs)
33513349
if (isBackquoted(ident)) ddef.pushAttachment(Backquoted, ())
@@ -3357,7 +3355,7 @@ object Parsers {
33573355
* | `{' SelfInvocation {semi BlockStat} `}'
33583356
*/
33593357
val constrExpr: () => Tree = () =>
3360-
if (in.isNestedStart)
3358+
if in.isNestedStart then
33613359
atSpan(in.offset) {
33623360
inBracesOrIndented {
33633361
val stats = selfInvocation() :: (
@@ -3779,9 +3777,9 @@ object Parsers {
37793777
stats ++= importClause(EXPORT, Export.apply)
37803778
else if isIdent(nme.extension) && followingIsExtension() then
37813779
stats += extension()
3782-
else if isDefIntro(modifierTokens)
3780+
else if isDefIntro(modifierTokens) then
37833781
stats +++= defOrDcl(in.offset, defAnnotsMods(modifierTokens))
3784-
else if (!isStatSep)
3782+
else if !isStatSep then
37853783
if (in.token == CASE)
37863784
syntaxErrorOrIncomplete(OnlyCaseClassOrCaseObjectAllowed())
37873785
else

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ object Inliner {
7373
val startId = ctx.source.nextId
7474

7575
if tree.symbol.denot != SymDenotations.NoDenotation
76-
&& tree.symbol.owner.companionModule == defn.CompiletimeTestingPackageObject then
76+
&& tree.symbol.owner.companionModule == defn.CompiletimeTestingPackageObject
77+
then
7778
if (tree.symbol == defn.CompiletimeTesting_typeChecks) return Intrinsics.typeChecks(tree)
7879
if (tree.symbol == defn.CompiletimeTesting_typeCheckErrors) return Intrinsics.typeCheckErrors(tree)
7980

0 commit comments

Comments
 (0)