Skip to content

Align if then syntax without parens batch2 #9711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ trait ConstraintHandling {
*/
def instanceType(param: TypeParamRef, fromBelow: Boolean)(using Context): Type = {
val approx = approximation(param, fromBelow).simplified
if (fromBelow)
if fromBelow then
val widened = widenInferred(approx, param)
// Widening can add extra constraints, in particular the widened type might
// be a type variable which is now instantiated to `param`, and therefore
Expand Down
20 changes: 9 additions & 11 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,7 @@ object Parsers {
if isIdent(nme.raw.STAR) then
in.nextToken()
if !(location.inArgs && in.token == RPAREN) then
if opStack.nonEmpty
if opStack.nonEmpty then
report.errorOrMigrationWarning(
em"""`_*` can be used only for last argument of method application.
|It is no longer allowed in operands of infix operations.""",
Expand Down Expand Up @@ -2151,7 +2151,7 @@ object Parsers {
val name = bindingName()
val t =
if (in.token == COLON && location == Location.InBlock) {
if sourceVersion.isAtLeast(`3.1`)
if sourceVersion.isAtLeast(`3.1`) then
// Don't error in non-strict mode, as the alternative syntax "implicit (x: T) => ... "
// is not supported by Scala2.x
report.errorOrMigrationWarning(
Expand Down Expand Up @@ -3331,21 +3331,19 @@ object Parsers {
}
if (migrateTo3) newLineOptWhenFollowedBy(LBRACE)
val rhs =
if (in.token == EQUALS)
if in.token == EQUALS then
in.nextToken()
subExpr()
else if (!tpt.isEmpty)
else if !tpt.isEmpty then
EmptyTree
else if (scala2ProcedureSyntax(": Unit")) {
else if scala2ProcedureSyntax(": Unit") then
tpt = scalaUnit
if (in.token == LBRACE) expr()
else EmptyTree
}
else {
else
if (!isExprIntro) syntaxError(MissingReturnType(), in.lastOffset)
accept(EQUALS)
expr()
}

val ddef = DefDef(name, tparams, vparamss, tpt, rhs)
if (isBackquoted(ident)) ddef.pushAttachment(Backquoted, ())
Expand All @@ -3357,7 +3355,7 @@ object Parsers {
* | `{' SelfInvocation {semi BlockStat} `}'
*/
val constrExpr: () => Tree = () =>
if (in.isNestedStart)
if in.isNestedStart then
atSpan(in.offset) {
inBracesOrIndented {
val stats = selfInvocation() :: (
Expand Down Expand Up @@ -3779,9 +3777,9 @@ object Parsers {
stats ++= importClause(EXPORT, Export.apply)
else if isIdent(nme.extension) && followingIsExtension() then
stats += extension()
else if isDefIntro(modifierTokens)
else if isDefIntro(modifierTokens) then
stats +++= defOrDcl(in.offset, defAnnotsMods(modifierTokens))
else if (!isStatSep)
else if !isStatSep then
if (in.token == CASE)
syntaxErrorOrIncomplete(OnlyCaseClassOrCaseObjectAllowed())
else
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ object Inliner {
val startId = ctx.source.nextId

if tree.symbol.denot != SymDenotations.NoDenotation
&& tree.symbol.owner.companionModule == defn.CompiletimeTestingPackageObject then
&& tree.symbol.owner.companionModule == defn.CompiletimeTestingPackageObject
then
if (tree.symbol == defn.CompiletimeTesting_typeChecks) return Intrinsics.typeChecks(tree)
if (tree.symbol == defn.CompiletimeTesting_typeCheckErrors) return Intrinsics.typeCheckErrors(tree)

Expand Down