From a88312b6bf2ff1a7f0884ddaadbf5736bde91eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Wed, 26 Jun 2024 13:54:23 +0200 Subject: [PATCH] Mark genSJSIR as *disabled* (rather than non-*runnable*) when no `-scalajs`. This works around the issue seen in #20296. However, the issue resurfaces if we actually run `-Ycheck:all` in a Scala.js-enabled build. --- .../src/dotty/tools/backend/sjs/GenSJSIR.scala | 5 ++++- .../test/xsbt/CompileProgressSpecification.scala | 1 - tests/pos/i20296.scala | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i20296.scala diff --git a/compiler/src/dotty/tools/backend/sjs/GenSJSIR.scala b/compiler/src/dotty/tools/backend/sjs/GenSJSIR.scala index fbb9042affe7..c44c8f19777b 100644 --- a/compiler/src/dotty/tools/backend/sjs/GenSJSIR.scala +++ b/compiler/src/dotty/tools/backend/sjs/GenSJSIR.scala @@ -11,8 +11,11 @@ class GenSJSIR extends Phase { override def description: String = GenSJSIR.description + override def isEnabled(using Context): Boolean = + ctx.settings.scalajs.value + override def isRunnable(using Context): Boolean = - super.isRunnable && ctx.settings.scalajs.value && !ctx.usedBestEffortTasty + super.isRunnable && !ctx.usedBestEffortTasty def run(using Context): Unit = new JSCodeGen().run() diff --git a/sbt-bridge/test/xsbt/CompileProgressSpecification.scala b/sbt-bridge/test/xsbt/CompileProgressSpecification.scala index bcdac0547e75..dc3956ada0db 100644 --- a/sbt-bridge/test/xsbt/CompileProgressSpecification.scala +++ b/sbt-bridge/test/xsbt/CompileProgressSpecification.scala @@ -66,7 +66,6 @@ class CompileProgressSpecification { "MegaPhase{pruneErasedDefs,...,arrayConstructors}", "erasure", "constructors", - "genSJSIR", "genBCode" ) val missingExpectedPhases = someExpectedPhases -- allPhases.toSet diff --git a/tests/pos/i20296.scala b/tests/pos/i20296.scala new file mode 100644 index 000000000000..910fd07c1298 --- /dev/null +++ b/tests/pos/i20296.scala @@ -0,0 +1,14 @@ +trait Foo + +object Foo { + inline def bar(): Foo = + class InlinedFoo extends Foo {} + new InlinedFoo + + inline def foo(): Foo = + bar() + class InlinedFoo extends Foo {} + new InlinedFoo + + def Test: Foo = Foo.foo() +}