Skip to content

Commit

Permalink
Add parens for params
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Feb 21, 2023
1 parent 056a70d commit 5851193
Show file tree
Hide file tree
Showing 44 changed files with 170 additions and 195 deletions.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/GenericRunnerSettings.scala
Expand Up @@ -64,5 +64,5 @@ class GenericRunnerSettings(error: String => Unit, pathFactory: PathFactory) ext
"-nc",
"do not use the legacy fsc compilation daemon").withAbbreviation("-nocompdaemon").withAbbreviation("--no-compilation-daemon")
.withDeprecationMessage("scripts use cold compilation by default; use -Yscriptrunner for custom behavior")
.withPostSetHook { x: BooleanSetting => Yscriptrunner.value = if (x.value) "default" else "resident" }
.withPostSetHook { (x: BooleanSetting) => Yscriptrunner.value = if (x.value) "default" else "resident" }
}
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/PipelineMain.scala
Expand Up @@ -201,7 +201,7 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
}
strategy match {
case OutlineTypePipeline =>
projects.foreach { p: Task =>
projects.foreach { (p: Task) =>
val depsReady = Future.traverse(dependsOn.getOrElse(p, Nil))(task => p.dependencyReadyFuture(task))
val f = for {
_ <- depsReady
Expand Down
Expand Up @@ -82,7 +82,7 @@ abstract class ClassfileWriters {
if (distinctOutputs.size == 1) new SingleClassWriter(FileWriter(global, distinctOutputs.head, jarManifestMainClass))
else {
val sourceToOutput: Map[AbstractFile, AbstractFile] = global.currentRun.units.map(unit => (unit.source.file, frontendAccess.compilerSettings.outputDirectory(unit.source.file))).toMap
new MultiClassWriter(sourceToOutput, distinctOutputs.iterator.map { output: AbstractFile => output -> FileWriter(global, output, jarManifestMainClass) }.toMap)
new MultiClassWriter(sourceToOutput, distinctOutputs.iterator.map((output: AbstractFile) => output -> FileWriter(global, output, jarManifestMainClass)).toMap)
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
Expand Up @@ -888,7 +888,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
sClass
}

val decls1 = clazz.info.decls.toList flatMap { m: Symbol =>
val decls1 = clazz.info.decls.toList flatMap { (m: Symbol) =>
if (m.isAnonymousClass) List(m) else {
normalizeMember(m.owner, m, outerEnv) flatMap { normalizedMember =>
val ms = specializeMember(m.owner, normalizedMember, outerEnv, clazz.info.typeParams)
Expand Down Expand Up @@ -1813,7 +1813,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case SpecialOverload(original, env) =>
debuglog("completing specialized " + symbol.fullName + " calling " + original)
debuglog("special overload " + original + " -> " + env)
val t = DefDef(symbol, { vparamss: List[List[Symbol]] =>
val t = DefDef(symbol, (vparamss: List[List[Symbol]]) => {
val fun = Apply(Select(This(symbol.owner), original),
makeArguments(original, vparamss.head))

Expand Down Expand Up @@ -1905,7 +1905,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
// flag. nobody has to see this anyway :)
sym.setFlag(SPECIALIZED)
// create empty bodies for specializations
localTyper.typed(Block(norm.tail.map(sym => DefDef(sym, { vparamss: List[List[Symbol]] => EmptyTree })), ddef))
localTyper.typed(Block(norm.tail.map(sym => DefDef(sym, (vparamss: List[List[Symbol]]) => EmptyTree)), ddef))
} else
tree
case _ =>
Expand Down Expand Up @@ -2011,7 +2011,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
// ctor
mbrs += DefDef(m, Modifiers(m.flags), mmap(List(vparams))(ValDef.apply), EmptyTree)
} else {
mbrs += DefDef(m, { paramss: List[List[Symbol]] => EmptyTree })
mbrs += DefDef(m, (paramss: List[List[Symbol]]) => EmptyTree)
}
} else if (m.isValue) {
mbrs += ValDef(m).setType(NoType)
Expand Down
Expand Up @@ -557,7 +557,7 @@ trait Solving extends Logic {
neg.clear()
for (clause <- clauses) {
if (clause != null) {
clause.foreach { lit: Lit =>
clause.foreach { (lit: Lit) =>
if (lit.positive) pos.set(lit.variable) else neg.set(lit.variable)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Namers.scala
Expand Up @@ -1521,7 +1521,7 @@ trait Namers extends MethodSynthesis {
if (vparam.mods.hasDefault) {
val name = nme.defaultGetterName(meth.name, posCounter)

search.createAndEnter { owner: Symbol =>
search.createAndEnter { (owner: Symbol) =>
methOwner.resetFlag(INTERFACE) // there's a concrete member now
val default = owner.newMethodSymbol(name, vparam.pos, paramFlagsToDefaultGetter(meth.flags))
default.setPrivateWithin(meth.privateWithin)
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/Printers.scala
Expand Up @@ -730,7 +730,7 @@ trait Printers extends api.Printers { self: SymbolTable =>
override def printTParam(td: TypeDef): Unit = printTParam(td, primaryCtorParam = false)

protected def printArgss(argss: List[List[Tree]]) =
argss foreach {x: List[Tree] => if (!(x.isEmpty && argss.size == 1)) printRow(x, "(", ", ", ")")}
argss.foreach((x: List[Tree]) => if (!(x.isEmpty && argss.size == 1)) printRow(x, "(", ", ", ")"))

override def printAnnotations(tree: MemberDef) = {
val annots = tree.mods.annotations
Expand Down
2 changes: 1 addition & 1 deletion src/scaladoc/scala/tools/nsc/doc/Settings.scala
Expand Up @@ -272,7 +272,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_),

lazy val hiddenImplicits: Set[String] = {
if (docImplicitsHide.value.isEmpty) hardcoded.commonConversionTargets
else docImplicitsHide.value.toSet flatMap { name: String =>
else docImplicitsHide.value.toSet flatMap { (name: String) =>
if(name == ".") hardcoded.commonConversionTargets
else Set(name)
}
Expand Down
2 changes: 1 addition & 1 deletion src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala
Expand Up @@ -97,7 +97,7 @@ trait EntityPage extends HtmlPage {
Li(`class`= s"current-entities indented$indentation", elems =
(mbr match {
case dtpl: DocTemplateEntity =>
dtpl.companion.fold(Span(`class`= "separator"): Elem) { c: DocTemplateEntity =>
dtpl.companion.fold(Span(`class`= "separator"): Elem) { (c: DocTemplateEntity) =>
A(`class`= "object", href=relativeLinkTo(c), title= memberToShortCommentTitleTag(c))
}
case _ => Span(`class`= "separator")
Expand Down
Expand Up @@ -42,7 +42,7 @@ class IndexScript(universe: doc.Universe) extends Page {
* class/trait instance. Otherwise one of the member objects will be
* overwritten.
*/
val pairs = merged(key).flatMap { t: DocTemplateEntity =>
val pairs = merged(key).flatMap { (t: DocTemplateEntity) =>
val kind = kindToString(t)
Seq(
kind -> relativeLinkTo(t),
Expand Down
Expand Up @@ -109,10 +109,10 @@ trait ModelFactoryImplicitSupport {
.map(_.hideImplicitConversions.toSet)
.getOrElse(Set.empty)

conversions = conversions filterNot { conv: ImplicitConversionImpl =>
conversions = conversions.filterNot((conv: ImplicitConversionImpl) =>
hiddenConversions.contains(conv.conversionShortName) ||
hiddenConversions.contains(conv.conversionQualifiedName)
}
)

// Filter out non-sensical conversions from value types
if (isPrimitiveValueType(sym.tpe_*))
Expand Down
4 changes: 2 additions & 2 deletions src/scalap/scala/tools/scalap/scalax/rules/Rule.scala
Expand Up @@ -42,7 +42,7 @@ trait Rule[-In, +Out, +A, +X] extends (In => Result[Out, A, X]) {
def filter(f: A => Boolean) = flatMap { a => out => if(f(a)) Success(out, a) else Failure }

def mapResult[Out2, B, Y](f: Result[Out, A, X] => Result[Out2, B, Y]) = rule {
in: In => f(apply(in))
(in: In) => f(apply(in))
}

def orElse[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other: => Rule[In2, Out2, A2, X2]): Rule[In2, Out2, A2, X2] = new Choice[In2, Out2, A2, X2] {
Expand Down Expand Up @@ -164,7 +164,7 @@ trait Rule[-In, +Out, +A, +X] extends (In => Result[Out, A, X]) {

/** ^-^(f) is equivalent to ^^ { b2 => b1 => f(b1, b2) }
*/
def ^-^ [B1, B2 >: A, C](f: (B1, B2) => C) = map { b2: B2 => b1: B1 => f(b1, b2) }
def ^-^ [B1, B2 >: A, C](f: (B1, B2) => C) = map { (b2: B2) => (b1: B1) => f(b1, b2) }

/** ^~>~^(f) is equivalent to ^^ { case b2 ~ b3 => b1 => f(b1, b2, b3) }
*/
Expand Down
10 changes: 5 additions & 5 deletions src/scalap/scala/tools/scalap/scalax/rules/Rules.scala
Expand Up @@ -45,12 +45,12 @@ trait Rules {
val factory = Rules.this
}

def success[Out, A](out: Out, a: A) = rule { in: Any => Success(out, a) }
def success[Out, A](out: Out, a: A) = rule { (in: Any) => Success(out, a) }

def failure = rule { in: Any => Failure }
def failure = rule { (in: Any) => Failure }

def error[In] = rule { in: In => Error(in) }
def error[X](err: X) = rule { in: Any => Error(err) }
def error[In] = rule { (in: In) => Error(in) }
def error[X](err: X) = rule { (in: Any) => Error(err) }

def oneOf[In, Out, A, X](rules: Rule[In, Out, A, X] *): Rule[In, Out, A, X] = new Choice[In, Out, A, X] {
val factory = Rules.this
Expand Down Expand Up @@ -120,7 +120,7 @@ trait StateRules {
}
}
}
in: S => rep(in, rules.toList, Nil)
(in: S) => rep(in, rules.toList, Nil)
}


Expand Down
18 changes: 9 additions & 9 deletions src/scalap/scala/tools/scalap/scalax/rules/SeqRule.scala
Expand Up @@ -24,30 +24,30 @@ import scala.collection.immutable.ArraySeq
class InRule[In, +Out, +A, +X](rule: Rule[In, Out, A, X]) {

def mapRule[Out2, B, Y](f: Result[Out, A, X] => In => Result[Out2, B, Y]): Rule[In, Out2, B, Y] = rule.factory.rule {
in: In => f(rule(in))(in)
(in: In) => f(rule(in))(in)
}

/** Creates a rule that succeeds only if the original rule would fail on the given context. */
def unary_! : Rule[In, In, Unit, Nothing] = mapRule {
case Success(_, _) => in: In => Failure
case _ => in: In => Success(in, ())
case Success(_, _) => (in: In) => Failure
case _ => (in: In) => Success(in, ())
}

/** Creates a rule that succeeds if the original rule succeeds, but returns the original input. */
def & : Rule[In, In, A, X] = mapRule {
case Success(_, a) => in: In => Success(in, a)
case Failure => in: In => Failure
case Error(x) => in: In => Error(x)
case Success(_, a) => (in: In) => Success(in, a)
case Failure => (in: In) => Failure
case Error(x) => (in: In) => Error(x)
}
}

class SeqRule[S, +A, +X](rule: Rule[S, S, A, X]) {
import rule.factory._

def ? = rule mapRule {
case Success(out, a) => in: S => Success(out, Some(a))
case Failure => in: S => Success(in, None)
case Error(x) => in: S => Error(x)
case Success(out, a) => (in: S) => Success(out, Some(a))
case Failure => (in: S) => Success(in, None)
case Error(x) => (in: S) => Error(x)
}

/** Creates a rule that always succeeds with a Boolean value.
Expand Down
14 changes: 6 additions & 8 deletions test/files/jvm/scala-concurrent-tck.scala
@@ -1,3 +1,4 @@
// scalac: -Werror -Xlint
import scala.concurrent.{
Future,
Promise,
Expand All @@ -11,7 +12,6 @@ import scala.concurrent.{
}
import scala.annotation.tailrec
import scala.concurrent.duration._
import scala.reflect.{classTag, ClassTag}
import scala.tools.testkit.AssertUtil.{Fast, Slow, assertThrows, waitFor, waitForIt}
import scala.util.{Try, Success, Failure}
import scala.util.chaining._
Expand Down Expand Up @@ -747,7 +747,7 @@ class Blocking extends TestBase {

class BlockContexts extends TestBase {
import ExecutionContext.Implicits._
import scala.concurrent.{ Await, Awaitable, BlockContext }
import scala.concurrent.BlockContext

private def getBlockContext(body: => BlockContext): BlockContext = await(Future(body))

Expand Down Expand Up @@ -846,7 +846,7 @@ class Exceptions extends TestBase {
Thread.sleep(20)
e.shutdownNow()

val Failure(ee: ExecutionException) = Await.ready(f, 2.seconds).value.get
val Failure(ee: ExecutionException) = Await.ready(f, 2.seconds).value.get: @unchecked
assert(ee.getCause.isInstanceOf[InterruptedException])
}

Expand All @@ -855,16 +855,14 @@ class Exceptions extends TestBase {
val p = Promise[String]()
p.success("foo")
val f = p.future.map(identity)
val Failure(t: RejectedExecutionException) = Await.ready(f, 2.seconds).value.get
val Failure(t: RejectedExecutionException) = Await.ready(f, 2.seconds).value.get: @unchecked
}

test("interruptHandling")(interruptHandling())
test("rejectedExecutionException")(rejectedExecutionException())
}

class GlobalExecutionContext extends TestBase {
import ExecutionContext.Implicits._

def testNameOfGlobalECThreads(): Unit = once {
done => Future({
val expectedName = "scala-execution-context-global-"+ Thread.currentThread.getId
Expand All @@ -876,7 +874,7 @@ class GlobalExecutionContext extends TestBase {
}

class CustomExecutionContext extends TestBase {
import scala.concurrent.{ ExecutionContext, Awaitable }
import scala.concurrent.ExecutionContext

def defaultEC = ExecutionContext.global

Expand Down Expand Up @@ -962,7 +960,7 @@ class CustomExecutionContext extends TestBase {
blocking {
once { done =>
assertNoEC()
val addOne = { x: Int => assertEC(); x + 1 }
val addOne = { (x: Int) => assertEC(); x + 1 }
val f = Promise.successful(10).future
f.map(addOne).filter { x =>
assertEC()
Expand Down
13 changes: 0 additions & 13 deletions test/files/jvm/serialization-new.check
@@ -1,16 +1,3 @@
serialization-new.scala:24: warning: comparing values of types A and B using `equals` unsafely bypasses cooperative equality; use `==` instead
println("x equals y: " + (x equals y) + ", y equals x: " + (y equals x))
^
serialization-new.scala:24: warning: comparing values of types B and A using `equals` unsafely bypasses cooperative equality; use `==` instead
println("x equals y: " + (x equals y) + ", y equals x: " + (y equals x))
^
serialization-new.scala:25: warning: comparing values of types A and B using `equals` unsafely bypasses cooperative equality; use `==` instead
assert((x equals y) && (y equals x))
^
serialization-new.scala:25: warning: comparing values of types B and A using `equals` unsafely bypasses cooperative equality; use `==` instead
assert((x equals y) && (y equals x))
^
warning: 4 deprecations (since 2.13.0); re-run with -deprecation for details
a1 = Array[1,2,3]
_a1 = Array[1,2,3]
arrayEquals(a1, _a1): true
Expand Down
13 changes: 8 additions & 5 deletions test/files/jvm/serialization-new.scala
@@ -1,3 +1,4 @@
// scalac: -Werror -Xlint -Wconf:cat=deprecation&msg="symbol literal":s -Wconf:msg="cooperative equality":s
//############################################################################
// Serialization
//############################################################################
Expand Down Expand Up @@ -105,7 +106,7 @@ object Test1_scala {
println()

// Function
val f1 = { x: Int => 2 * x }
val f1 = (x: Int) => 2 * x
val _f1: Function[Int, Int] = read(write(f1))
println("f1 = <na>")
println("_f1 = <na>")
Expand Down Expand Up @@ -396,11 +397,13 @@ class Person(_name: String) extends Serializable {
override def equals(that: Any): Boolean =
that.isInstanceOf[Person] &&
(name == that.asInstanceOf[Person].name)
def rename() = name = "Bob"
}

class Employee(_name: String) extends Serializable {
private var name = _name
override def toString() = name
def rename() = name = "Bob"
}

object bob extends Employee("Bob")
Expand Down Expand Up @@ -473,20 +476,20 @@ class WithTransient extends Serializable {
@transient object B extends Serializable
@transient private object C extends Serializable

def test = {
def test() = {
println(a1)
println(a2)
if (B == null || C == null)
println("Transient nested object failed to serialize properly")
println("Transient nested object failed to serialize properly")
}
}

object Test8 {
val x = new WithTransient
x.test
x.test()
try {
val y:WithTransient = read(write(x))
y.test
y.test()
}
catch {
case e: Exception =>
Expand Down
13 changes: 0 additions & 13 deletions test/files/jvm/serialization.check
@@ -1,16 +1,3 @@
serialization.scala:24: warning: comparing values of types A and B using `equals` unsafely bypasses cooperative equality; use `==` instead
println("x equals y: " + (x equals y) + ", y equals x: " + (y equals x))
^
serialization.scala:24: warning: comparing values of types B and A using `equals` unsafely bypasses cooperative equality; use `==` instead
println("x equals y: " + (x equals y) + ", y equals x: " + (y equals x))
^
serialization.scala:25: warning: comparing values of types A and B using `equals` unsafely bypasses cooperative equality; use `==` instead
assert((x equals y) && (y equals x))
^
serialization.scala:25: warning: comparing values of types B and A using `equals` unsafely bypasses cooperative equality; use `==` instead
assert((x equals y) && (y equals x))
^
warning: 4 deprecations (since 2.13.0); re-run with -deprecation for details
a1 = Array[1,2,3]
_a1 = Array[1,2,3]
arrayEquals(a1, _a1): true
Expand Down

0 comments on commit 5851193

Please sign in to comment.