Scala Programming Language
  1. Scala Programming Language
  2. SI-5031

type alias and object with the same name report bogus error message about companion objects

    Details

      Description

      Attached is a three-file reproduction with instructions to reproduce with either scalac or sbt.

      The bug persists with -no-specialization; and appears in at least 2.8.1 and 2.9.1.

      Workaround is to choose a different name for the object.

      error: java.lang.NullPointerException
      	at scala.tools.nsc.Global$Run.compiles(Global.scala:843)
      	at scala.tools.nsc.Global$Run.compiles(Global.scala:844)
      	at scala.tools.nsc.Global$Run.compiles(Global.scala:843)
      	at scala.tools.nsc.transform.SpecializeTypes.addConcreteSpecMethod(SpecializeTypes.scala:1760)
      	at scala.tools.nsc.transform.SpecializeTypes.scala$tools$nsc$transform$SpecializeTypes$$specializeMember(SpecializeTypes.scala:838)
      	at scala.tools.nsc.transform.SpecializeTypes$$anonfun$16$$anonfun$apply$17.apply(SpecializeTypes.scala:719)
      	at scala.tools.nsc.transform.SpecializeTypes$$anonfun$16$$anonfun$apply$17.apply(SpecializeTypes.scala:718)
      	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:200)
      	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:200)
      	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
      	at scala.collection.immutable.List.foreach(List.scala:45)
      	at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:200)
      	at scala.collection.immutable.List.flatMap(List.scala:45)
      	at scala.tools.nsc.transform.SpecializeTypes$$anonfun$16.apply(SpecializeTypes.scala:718)
      	at scala.tools.nsc.transform.SpecializeTypes$$anonfun$16.apply(SpecializeTypes.scala:716)
      	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:200)
      	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:200)
      	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
      

        Issue Links

          Activity

          Hide
          Paolo G. Giarrusso added a comment -

          Thanks a lot! I think confusion has arisen because the original bug report was about something else for 2.8.1 and 2.9.1, while Paul Phillips's comment switched the discussion to the regression. It might be worth preserving the original bug report.
          But at least, the regression won't be forgot.

          Show
          Paolo G. Giarrusso added a comment - Thanks a lot! I think confusion has arisen because the original bug report was about something else for 2.8.1 and 2.9.1, while Paul Phillips's comment switched the discussion to the regression. It might be worth preserving the original bug report. But at least, the regression won't be forgot.
          Hide
          Hubert Plociniczak added a comment - - edited

          Here is the minimized code from the zip file that illustrates the regression.
          Id.scala:

          package t5031
          object ID
          

          package.scala:

          package object t5031 {
            type ID = Int
          }
          
          Show
          Hubert Plociniczak added a comment - - edited Here is the minimized code from the zip file that illustrates the regression. Id.scala: package t5031 object ID package.scala: package object t5031 { type ID = Int }
          Show
          Hubert Plociniczak added a comment - https://github.com/scala/scala/pull/1016
          Hide
          Johannes Rudolph added a comment -

          This is still broken in 2.10.0-RC1 (and a regression from 2.9.2) with separate compilation.

          See this case:

          https://gist.github.com/3916794

          The problem is that the non-companion object can't be accessed at all from code not compiled at the same time as with the type-alias/object code.

          The workaround of putting the object into the package object still works.

          Show
          Johannes Rudolph added a comment - This is still broken in 2.10.0-RC1 (and a regression from 2.9.2) with separate compilation. See this case: https://gist.github.com/3916794 The problem is that the non-companion object can't be accessed at all from code not compiled at the same time as with the type-alias/object code. The workaround of putting the object into the package object still works.
          Show
          Hubert Plociniczak added a comment - https://github.com/scala/scala/pull/1532

            People

            • Assignee:
              Hubert Plociniczak
              Reporter:
              Jason Zaugg
            • Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development