Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13860: Ignore bridges when looking for a default getter's attached method. #13870

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Expand Up @@ -4706,7 +4706,7 @@ object JSCodeGen {
if (!overloads.isOverloaded)
overloads.symbol
else
overloads.suchThat(_.is(HasDefaultParams)).symbol
overloads.suchThat(_.is(HasDefaultParams, butNot = Bridge)).symbol
}
}

Expand Down
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down