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

productIterator not implemented in case class in REPL w -optimize #5290

Closed
scabug opened this issue Dec 7, 2011 · 9 comments
Closed

productIterator not implemented in case class in REPL w -optimize #5290

scabug opened this issue Dec 7, 2011 · 9 comments

Comments

@scabug
Copy link

scabug commented Dec 7, 2011

If you run the scala REPL with -optimize in 2.9.1, then case classes don't auto-generate the productIterator method and calling it (or toString, eg) will causes an AbstractMethodError. This does NOT happen in 2.9.0 and 2.8.x. Reproducing:

$ scala -optimize
scala> case class A(x: Int)
scala> A(1).productIterator
java.lang.AbstractMethodError: A.productIterator()Lscala/collection/Iterator;
at .(:10)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:680)

Just doing A(1) by itself will also cause an exception, since scala.runtime.ScalaRuntime$._toString uses productIterator. This also happens when using sbt> console w/ "-optimize" as a "scalacOption", which is where I first noticed it, since I would've never run the REPL with -optimize otherwise.

@scabug
Copy link
Author

scabug commented Dec 7, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5290?orig=1
Reporter: Thomas Switzer (tixxit)
Affected Versions: 2.9.1

@scabug
Copy link
Author

scabug commented Dec 16, 2011

@VladUreche said:
Can't reproduce on trunk.

@scabug
Copy link
Author

scabug commented Feb 20, 2012

Anton Malykh (malykh) said:
(64-bit Windows 7)
C:\Soft\scala-2.9.1.final>java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

C:\Soft\scala-2.9.1.final>scala -version
Scala code runner version 2.9.1.final -- Copyright 2002-2011, LAMP/EPFL

C:\Soft\scala-2.9.1.final>scala -optimize
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> case class A(x: Int)
defined class A

scala> A(1).productIterator
java.lang.AbstractMethodError: A.productIterator()Lscala/collection/Iterator;
at .(:10)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:662)

@scabug
Copy link
Author

scabug commented Feb 20, 2012

@paulp said:
I don't remember what happened here, but this is fixed in both 2.9.2 and trunk.

@scabug
Copy link
Author

scabug commented Apr 15, 2012

Anton Malykh (malykh) said:
The some problem with the 2.9.2 release:

C:\Soft\scala-2.9.2\bin>java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

C:\Soft\scala-2.9.2\bin>scala -version
Scala code runner version 2.9.2 -- Copyright 2002-2011, LAMP/EPFL

C:\Soft\scala-2.9.2\bin>scala -optimize
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> case class A(x: Int)
defined class A

scala> A(1).productIterator
java.lang.AbstractMethodError: A.productIterator()Lscala/collection/Iterator;
at .(:10)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:662)

@scabug
Copy link
Author

scabug commented Apr 15, 2012

Anton Malykh (malykh) said:
Not fixed in 2.9.2

@scabug
Copy link
Author

scabug commented May 2, 2012

@axel22 said (edited on May 2, 2012 4:53:16 PM UTC):
Interesting, I didn't even get this far:

Running scala -optimize:

scala> case class A(x: Int)
error: 
     while compiling:  <console>
       current phase:  mixin
     library version:  version 2.10.0-20120502-012746-90d2bee45b
    compiler version:  version 2.10.0-20120502-012746-90d2bee45b
  reconstructed args:  -Ydead-code -optimise -Yinline -Yclosure-elim -Yinline-handlers

uncaught exception during compilation: java.lang.AssertionError
java.lang.AssertionError: assertion failed: 
     while compiling:  <console>
       current phase:  mixin
     library version:  version 2.10.0-20120502-012746-90d2bee45b
    compiler version:  version 2.10.0-20120502-012746-90d2bee45b
  reconstructed args:  -Ydead-code -optimise -Yinline -Yclosure-elim -Yinline-handlers

Not an impl class:(class Product$class in package scala abstract <java>,trait Product in package scala abstract <interface> <trait> <lateinterface>)
	at scala.Predef$.assert(Predef.scala:182)
	at scala.tools.nsc.Global.assert(Global.scala:187)
	at scala.tools.nsc.transform.Mixin.mixinImplClassMembers$1(Mixin.scala:275)
	at scala.tools.nsc.transform.Mixin$$anonfun$addMixedinMembers$2.apply(Mixin.scala:372)
	at scala.tools.nsc.transform.Mixin$$anonfun$addMixedinMembers$2.apply(Mixin.scala:367)
	at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:757)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:756)
	at scala.tools.nsc.transform.Mixin.addMixedinMembers(Mixin.scala:367)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.preTransform(Mixin.scala:521)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:1238)
	at scala.reflect.api.Trees$Transformer.transformTemplate(Trees.scala:1538)
	at scala.reflect.api.Trees$Transformer$$anonfun$transform$2.apply(Trees.scala:1432)
	at scala.reflect.api.Trees$Transformer$$anonfun$transform$2.apply(Trees.scala:1431)
	at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1561)
	at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1430)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:1238)
	at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1554)
	at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1552)
	at scala.collection.immutable.List.loop$1(List.scala:163)
	at scala.collection.immutable.List.mapConserve(List.scala:179)
	at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:1552)
	at scala.reflect.api.Trees$Transformer$$anonfun$transform$1.apply(Trees.scala:1426)
	at scala.reflect.api.Trees$Transformer$$anonfun$transform$1.apply(Trees.scala:1426)
	at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1561)
	at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1425)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:1238)
	at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:228)
	at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:30)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:432)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:398)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:392)
	at scala.collection.Iterator$class.foreach(Iterator.scala:706)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1133)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:392)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1336)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1309)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1303)
	at scala.tools.nsc.interpreter.IMain.compileSourcesKeepingRun(IMain.scala:461)
	at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compileAndSaveRun(IMain.scala:845)
	at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:803)
	at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:979)
	at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:629)
	at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:595)
	at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:826)
	at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:883)
	at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:783)
	at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:647)
	at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:654)
	at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:657)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:962)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:924)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:924)
	at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:157)
	at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:924)
	at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:79)
	at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:92)
	at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:101)
	at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning and rescheduling to M6 as previous deadline was missed.

@scabug
Copy link
Author

scabug commented Feb 5, 2014

@som-snytt said:
Slays 2.10.0, all fixed since 2.10.1.

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