diff --git a/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala b/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala index 53885ba523ec..e30ddd9a55da 100644 --- a/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala +++ b/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala @@ -4706,7 +4706,7 @@ object JSCodeGen { if (!overloads.isOverloaded) overloads.symbol else - overloads.suchThat(_.is(HasDefaultParams)).symbol + overloads.suchThat(_.is(HasDefaultParams, butNot = Bridge)).symbol } } diff --git a/tests/sjs-junit/test/org/scalajs/testsuite/compiler/RegressionTestScala3.scala b/tests/sjs-junit/test/org/scalajs/testsuite/compiler/RegressionTestScala3.scala index 90d7df3ab281..08aa26726dc7 100644 --- a/tests/sjs-junit/test/org/scalajs/testsuite/compiler/RegressionTestScala3.scala +++ b/tests/sjs-junit/test/org/scalajs/testsuite/compiler/RegressionTestScala3.scala @@ -52,6 +52,13 @@ class RegressionTestScala3 { def intPlusString(x: String): String = 5 + x assertEquals("5bc", intPlusString("bc")) } + + @Test def defaultParamsInModuleDefWithBridgesIssue13860(): Unit = { + import Issue13860._ + + assertEquals(0L, Foo.bar().x) + assertEquals(5L, Foo.bar(5L).x) + } } object RegressionTestScala3 { @@ -100,6 +107,18 @@ object RegressionTestScala3 { import I._ def blah = i } + + object Issue13860 { + class Foo(var x: Long) + + trait Companion[A] { + def bar(x: Long = 0): A + } + + object Foo extends Companion[Foo] { + def bar(x: Long = 0): Foo = new Foo(x) + } + } } // This class needs to be at the top-level, not in an object, to reproduce the issue