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

Compiler Crash - trait method with Symbol parameter and default value #4812

Closed
scabug opened this issue Jul 16, 2011 · 4 comments
Closed

Compiler Crash - trait method with Symbol parameter and default value #4812

scabug opened this issue Jul 16, 2011 · 4 comments

Comments

@scabug
Copy link

scabug commented Jul 16, 2011

The following source

trait Test1 {
 def m1(sym: Symbol = 'TestSym)
}

crashes the compiler:

uncaught exception during compilation: java.util.NoSuchElementException
error: java.util.NoSuchElementException
	at scala.collection.LinearSeqOptimized$class.last(LinearSeqOptimized.scala:135)
	at scala.collection.immutable.List.last(List.scala:77)
	at scala.tools.nsc.backend.icode.Members$IMethod.lastBlock(Members.scala:159)
	at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.addStaticInit(GenJVM.scala:995)
	at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$genClass$1.apply(GenJVM.scala:445)
	at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$genClass$1.apply(GenJVM.scala:445)
[...]
@scabug
Copy link
Author

scabug commented Jul 16, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4812?orig=1
Reporter: John Bruce (scimonkey)
Affected Versions: 2.9.0
Attachments:

  • si-4812.patch (created on Oct 30, 2011 1:41:10 PM UTC, 331 bytes)

@scabug
Copy link
Author

scabug commented Aug 16, 2011

@paulp said:
Feels like default parameters.

@scabug
Copy link
Author

scabug commented Oct 30, 2011

Remo Lemma (coloss) said (edited on Oct 30, 2011 1:42:07 PM UTC):
I investigated this bug, and it seems that there was a problem on how the compiler treats default parameters in abstract methods of traits.
This patch should solve the issue. I tested it with different test cases and of course checked that the test suite still finishes with no problems.

@scabug
Copy link
Author

scabug commented May 19, 2012

@lrytz said (edited on May 19, 2012 12:33:38 PM UTC):
fixed in scala/scala@57967c9

The crash is in CleanUp: It generates a static field & constructor in the interface class (that's wrong) because the "scala.Symbol.apply(...)" code remains in the interface as a default argument. Fixed by removing all default arguments from parameter ValDefs in UnCurry.

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