Skip to content

Commit 6c64430

Browse files
committed
Fix #2563: Unconditionally emit mixin forwarders
This is what Scala 2.12+ does for cold performance reasons (see #5928 for more details) and we should align ourselves with them when possible. About two years ago in #2563, Dmitry objected that we may not need to do that if we found another way to get performance back, or if newer JDKs improved the performance of default method resolution. It doesn't look like these things have happened so far (but there's some recent glimmer of hope here: https://bugs.openjdk.java.net/browse/JDK-8036580). Dmitry also said "I don't recall triggering bugs by emitting more forwarders rather then less.", but in fact since then I've found one case where the standard library failed to compile with extra forwarders causing name clashes, requiring a non-binary-compatible change: scala/scala@e3ef657. As of #6079 this is no longer a problem since we now emit mixin forwarders after erasure like scalac, but it still seems prudent to emit as many forwarders as scalac to catch potential name clash issues.
1 parent cdbee63 commit 6c64430

File tree

3 files changed

+2
-1
lines changed

3 files changed

+2
-1
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ScalaSettings extends Settings.SettingGroup {
8282
helpArg = "mode",
8383
descr = "Generate forwarder methods in classes inhering concrete methods from traits.",
8484
choices = List("true", "junit", "false"),
85-
default = "junit")
85+
default = "true")
8686

8787
object mixinForwarderChoices {
8888
def isTruthy(implicit ctx: Context) = XmixinForceForwarders.value == "true"

compiler/test/dotty/tools/dotc/CompilationTests.scala

+1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class CompilationTests extends ParallelTesting {
185185
compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees") +
186186
compileFile("tests/run-custom-args/tuple-cons.scala", allowDeepSubtypes) +
187187
compileFile("tests/run-custom-args/i5256.scala", allowDeepSubtypes) +
188+
compileFile("tests/run-custom-args/no-useless-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false") +
188189
compileFilesInDir("tests/run", defaultOptions)
189190
}.checkRuns()
190191

0 commit comments

Comments
 (0)