From 939811bc52eaddbba2b2e86df8305fe034e74be6 Mon Sep 17 00:00:00 2001 From: Krzysztof Bochenek Date: Tue, 1 Sep 2020 17:52:46 +0200 Subject: [PATCH] align if then syntax --- .gitignore | 2 +- .../communitybuild/CommunityBuildTest.scala | 6 +- compiler/src/dotty/tools/dotc/Compiler.scala | 2 +- .../tools/dotc/core/ConstraintHandling.scala | 2 +- .../dotty/tools/dotc/core/SymbolLoaders.scala | 2 +- .../dotc/semanticdb/ExtractSemanticDB.scala | 94 +++++++++---------- .../dotty/tools/dotc/semanticdb/Tools.scala | 4 +- .../dotc/transform/CompleteJavaEnums.scala | 2 +- .../tools/dotc/transform/Constructors.scala | 2 +- .../dotc/transform/DropOuterAccessors.scala | 2 +- .../tools/dotc/transform/ElimRepeated.scala | 2 +- .../dotty/tools/dotc/transform/Getters.scala | 2 +- .../dotty/tools/dotc/transform/Pickler.scala | 2 +- .../dotty/tools/dotc/transform/Splicer.scala | 2 +- .../src/dotty/tools/dotc/typer/Inliner.scala | 5 +- .../tools/dotc/typer/QuotesAndSplices.scala | 2 +- .../dotc/semanticdb/SemanticdbTests.scala | 6 +- 17 files changed, 70 insertions(+), 69 deletions(-) diff --git a/.gitignore b/.gitignore index 8c62dbc8915d..11c3fb13d43f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,7 @@ node_modules # Metals .bloop/ .metals/ -project/metals.sbt +metals.sbt # Scala-IDE specific .scala_dependencies diff --git a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala index f10efcfa8297..e0c9b07bfd55 100644 --- a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala +++ b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala @@ -59,12 +59,12 @@ sealed trait CommunityProject: /** Publish this project to the local Maven repository */ final def publish(): Unit = - if !published + if !published then log(s"Publishing $project") - if publishCommand eq null + if publishCommand eq null then throw RuntimeException(s"Publish command is not specified for $project. Project details:\n$this") val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ publishCommand): _*) - if exitCode != 0 + if exitCode != 0 then throw RuntimeException(s"Publish command exited with code $exitCode for project $project. Project details:\n$this") published = true end CommunityProject diff --git a/compiler/src/dotty/tools/dotc/Compiler.scala b/compiler/src/dotty/tools/dotc/Compiler.scala index 48290ac3fb2f..5b208042cde3 100644 --- a/compiler/src/dotty/tools/dotc/Compiler.scala +++ b/compiler/src/dotty/tools/dotc/Compiler.scala @@ -145,7 +145,7 @@ class Compiler { def newRun(using Context): Run = { reset() val rctx = - if ctx.settings.Ysemanticdb.value + if ctx.settings.Ysemanticdb.value then ctx.addMode(Mode.ReadPositions) else ctx diff --git a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala index 8ac1b7643f00..1e44ce09eb1a 100644 --- a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala +++ b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala @@ -79,7 +79,7 @@ trait ConstraintHandling { protected def addOneBound(param: TypeParamRef, bound: Type, isUpper: Boolean)(using Context): Boolean = if !constraint.contains(param) then true - else if !isUpper && param.occursIn(bound) + else if !isUpper && param.occursIn(bound) then // We don't allow recursive lower bounds when defining a type, // so we shouldn't allow them as constraints either. false diff --git a/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala b/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala index 4f98f791c3cd..6416c38d007a 100644 --- a/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -121,7 +121,7 @@ object SymbolLoaders { def enterToplevelsFromSource( owner: Symbol, name: PreName, src: AbstractFile, scope: Scope = EmptyScope)(using Context): Unit = - if src.exists && !src.isDirectory + if src.exists && !src.isDirectory then val completer = new SourcefileLoader(src) val filePath = owner.ownersIterator.takeWhile(!_.isRoot).map(_.name.toTermName).toList diff --git a/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala b/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala index 176090c20e5b..af65a7f45259 100644 --- a/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala +++ b/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala @@ -115,7 +115,7 @@ class ExtractSemanticDB extends Phase: private def traverseAnnotsOfDefinition(sym: Symbol)(using Context): Unit = for annot <- sym.annotations do if annot.tree.span.exists - && annot.tree.span.hasLength + && annot.tree.span.hasLength then annot.tree match case tree: Typed => () // hack for inline code case tree => traverse(tree) @@ -131,7 +131,7 @@ class ExtractSemanticDB extends Phase: tree match case tree: PackageDef => if !excludeDef(tree.pid.symbol) - && tree.pid.span.hasLength + && tree.pid.span.hasLength then tree.pid match case tree: Select => registerDefinition(tree.symbol, selectSpan(tree), Set.empty, tree.source) @@ -139,15 +139,15 @@ class ExtractSemanticDB extends Phase: case tree => registerDefinition(tree.symbol, tree.span, Set.empty, tree.source) tree.stats.foreach(traverse) case tree: NamedDefTree => - if tree.symbol.isAllOf(ModuleValCreationFlags) + if tree.symbol.isAllOf(ModuleValCreationFlags) then return if !excludeDef(tree.symbol) - && tree.span.hasLength + && tree.span.hasLength then registerDefinition(tree.symbol, tree.adjustedNameSpan, symbolKinds(tree), tree.source) val privateWithin = tree.symbol.privateWithin - if privateWithin.exists + if privateWithin.exists then registerUseGuarded(None, privateWithin, spanOfSymbol(privateWithin, tree.span, tree.source), tree.source) - else if !excludeSymbol(tree.symbol) + else if !excludeSymbol(tree.symbol) then registerSymbol(tree.symbol, symbolName(tree.symbol), symbolKinds(tree)) tree match case tree: ValDef @@ -158,7 +158,7 @@ class ExtractSemanticDB extends Phase: case _ => // calls $new case tree: ValDef if tree.symbol.isSelfSym => - if tree.tpt.span.hasLength + if tree.tpt.span.hasLength then traverse(tree.tpt) case tree: DefDef if tree.symbol.isConstructor => // ignore typeparams for secondary ctors @@ -171,18 +171,18 @@ class ExtractSemanticDB extends Phase: tree.tparams.foreach(tparam => registerSymbolSimple(tparam.symbol)) tree.vparamss.foreach(_.foreach(vparam => registerSymbolSimple(vparam.symbol))) case _ => - if !tree.symbol.isGlobal + if !tree.symbol.isGlobal then localBodies(tree.symbol) = tree.rhs // ignore rhs case PatternValDef(pat, rhs) => traverse(rhs) PatternValDef.collectPats(pat).foreach(traverse) case tree => - if !excludeChildren(tree.symbol) + if !excludeChildren(tree.symbol) then traverseChildren(tree) case tree: Template => val ctorSym = tree.constr.symbol - if !excludeDef(ctorSym) + if !excludeDef(ctorSym) then traverseAnnotsOfDefinition(ctorSym) registerDefinition(ctorSym, tree.constr.span, Set.empty, tree.source) ctorParams(tree.constr.vparamss, tree.body) @@ -191,7 +191,7 @@ class ExtractSemanticDB extends Phase: val selfSpan = tree.self.span if selfSpan.exists && selfSpan.hasLength then traverse(tree.self) - if tree.symbol.owner.is(Enum, butNot=Case) + if tree.symbol.owner.is(Enum, butNot=Case) then tree.body.foreachUntilImport(traverse).foreach(traverse) // the first import statement else tree.body.foreach(traverse) @@ -206,7 +206,7 @@ class ExtractSemanticDB extends Phase: case _ => traverse(arg) case tree: Assign => val qualSym = condOpt(tree.lhs) { case Select(qual, _) if qual.symbol.exists => qual.symbol } - if !excludeUse(qualSym, tree.lhs.symbol) + if !excludeUse(qualSym, tree.lhs.symbol) then val lhs = tree.lhs.symbol val setter = lhs.matchingSetter.orElse(lhs) tree.lhs match @@ -285,7 +285,7 @@ class ExtractSemanticDB extends Phase: extension (tree: NamedDefTree): private def adjustedNameSpan(using Context): Span = - if tree.span.exists && tree.name.isAnonymousFunctionName || tree.name.isAnonymousClassName + if tree.span.exists && tree.name.isAnonymousFunctionName || tree.name.isAnonymousClassName then Span(tree.span.point) else tree.nameSpan @@ -304,7 +304,7 @@ class ExtractSemanticDB extends Phase: def addOverloadIdx(sym: Symbol): Unit = val decls = val decls0 = sym.owner.info.decls.lookupAll(sym.name) - if sym.owner.isAllOf(JavaModule) + if sym.owner.isAllOf(JavaModule) then decls0 ++ sym.owner.companionClass.info.decls.lookupAll(sym.name) else decls0 @@ -384,70 +384,70 @@ class ExtractSemanticDB extends Phase: Some(Range(startLine, startCol, endLine, endCol)) private def symbolKind(sym: Symbol, symkinds: Set[SymbolKind])(using Context): SymbolInformation.Kind = - if sym.isTypeParam + if sym.isTypeParam then SymbolInformation.Kind.TYPE_PARAMETER - else if sym.is(TermParam) + else if sym.is(TermParam) then SymbolInformation.Kind.PARAMETER - else if sym.isTerm && sym.owner.isTerm + else if sym.isTerm && sym.owner.isTerm then SymbolInformation.Kind.LOCAL - else if sym.isInlineMethod || sym.is(Macro) + else if sym.isInlineMethod || sym.is(Macro) then SymbolInformation.Kind.MACRO - else if sym.isConstructor + else if sym.isConstructor then SymbolInformation.Kind.CONSTRUCTOR - else if sym.isSelfSym + else if sym.isSelfSym then SymbolInformation.Kind.SELF_PARAMETER - else if sym.isOneOf(Method) || symkinds.exists(_.isVarOrVal) + else if sym.isOneOf(Method) || symkinds.exists(_.isVarOrVal) then SymbolInformation.Kind.METHOD - else if sym.isPackageObject + else if sym.isPackageObject then SymbolInformation.Kind.PACKAGE_OBJECT - else if sym.is(Module) + else if sym.is(Module) then SymbolInformation.Kind.OBJECT - else if sym.is(Package) + else if sym.is(Package) then SymbolInformation.Kind.PACKAGE - else if sym.isAllOf(JavaInterface) + else if sym.isAllOf(JavaInterface) then SymbolInformation.Kind.INTERFACE - else if sym.is(Trait) + else if sym.is(Trait) then SymbolInformation.Kind.TRAIT - else if sym.isClass + else if sym.isClass then SymbolInformation.Kind.CLASS - else if sym.isType + else if sym.isType then SymbolInformation.Kind.TYPE - else if sym.is(ParamAccessor) + else if sym.is(ParamAccessor) then SymbolInformation.Kind.FIELD else SymbolInformation.Kind.UNKNOWN_KIND private def symbolProps(sym: Symbol, symkinds: Set[SymbolKind])(using Context): Int = - if sym.is(ModuleClass) + if sym.is(ModuleClass) then return symbolProps(sym.sourceModule, symkinds) var props = 0 - if sym.isPrimaryConstructor + if sym.isPrimaryConstructor then props |= SymbolInformation.Property.PRIMARY.value - if sym.is(Abstract) || symkinds.contains(SymbolKind.Abstract) + if sym.is(Abstract) || symkinds.contains(SymbolKind.Abstract) then props |= SymbolInformation.Property.ABSTRACT.value - if sym.is(Final) + if sym.is(Final) then props |= SymbolInformation.Property.FINAL.value - if sym.is(Sealed) + if sym.is(Sealed) then props |= SymbolInformation.Property.SEALED.value - if sym.isOneOf(GivenOrImplicit) + if sym.isOneOf(GivenOrImplicit) then props |= SymbolInformation.Property.IMPLICIT.value - if sym.is(Lazy, butNot=Module) + if sym.is(Lazy, butNot=Module) then props |= SymbolInformation.Property.LAZY.value - if sym.isAllOf(Case | Module) || sym.is(CaseClass) || sym.isAllOf(EnumCase) + if sym.isAllOf(Case | Module) || sym.is(CaseClass) || sym.isAllOf(EnumCase) then props |= SymbolInformation.Property.CASE.value - if sym.is(Covariant) + if sym.is(Covariant) then props |= SymbolInformation.Property.COVARIANT.value - if sym.is(Contravariant) + if sym.is(Contravariant) then props |= SymbolInformation.Property.CONTRAVARIANT.value - if sym.isAllOf(DefaultMethod | JavaDefined) || sym.is(Accessor) && sym.name.is(NameKinds.DefaultGetterName) + if sym.isAllOf(DefaultMethod | JavaDefined) || sym.is(Accessor) && sym.name.is(NameKinds.DefaultGetterName) then props |= SymbolInformation.Property.DEFAULT.value - if symkinds.exists(_.isVal) + if symkinds.exists(_.isVal) then props |= SymbolInformation.Property.VAL.value - if symkinds.exists(_.isVar) + if symkinds.exists(_.isVar) then props |= SymbolInformation.Property.VAR.value - if sym.is(JavaStatic) + if sym.is(JavaStatic) then props |= SymbolInformation.Property.STATIC.value - if sym.is(Enum) + if sym.is(Enum) then props |= SymbolInformation.Property.ENUM.value props @@ -462,8 +462,8 @@ class ExtractSemanticDB extends Phase: private def registerSymbol(sym: Symbol, symbolName: String, symkinds: Set[SymbolKind])(using Context): Unit = val isLocal = symbolName.isLocal - if !isLocal || !localNames.contains(symbolName) - if isLocal + if !isLocal || !localNames.contains(symbolName) then + if isLocal then localNames += symbolName symbolInfos += symbolInfo(sym, symbolName, symkinds) @@ -489,7 +489,7 @@ class ExtractSemanticDB extends Phase: private def registerDefinition(sym: Symbol, span: Span, symkinds: Set[SymbolKind], treeSource: SourceFile)(using Context) = val symbol = symbolName(sym) registerOccurrence(symbol, span, SymbolOccurrence.Role.DEFINITION, treeSource) - if !sym.is(Package) + if !sym.is(Package) then registerSymbol(sym, symbol, symkinds) private def spanOfSymbol(sym: Symbol, span: Span, treeSource: SourceFile)(using Context): Span = diff --git a/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala b/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala index 161db6f98755..4ef5f3cee1d8 100644 --- a/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala +++ b/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala @@ -34,7 +34,7 @@ object Tools: val text = new String(Files.readAllBytes(scalaAbsolutePath), StandardCharsets.UTF_8) // Assert the SemanticDB payload is in-sync with the contents of the Scala file on disk. val md5FingerprintOnDisk = internal.MD5.compute(text) - if document.md5 != md5FingerprintOnDisk + if document.md5 != md5FingerprintOnDisk then throw new IllegalArgumentException(s"stale semanticdb: $scalaRelativePath") else // Update text document to include full text contents of the file. @@ -132,7 +132,7 @@ object Tools: .append("):") if range.endLine == range.startLine && range.startCharacter != range.endCharacter - && !(occ.symbol.isConstructor && occ.role.isDefinition) + && !(occ.symbol.isConstructor && occ.role.isDefinition) then val line = sourceFile.lineContent(sourceFile.lineToOffset(range.startLine)) assert(range.startCharacter <= line.length && range.endCharacter <= line.length, s"Line is only ${line.length} - start line was ${range.startLine} in source ${sourceFile.name}" diff --git a/compiler/src/dotty/tools/dotc/transform/CompleteJavaEnums.scala b/compiler/src/dotty/tools/dotc/transform/CompleteJavaEnums.scala index 3c0795fb3093..23e5d12622b4 100644 --- a/compiler/src/dotty/tools/dotc/transform/CompleteJavaEnums.scala +++ b/compiler/src/dotty/tools/dotc/transform/CompleteJavaEnums.scala @@ -86,7 +86,7 @@ class CompleteJavaEnums extends MiniPhase with InfoTransformer { thisPhase => /** If this is a constructor of a enum class that extends, add $name and $ordinal parameters to it. */ override def transformDefDef(tree: DefDef)(using Context): DefDef = { val sym = tree.symbol - if (sym.isConstructor && sym.owner.derivesFromJavaEnum) + if sym.isConstructor && sym.owner.derivesFromJavaEnum then val tree1 = cpy.DefDef(tree)( vparamss = tree.vparamss.init :+ (tree.vparamss.last ++ addedParams(sym, isLocal=false, Param))) sym.setParamssFromDefs(tree1.tparams, tree1.vparamss) diff --git a/compiler/src/dotty/tools/dotc/transform/Constructors.scala b/compiler/src/dotty/tools/dotc/transform/Constructors.scala index 1806340bc3cf..ae7acc49eab1 100644 --- a/compiler/src/dotty/tools/dotc/transform/Constructors.scala +++ b/compiler/src/dotty/tools/dotc/transform/Constructors.scala @@ -211,7 +211,7 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase = if stat.symbol.isGetter && stat.symbol.owner.is(Trait) && !stat.symbol.is(Lazy) => val sym = stat.symbol assert(isRetained(sym), sym) - if (!stat.rhs.isEmpty && !isWildcardArg(stat.rhs)) + if !stat.rhs.isEmpty && !isWildcardArg(stat.rhs) then /* !!! Work around #9390 * This should really just be `sym.setter`. However, if we do that, we'll miss * setters for mixed in `private var`s. Even though the scope clearly contains the diff --git a/compiler/src/dotty/tools/dotc/transform/DropOuterAccessors.scala b/compiler/src/dotty/tools/dotc/transform/DropOuterAccessors.scala index 17b342709e0e..c6b3785e99ed 100644 --- a/compiler/src/dotty/tools/dotc/transform/DropOuterAccessors.scala +++ b/compiler/src/dotty/tools/dotc/transform/DropOuterAccessors.scala @@ -83,4 +83,4 @@ class DropOuterAccessors extends MiniPhase with IdentityDenotTransformer: when dropping outer accessors for ${ctx.owner} with $impl""") cpy.Template(impl)(constr = constr1, body = body1) - end transformTemplate \ No newline at end of file + end transformTemplate diff --git a/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala b/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala index f0711cf2d6ff..85e2a62c9172 100644 --- a/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala +++ b/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala @@ -55,7 +55,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase => sym.sourcePos) else addVarArgsForwarder(sym, isJavaVarargsOverride, hasAnnotation) - else if hasAnnotation + else if hasAnnotation then report.error("A method without repeated parameters cannot be annotated with @varargs", sym.sourcePos) end diff --git a/compiler/src/dotty/tools/dotc/transform/Getters.scala b/compiler/src/dotty/tools/dotc/transform/Getters.scala index b1d97d412910..27150e727532 100644 --- a/compiler/src/dotty/tools/dotc/transform/Getters.scala +++ b/compiler/src/dotty/tools/dotc/transform/Getters.scala @@ -112,7 +112,7 @@ class Getters extends MiniPhase with SymTransformer { thisPhase => override def transformAssign(tree: Assign)(using Context): Tree = val lsym = tree.lhs.symbol.asTerm - if (lsym.is(Method)) + if lsym.is(Method) then ensureSetter(lsym) tree.lhs.becomes(tree.rhs).withSpan(tree.span) else tree diff --git a/compiler/src/dotty/tools/dotc/transform/Pickler.scala b/compiler/src/dotty/tools/dotc/transform/Pickler.scala index 109f7ec5156f..8999714958c6 100644 --- a/compiler/src/dotty/tools/dotc/transform/Pickler.scala +++ b/compiler/src/dotty/tools/dotc/transform/Pickler.scala @@ -108,7 +108,7 @@ class Pickler extends Phase { override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] = { val result = super.runOn(units) - if ctx.settings.YtestPickler.value + if ctx.settings.YtestPickler.value then testUnpickler( using ctx.fresh .setPeriod(Period(ctx.runId + 1, FirstPhaseId)) diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index bb78689a3746..addc3edd6e07 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -252,7 +252,7 @@ object Splicer { val staticMethodCall = interpretedStaticMethodCall(fn.symbol.owner, fn.symbol) staticMethodCall(args.flatten.map(interpretTree)) } - else if (fn.symbol.isStatic) + else if fn.symbol.isStatic then assert(args.isEmpty) interpretedStaticFieldAccess(fn.symbol) else if (fn.qualifier.symbol.is(Module) && fn.qualifier.symbol.isStatic) diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 89d37f77f037..c97ea8c4b546 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -72,7 +72,8 @@ object Inliner { def inlineCall(tree: Tree)(using Context): Tree = { val startId = ctx.source.nextId - if tree.symbol.denot != SymDenotations.NoDenotation && tree.symbol.owner.companionModule == defn.CompiletimeTestingPackageObject + if tree.symbol.denot != SymDenotations.NoDenotation + && 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) @@ -298,7 +299,7 @@ object Inliner { val parseErrors = ctx2.reporter.allErrors.toList res ++= parseErrors.map(e => ErrorKind.Parser -> e) - if !stopAfterParser || res.isEmpty + if !stopAfterParser || res.isEmpty then ctx2.typer.typed(tree2)(using ctx2) val typerErrors = ctx2.reporter.allErrors.filterNot(parseErrors.contains) res ++= typerErrors.map(e => ErrorKind.Typer -> e) diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index 1dc6a71fb842..8121b9e9e622 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -152,7 +152,7 @@ trait QuotesAndSplices { case _ => } - if (ctx.mode.is(Mode.QuotedPattern) && level == 1) + if ctx.mode.is(Mode.QuotedPattern) && level == 1 then def spliceOwner(ctx: Context): Symbol = if (ctx.mode.is(Mode.QuotedPattern)) spliceOwner(ctx.outer) else ctx.owner val name = tree.expr match { diff --git a/compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala b/compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala index 53aa4df47623..b3fe710c800e 100644 --- a/compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala +++ b/compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala @@ -43,7 +43,7 @@ class SemanticdbTests: val errors = mutable.ArrayBuffer.empty[Path] val metacSb: StringBuilder = StringBuilder(5000) def collectErrorOrUpdate(expectPath: Path, obtained: String) = - if updateExpectFiles + if updateExpectFiles then Files.write(expectPath, obtained.getBytes(StandardCharsets.UTF_8)) println("updated: " + expectPath) else @@ -78,7 +78,7 @@ class SemanticdbTests: |Or else update all expect files with | sbt 'dotty-compiler-bootstrapped/test:runMain dotty.tools.dotc.semanticdb.updateExpect'""".stripMargin) Files.walk(target).sorted(Comparator.reverseOrder).forEach(Files.delete) - if errors.nonEmpty + if errors.nonEmpty then fail(s"${errors.size} errors in expect test.") def trimTrailingWhitespace(s: String): String = @@ -148,7 +148,7 @@ object SemanticdbTests: ) val isPrimaryConstructor = symtab.get(occ.symbol).exists(_.isPrimary) - if !occ.symbol.isPackage && !isPrimaryConstructor + if !occ.symbol.isPackage && !isPrimaryConstructor then assert(end <= doc.text.length, s"doc is only ${doc.text.length} - offset=$offset, end=$end , symbol=${occ.symbol} in source ${sourceFile.name}") sb.append(doc.text.substring(offset, end))