Skip to content

Bad Interaction between constructor overloading and default parameters #3171

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

Closed
allanrenucci opened this issue Sep 25, 2017 · 0 comments
Closed

Comments

@allanrenucci
Copy link
Contributor

The following code snippet fails to compile with Dotty

object Test {
  class C(x: Int, y: Int) {
    def this(x: Int = 1)(y: String) =
      this(x, y.toInt)
  }
  
  def test: Unit = {
    new C()("1")
  }
}
-- Error: tests/allan/Test.scala:8:8 -------------------------------------------
8 |    new C()("1")
  |        ^
  |missing argument for parameter x of constructor C: (x: Int)(y: String): Test.C
@allanrenucci allanrenucci mentioned this issue Sep 25, 2017
17 tasks
odersky added a commit to dotty-staging/dotty that referenced this issue Sep 28, 2017
Previous logic would place them in the enclosing class instead of in
the companion object where they belong.

Also, define position for error that checks against multiple overloaded
alternatives with default arguments.
odersky added a commit that referenced this issue Sep 28, 2017
Fix #3171: Fix handling default getters in secondary constructors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant