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

Typer error when instantiating value class from value in array #5608

Closed
scabug opened this issue Mar 26, 2012 · 4 comments
Closed

Typer error when instantiating value class from value in array #5608

scabug opened this issue Mar 26, 2012 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 26, 2012

Here's a simple test program:

object Main {
  def main(args:Array[String]) {
    val ns = Array(3L, 3L, 3L)
    val a:A = new A(ns(0))
  }
}

class A(val u:Long) extends AnyVal

It currently crashes with an error in typer:

exception when typing new <error>(ns.apply(0).$asInstanceOf[<notype>]())
class type required but <notype> found in file test.scala
scala.reflect.internal.Types$TypeError: class type required but <notype> found
        at scala.tools.nsc.typechecker.Contexts$Context.issue(Contexts.scala:317)

If you save the dereference Long in a val and then instantiate A, things are fine.

@scabug
Copy link
Author

scabug commented Mar 26, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5608?orig=1
Reporter: @non
Other Milestones: 2.10.0
Attachments:

  • error.txt (created on Mar 27, 2012 2:42:37 PM UTC, 17511 bytes)

@scabug
Copy link
Author

scabug commented Mar 26, 2012

@non said:
I should add that if you cast to A (rather than construct A) things seem to work:

ns(0).asInstanceOf[A]

@scabug
Copy link
Author

scabug commented Mar 27, 2012

@cvogt said (edited on Mar 27, 2012 2:43:03 PM UTC):
confirmed in 8f42361d71d11e9522052dcb5d9be020df7e5cc5

I attached the complete error message as error.txt

@scabug scabug closed this as completed May 3, 2012
@scabug
Copy link
Author

scabug commented May 3, 2012

@paulp said:
453d615fb3

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017
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