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

Seq/Array varargs crash #4024

Closed
scabug opened this issue Nov 23, 2010 · 6 comments
Closed

Seq/Array varargs crash #4024

scabug opened this issue Nov 23, 2010 · 6 comments
Assignees

Comments

@scabug
Copy link

scabug commented Nov 23, 2010

Welcome to Scala version 2.9.0.r23530-b20101116170224 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> val x = "abc" 
x: java.lang.String = abc

scala> x.getClass.getMethod("toString")
res0: java.lang.reflect.Method = public java.lang.String java.lang.String.toString()

scala> res0.invoke(x)
res1: java.lang.Object = abc

scala> res0.invoke(x, Array[AnyRef](): _*)
res2: java.lang.Object = abc

scala> res0.invoke(x, List[AnyRef](): _*)
res3: java.lang.Object = abc

scala> res0.invoke(x, (Nil: List[AnyRef]): _*)
res4: java.lang.Object = abc

scala> res0.invoke(x, Nil: _*)            
exception when traversing line2$$object.$$iw.$$iw.res0.invoke(line0$$object.$$iw.$$iw.x, (immutable.this.Nil: _*))
exception when traversing private[this] val res3: java.lang.Object = line2$$object.$$iw.$$iw.res0.invoke(line0$$object.$$iw.$$iw.x, (immutable.this.Nil: _*))
exception when traversing java.lang.Object with ScalaObject {
  def this(): object $$iw.$$iw = {
[...]
Exception in thread "main" java.util.NoSuchElementException: head of empty list
	at scala.collection.immutable.Nil$$.head(List.scala:389)
	at scala.collection.immutable.Nil$$.head(List.scala:386)
	at scala.tools.nsc.transform.UnCurry$$UnCurryTransformer$$$$anonfun$$sequenceToArray$$1$$1.apply(UnCurry.scala:419)
	at scala.tools.nsc.transform.UnCurry$$UnCurryTransformer$$$$anonfun$$sequenceToArray$$1$$1.apply(UnCurry.scala:418)
	at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:104)
	at scala.tools.nsc.transform.UnCurry$$UnCurryTransformer.sequenceToArray$$1(UnCurry.scala:417)
	at scala.tools.nsc.transform.UnCurry$$UnCurryTransformer.transformVarargs$$1(UnCurry.scala:429)
	at scala.tools.nsc.transform.UnCurry$$UnCurryTransformer.transformArgs(UnCurry.scala:449)
	at scala.tools.nsc.transform.UnCurry$$UnCurryTransformer$$$$anonfun$$mainTransform$$3.apply(UnCurry.scala:589)
	at scala.tools.nsc.transform.UnCurry$$UnCurryTransformer$$$$anonfun$$mainTransform$$3.apply(UnCurry.scala:587)
@scabug
Copy link
Author

scabug commented Nov 23, 2010

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

@scabug
Copy link
Author

scabug commented Nov 23, 2010

@paulp said:
Here's another one, crashing a different way.

scala> res0.invoke(x, Seq(): _*)
exception when traversing line2$$object.$$iw.$$iw.res0.invoke(line0$$object.$$iw.$$iw.x, (collection.this.Seq.apply[Nothing](): _*))
exception when traversing private[this] val res1: java.lang.Object = line2$$object.$$iw.$$iw.res0.invoke(line0$$object.$$iw.$$iw.x, (collection.this.Seq.apply[Nothing](): _*))
...
Exception in thread "main" scala.tools.nsc.symtab.Types$$TypeError: type mismatch;
 found   : scala.reflect.Manifest[Nothing]
 required: scala.reflect.ClassManifest[B]
	at scala.tools.nsc.typechecker.Contexts$$Context.error(Contexts.scala:280)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.error(Infer.scala:203)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.typeError(Infer.scala:213)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.typeErrorTree(Infer.scala:228)
	at scala.tools.nsc.typechecker.Typers$$Typer.adapt(Typers.scala:1018)
	at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:4175)
	at scala.tools.nsc.typechecker.Typers$$Typer.typedArg(Typers.scala:2189)
	at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedArgs$$3.apply(Typers.scala:2200)
	at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedArgs$$3.apply(Typers.scala:2199)
	at scala.Tuple3$$Zipped$$$$anonfun$$map$$1.apply(Tuple3.scala:56)
	at scala.Tuple3$$Zipped$$$$anonfun$$map$$1.apply(Tuple3.scala:54)
	at scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:61)

@scabug
Copy link
Author

scabug commented Dec 14, 2010

@odersky said:
(In r23762) Closes #4024. No review.

@scabug
Copy link
Author

scabug commented Mar 28, 2011

@paulp said:
There was no test case checked in, a prerequisite to the fact that this bug is still with us. res0.invoke(x, Nil: _) still crashes as of r24610, as does res0.invoke(x, Seq(): _).

Here is a test case with both crashers for the convenience of the eventual closer.

object Test {
  def main(args: Array[String]): Unit = {
    val x = "abc"
    val m = x.getClass.getMethod("toString")
    m.invoke(x, Nil: _*)
    m.invoke(x, Seq(): _*)
  }
}

@scabug
Copy link
Author

scabug commented Mar 28, 2011

@paulp said:
See also #4207 which I marked duplicate.

@scabug
Copy link
Author

scabug commented Dec 20, 2011

@paulp said:
Fixed in 6912ff828db2 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants