From 9f7d16924813998631f7706900a4128ff09e9cd4 Mon Sep 17 00:00:00 2001 From: Matthew de Detrich Date: Wed, 12 Oct 2022 13:43:11 -0400 Subject: [PATCH] Don't make ScalaModulePlugin.enableOptimizer fail on Scala3 --- src/main/scala/ScalaModulePlugin.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/scala/ScalaModulePlugin.scala b/src/main/scala/ScalaModulePlugin.scala index 3ad4392..441a82b 100644 --- a/src/main/scala/ScalaModulePlugin.scala +++ b/src/main/scala/ScalaModulePlugin.scala @@ -50,11 +50,12 @@ object ScalaModulePlugin extends AutoPlugin { */ lazy val enableOptimizer: Setting[_] = Compile / compile / scalacOptions ++= { val Ver = """(\d+)\.(\d+)\.(\d+).*""".r - val Ver("2", maj, min) = scalaVersion.value - (maj.toInt, min.toInt) match { - case (m, _) if m < 12 => Seq("-optimize") - case (12, n) if n < 3 => Seq("-opt:l:project") - case _ => Seq("-opt:l:inline", "-opt-inline-from:" + scalaModuleEnableOptimizerInlineFrom.value) + val Ver(epic, maj, min) = scalaVersion.value + (epic, maj.toInt, min.toInt) match { + case ("2", m, _) if m < 12 => Seq("-optimize") + case ("2", 12, n) if n < 3 => Seq("-opt:l:project") + case ("2", _, _) => Seq("-opt:l:inline", "-opt-inline-from:" + scalaModuleEnableOptimizerInlineFrom.value) + case ("3", _, _) => Nil // Optimizer not yet available for Scala3, see https://docs.scala-lang.org/overviews/compiler-options/optimizer.html } }