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

varargs crash with empty sequence and inferred type #4207

Closed
scabug opened this issue Jan 30, 2011 · 2 comments
Closed

varargs crash with empty sequence and inferred type #4207

scabug opened this issue Jan 30, 2011 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented Jan 30, 2011

This looks similar to #4024. I am very pleased that the compiler is giving itself variance advice.

class A {
  val clazz = Class.forName("xxx")
  val ctr = clazz.getConstructor(Nil: _*)
  
  // also crashes
  // val ctr = clazz.getConstructor(List(): _*)
  //
  // does not crash
  // val ctr = clazz.getConstructor(List[Class[_]]: _*)
}
[paulp@leaf bug]$$ scalac29 a.scala 
exception when traversing A.this.clazz.getConstructor((immutable.this.Nil: _*))
exception when traversing private[this] val ctr: java.lang.reflect.Constructor[_] = A.this.clazz.getConstructor((immutable.this.Nil: _*))
exception when traversing java.lang.Object with ScalaObject {
  def this(): A = {
    A.super.this();
    ()
  };
  private[this] val clazz: java.lang.Class[_] = java.this.lang.Class.forName("xxx");

...
Exception in thread "main" scala.tools.nsc.symtab.Types$$TypeError: type mismatch;
 found   : scala.reflect.Manifest[Nothing]
 required: scala.reflect.ClassManifest[B]
Note: Nothing <: B, but trait ClassManifest is invariant in type T.
You may wish to investigate a wildcard type such as `_ <: B`. (SLS 3.2.10)
	at scala.tools.nsc.typechecker.Contexts$$Context.error(Contexts.scala:291)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.error(Infer.scala:205)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.typeError(Infer.scala:215)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.typeErrorTree(Infer.scala:230)
	at scala.tools.nsc.typechecker.Typers$$Typer.adapt(Typers.scala:926)
	at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:4142)
	at scala.tools.nsc.typechecker.Typers$$Typer.typedArg(Typers.scala:2131)
	at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedArgs$$3.apply(Typers.scala:2144)
	at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedArgs$$3.apply(Typers.scala:2143)
@scabug
Copy link
Author

scabug commented Jan 30, 2011

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

@scabug
Copy link
Author

scabug commented Mar 28, 2011

@paulp said:
This looks to be a duplicate of the first comment in the now-reopened #4024, which I reported a couple months before this one. Am I duplicating my own tickets? There's a sobering idea.

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