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

Specialized classes with lazy vals generate broken variants

    Details

      Description

      Here's the test case:

      import scala.{specialized => spec}
      class C[@spec(Int) A](a:A) {
        lazy val b = (a, a)
        def c = b
      }
      object Test {
        def main(args:Array[String]) {
          println(new C(3).c)
          println(new C(3.0).c)
        }
      }
      

      Expected output:

      (3,3)
      (3.0,3.0)
      

      Actual output:

      null
      (3.0,3.0)
      

      The problem seems to be that the specialized subclass doesn't get its own bitmap... it just assumes its lazy val field has already been initialized. I'm not really an expert on lazy val, but barring deeper changes (e.g. not duplicating vals between generic class and specialized subclass) I think we need to copy the bitmask and the code in b that checks it.

        Attachments

          Activity

            People

            • Assignee:
              ureche Vlad Ureche
              Reporter:
              d_m Erik Osheim
              TracCC:
              Iulian Dragos, Vlad Ureche
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: