Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-5608

Typer error when instantiating value class from value in array

    Details

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              extempore Paul Phillips
              Reporter:
              d_m Erik Osheim
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: