From c06199fec9f918f9fcaf3fa36a3b1678d298e8ff Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Wed, 10 Jan 2024 23:29:41 +0100 Subject: [PATCH] Fix scalacOptions mill overrides --- .../scala/fix/MillScalacOptionsOverride.scala | 18 +++++++++--------- .../fix/Scala3CommunityBuildMillAdapter.scala | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/project-builder/mill/scalafix/output/src/main/scala/fix/MillScalacOptionsOverride.scala b/project-builder/mill/scalafix/output/src/main/scala/fix/MillScalacOptionsOverride.scala index 38e8aa7f..70bd1812 100644 --- a/project-builder/mill/scalafix/output/src/main/scala/fix/MillScalacOptionsOverride.scala +++ b/project-builder/mill/scalafix/output/src/main/scala/fix/MillScalacOptionsOverride.scala @@ -10,7 +10,7 @@ object MillScalacOptionsOverride { } } import MillCommunityBuild._ - def scalacOptions = List.empty[String].mapScalacOptions() + def scalacOptions = { List.empty[String] }.mapScalacOptions() object mill{ import scala.language.implicitConversions trait T[U] @@ -21,29 +21,29 @@ object MillScalacOptionsOverride { import mill._ object module { - val scalacOptions = Nil.mapScalacOptions() + val scalacOptions = { Nil }.mapScalacOptions() } object module2 { - def scalacOptions: Seq[String] = Seq("-Xprint:typer").mapScalacOptions() + def scalacOptions: Seq[String] = { Seq("-Xprint:typer") }.mapScalacOptions() } object module3 { - def scalacOptions = mill.T(module2.scalacOptions).mapScalacOptions() + def scalacOptions = { mill.T(module2.scalacOptions) }.mapScalacOptions() } class moduleDef { - def scalacOptions: T[Seq[String]] = { + def scalacOptions: T[Seq[String]] = { { val opt1 = "-release:11" Seq(opt1) - }.mapScalacOptions() + } }.mapScalacOptions() } class moduleDef2 extends moduleDef { - override val scalacOptions: T[Seq[String]] = MillScalacOptionsOverride.scalacOptions.mapScalacOptions() + override val scalacOptions: T[Seq[String]] = { MillScalacOptionsOverride.scalacOptions }.mapScalacOptions() } object moduleDef3 extends moduleDef { - override def scalacOptions = T { + override def scalacOptions = { T { super.scalacOptions ++ Nil - }.mapScalacOptions() + } }.mapScalacOptions() } } diff --git a/project-builder/mill/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala b/project-builder/mill/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala index 77d39c7d..328d96cd 100644 --- a/project-builder/mill/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala +++ b/project-builder/mill/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala @@ -130,7 +130,7 @@ class Scala3CommunityBuildMillAdapter( } case tree @ ValOrDefDef(Term.Name("scalacOptions"), _, body) => - Patch.addRight(body, ".mapScalacOptions()") + Patch.addAround(body,"{ ", " }.mapScalacOptions()") case ValOrDefDef(Term.Name(id), tpe, body) if scala3Identifiers.contains(id) => body.toString().trim() match {