Skip to content

Method overload in trait + default parameter values causes compiler crash #17999

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

Open
antognini opened this issue Jun 19, 2023 · 2 comments
Open

Comments

@antognini
Copy link

Compiler version

3.3.0

Minimized code

trait A:
  def foo = 1
  def foo(x: Int = 0) = 2

val a = new A{}
a.foo
a.foo()

(new A{}).foo
(new A{}).foo() // compiler crashes at this line

Output (click arrow to expand)

java.util.NoSuchElementException: None.get
scala.None$.get(Option.scala:627)
scala.None$.get(Option.scala:626)
dotty.tools.dotc.transform.LambdaLift.transformTemplate(LambdaLift.scala:336)
dotty.tools.dotc.transform.LambdaLift.transformTemplate(LambdaLift.scala:332)
dotty.tools.dotc.transform.MegaPhase.goTemplate(MegaPhase.scala:1010)
dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:360)
dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:427)
dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:255)
dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:425)
dotty.tools.dotc.transform.MegaPhase.loop$2(MegaPhase.scala:444)
dotty.tools.dotc.transform.MegaPhase.transformBlock(MegaPhase.scala:449)

Expectation

The code should compile

@antognini antognini added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 19, 2023
@mbovel mbovel added area:default-parameters Spree Suitable for a future Spree and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 19, 2023
@mbovel
Copy link
Member

mbovel commented Jun 19, 2023

As #17581 has been fixed, I suggest the team @dwijnand, @eugenefle, @hamzaremmal, @iusildra switches to this issue for tomorrow's Dotty Spree.

@dwijnand dwijnand removed the Spree Suitable for a future Spree label Jul 15, 2023
@dwijnand
Copy link
Member

This has nothing to do with overloading (as it looked) but only about default arguments. We couldn't figure out exactly how LambdaLift works, but clearly it didn't expect the duplication that derives from a default argument, so it crashes like it does.

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

3 participants