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

Compile succeeds using non-existent default constructor #7949

Closed
scabug opened this issue Nov 4, 2013 · 2 comments
Closed

Compile succeeds using non-existent default constructor #7949

scabug opened this issue Nov 4, 2013 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented Nov 4, 2013

A class compiled with Java lacks default constructor. The Scala compiler nevertheless accepts constructor calls without parameter. The Java compiler correctly fails to compile such calls.

Unpack the attached tarball, put the desired versions of javac and scalac on PATH, cd into no_default_constructor_bug and execute ./runme.sh. If the script fails, the bug was triggered.

When I discovered the problem in a real application setting, the scala compiler generated some byte code that brought down the JVM.

@scabug
Copy link
Author

scabug commented Nov 4, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7949?orig=1
Reporter: Lars Albertsson (lalle)
Affected Versions: 2.10.3
Duplicates #3583
Attachments:

@scabug
Copy link
Author

scabug commented Nov 9, 2013

@retronym said:
Unfortunately, this is a "feature" known as automatic argument list tupling. The lack of safety is discussed in #3583.

I recommend compiling with -Yno-adapted-args or at least -Ywarn-adapted-args. The latter is part of the option set -Xlint`.

src/main/scala/com/foo/TimeSlot.scala:9: warning: No automatic adaptation here: use explicit parentheses.
        signature: Interval(x$1: Any): org.joda.time.Interval
  given arguments: <none>
 after adaptation: new Interval((): Unit)
  val nullSlot = new TimeSlot(new Interval())
                              ^
src/main/scala/com/foo/TimeSlot.scala:9: error: not enough arguments for constructor Interval: (x$1: Any)org.joda.time.Interval.
Unspecified value parameter x$1.
  val nullSlot = new TimeSlot(new Interval())
                              ^

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

2 participants