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

@specialize Iterator => crash. #4123

Closed
scabug opened this issue Dec 31, 2010 · 7 comments
Closed

@specialize Iterator => crash. #4123

scabug opened this issue Dec 31, 2010 · 7 comments

Comments

@scabug
Copy link

scabug commented Dec 31, 2010

Been seeing what I can @Specialize in the library without undue difficulty.

Successes: Option, PartialFunction, List, Numeric, Ordering.

Failure:

% git diff
-trait Iterator[+A] extends TraversableOnce[A] {
+trait Iterator[@specialized +A] extends TraversableOnce[A] {

% scalac29 -d /tmp src/library/scala/collection/Iterator.scala
  Exception in thread "main" java.lang.UnsupportedOperationException
  	at ch.epfl.lamp.fjbg.JMethodType.getSize(JMethodType.java:29)
  	at ch.epfl.lamp.fjbg.JCode.emitGETFIELD(JCode.java:613)
  	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator$$$$anonfun$$genBlock$$1$$2.apply(GenJVM.scala:1131)
  	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator$$$$anonfun$$genBlock$$1$$2.apply(GenJVM.scala:1094)
  	at scala.collection.IndexedSeqOptimized$$class.foreach(IndexedSeqOptimized.scala:34)
  	at scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:38)
  	at scala.tools.nsc.backend.icode.BasicBlocks$$BasicBlock.foreach(BasicBlocks.scala:126)
  	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator.genBlock$$1(GenJVM.scala}} 

Paging Dr. Agos, Dr. Agos to the OR!

@scabug
Copy link
Author

scabug commented Dec 31, 2010

Imported From: https://issues.scala-lang.org/browse/SI-4123?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Feb 23, 2011

@dragos said:
This is the most spectacular failure I've seen so far in the specialization realm! I'll have a look.

@scabug
Copy link
Author

scabug commented Jun 19, 2011

@paulp said:
See also #4716 and #4717, both of which now prevent Iterator from being specialized. (I believe this bug is also still present, but those hit first.)

@scabug
Copy link
Author

scabug commented Oct 1, 2011

Jesse Eichar (jesseeichar) said:
I have specialized subclasses of Iterator but I have found a case where it crashes the compiler. Code is as follows:

trait Iter[@specialized(Byte) +A] extends Iterator[A] {
self =>
override def map[B](f: (A) => B) = super.map(f)
}

class ByteIter extends Iter[Byte] {
var i = 0
def hasNext = i<3
def next = {i += 1;i.toByte}
}

Message and top of stack trace is:

error: java.lang.UnsupportedOperationException: tail of empty list
at scala.collection.immutable.Nil$.tail(List.scala:373)
at scala.collection.immutable.Nil$.tail(List.scala:368)
at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$rebindSuper$1.apply(Mixin.scala:96)

just compile the above code with scalac to see full trace

@scabug
Copy link
Author

scabug commented Feb 19, 2012

@paulp said:
Jesse's bug is #4012.

@scabug
Copy link
Author

scabug commented May 10, 2012

@retronym said:
Another day, another mode of failure.

Minimized:

trait Bounds[@specialized A] {
  // okay without `>: A`
  def x[B >: A]: Unit = new Bounds[B] {
    lazy val it = ???  // def or val okay
    it
  }
}

Seems in the same neck of the woods as the recently remedied #5629.

@scabug
Copy link
Author

scabug commented May 10, 2012

@paulp said:
Your test case is a near perfect duplicate of mine in #4717. I'm going to close this one then and try to make that the new hot spot for young compiler hackers on the town.

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