From 71a447542d6f332ac8d7ca0b7f323fc7d74492fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Fri, 21 May 2021 22:53:55 +0200 Subject: [PATCH 1/2] Add -source future, strictEquality --- .../davidgregory084/TpolecatPlugin.scala | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala b/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala index 2a2a8d7..9545a3b 100644 --- a/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala +++ b/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala @@ -57,7 +57,8 @@ object TpolecatPlugin extends AutoPlugin { ScalacOption("-language:experimental.macros", removedIn = Some(V3_0_0)), // Allow macro definition (besides implementation and application) ScalacOption("-language:higherKinds", removedIn = Some(V3_0_0)), // Allow higher-kinded types ScalacOption("-language:implicitConversions", removedIn = Some(V3_0_0)), // Allow definition of implicit functions called views - ScalacOption("-language:existentials,experimental.macros,higherKinds,implicitConversions", addedIn = Some(V3_0_0)), // the four options above, dotty style + ScalacOption("-source future", addedIn = Some(V3_0_0)), // Emit warnings for features that are planned to be removed (e.g. extending non-open classes outside their files). + ScalacOption("-language:existentials,experimental.macros,higherKinds,implicitConversions,strictEquality", addedIn = Some(V3_0_0)), // Require CanEqual for equality checks + the four options above, dotty style ScalacOption("-unchecked"), // Enable additional warnings where generated code depends on assumptions. ScalacOption("-Xcheckinit", removedIn = Some(V3_0_0)), // Wrap field accessors to throw an exception on uninitialized access. ScalacOption("-Xfatal-warnings"), // Fail the compilation if there are any warnings. @@ -132,23 +133,24 @@ object TpolecatPlugin extends AutoPlugin { def scalacOptionsFor(version: String): Seq[String] = List( "-encoding", "utf8" // Specify character encoding used by source files. - ) ++ ((CrossVersion.partialVersion(version), version.split('.')) match { - case (Some((0, min)), _) => // dotty prereleases use 0 as major version - allScalacOptions - .filter(validFor(V3_0_0)) // treat dotty prereleases as 3.0.0 - .map(_.name) - case (Some((maj, min)), Array(maj2, min2, patch)) if maj.toString == maj2 && min.toString == min2 => - allScalacOptions - .filter(validFor(Version(maj, min, Try(patch.toLong).getOrElse(0)))) - .map(_.name) - case (Some((maj, min)), _) => - allScalacOptions - .filter(validFor(Version(maj, min, 0))) - .map(_.name) - case (None, _) => - Nil - }) + ) ++ { + val flags = (CrossVersion.partialVersion(version), version.split('.')) match { + case (Some((0, min)), _) => // dotty prereleases use 0 as major version + allScalacOptions + .filter(validFor(V3_0_0)) // treat dotty prereleases as 3.0.0 + case (Some((maj, min)), Array(maj2, min2, patch)) if maj.toString == maj2 && min.toString == min2 => + allScalacOptions + .filter(validFor(Version(maj, min, Try(patch.toLong).getOrElse(0)))) + case (Some((maj, min)), _) => + allScalacOptions + .filter(validFor(Version(maj, min, 0))) + case (None, _) => + Nil + } + + flags.flatMap(_.name.split("\\s+")) +} val filterConsoleScalacOptions = { options: Seq[String] => options.filterNot(Set( "-Werror", From 06ae77e5c2c1fb7d8473525ce68f6440227062dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Wed, 26 May 2021 16:03:43 +0200 Subject: [PATCH 2/2] Split language flags, remove existentials in 3.x.x --- .../scala/io/github/davidgregory084/TpolecatPlugin.scala | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala b/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala index 9545a3b..84a13e5 100644 --- a/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala +++ b/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala @@ -54,11 +54,10 @@ object TpolecatPlugin extends AutoPlugin { ScalacOption("-explain", addedIn = Some(V3_0_0)), // Explain errors in more detail. ScalacOption("-feature"), // Emit warning and location for usages of features that should be imported explicitly. ScalacOption("-language:existentials", removedIn = Some(V3_0_0)), // Existential types (besides wildcard types) can be written and inferred - ScalacOption("-language:experimental.macros", removedIn = Some(V3_0_0)), // Allow macro definition (besides implementation and application) - ScalacOption("-language:higherKinds", removedIn = Some(V3_0_0)), // Allow higher-kinded types - ScalacOption("-language:implicitConversions", removedIn = Some(V3_0_0)), // Allow definition of implicit functions called views - ScalacOption("-source future", addedIn = Some(V3_0_0)), // Emit warnings for features that are planned to be removed (e.g. extending non-open classes outside their files). - ScalacOption("-language:existentials,experimental.macros,higherKinds,implicitConversions,strictEquality", addedIn = Some(V3_0_0)), // Require CanEqual for equality checks + the four options above, dotty style + ScalacOption("-language:experimental.macros"), // Allow macro definition (besides implementation and application) + ScalacOption("-language:higherKinds"), // Allow higher-kinded types + ScalacOption("-language:implicitConversions"), // Allow definition of implicit functions called views + ScalacOption("-source future", addedIn = Some(V3_0_0)), // Emit warnings for features that are planned to be removed (e.g. extending non-open classes outside their files). ScalacOption("-unchecked"), // Enable additional warnings where generated code depends on assumptions. ScalacOption("-Xcheckinit", removedIn = Some(V3_0_0)), // Wrap field accessors to throw an exception on uninitialized access. ScalacOption("-Xfatal-warnings"), // Fail the compilation if there are any warnings.