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

[Regression] java.lang.VerifyError: Incompatible object argument for function call

    Details

      Description

      This is a regression from Scala 2.9.2 and it requires specialization and separate compilation to trigger a VerifyError. Unfortunately, removing specialization causes a significant performance regression for our app.

      Given:

      bar/bar.scala

      package bar
      
      abstract class IntBase[V] extends Base[Int, V]
      
      class DefaultIntBase[V <: IntProvider] extends IntBase[V] {
        override protected def hashCode(key: Int) = key
      }
      
      trait IntProvider {
        def int: Int
      }
      
      abstract class Base[@specialized K, V] {
      
        protected def hashCode(key: K) = key.hashCode
      
        def get(key: K): V = throw new RuntimeException
      
      }
      

      foo/foo.scala

      package foo
      
      import bar._
      
      class FooProvider extends IntProvider {
        def int = 3
      }
      
      class Wrapper(users: DefaultIntBase[FooProvider]) {
        final def user(userId: Int) = users.get(userId)
      }
      
      object Test {
        def main(args: Array[String]) {
          new Wrapper(new DefaultIntBase)
        }
      }
      
      

      Steps to reproduce:

      1. scalac bar/bar.scala
      2. scalac foo/foo.scala
      3. scala foo.Test

      Expected outcome: No output.

      Actual outcome:

      java.lang.VerifyError: (class: foo/Wrapper, method: user signature: (I)Lfoo/FooProvider Incompatible object argument for function call
      at foo.Test$.main(foo.scala:15)
      at foo.Test.main(foo.scala)

        Issue Links

          Activity

          Hide
          Adriaan Moors added a comment -

          based on the resources we currently have, I'd say specialization isn't going to be fixed before 2.11.x

          Show
          Adriaan Moors added a comment - based on the resources we currently have, I'd say specialization isn't going to be fixed before 2.11.x
          Hide
          Paul Phillips added a comment -

          I fixed it in master a while ago; as you can see, the fix is not in RC1. SI-6301, https://github.com/scala/scala/commit/a3680be29c .

          Show
          Paul Phillips added a comment - I fixed it in master a while ago; as you can see, the fix is not in RC1. SI-6301 , https://github.com/scala/scala/commit/a3680be29c .
          Hide
          Paul Phillips added a comment -

          I realize it's not the least bit obvious that ticket and commit have anything to do with this one; I cite it because I noticed it was fixed in master and bisected my way to it.

          Show
          Paul Phillips added a comment - I realize it's not the least bit obvious that ticket and commit have anything to do with this one; I cite it because I noticed it was fixed in master and bisected my way to it.
          Hide
          Ismael Juma added a comment -

          Hi Adriaan. I certainly understand not making major changes until 2.11.x, but it would certainly be nice to avoid regressions that cause a VerifyError.

          Thanks Paul! A shame that it was never integrated in the 2.10.0 stream. Is there any chance it can go to 2.10.x at least?

          Show
          Ismael Juma added a comment - Hi Adriaan. I certainly understand not making major changes until 2.11.x, but it would certainly be nice to avoid regressions that cause a VerifyError. Thanks Paul! A shame that it was never integrated in the 2.10.0 stream. Is there any chance it can go to 2.10.x at least?
          Hide
          Adriaan Moors added a comment -

          I just meant to set realistic expectations about stabilizing specialization as a whole. We want to focus on speed in 2.11 (aka Scala S).

          If Paul has a fix already, and it doesn't cause binary incompatibilities, it seems likely to be fixed in 2.10.1.

          Show
          Adriaan Moors added a comment - I just meant to set realistic expectations about stabilizing specialization as a whole. We want to focus on speed in 2.11 (aka Scala S). If Paul has a fix already, and it doesn't cause binary incompatibilities, it seems likely to be fixed in 2.10.1.
          Hide
          Ismael Juma added a comment -

          Sure, my expectations around specialization are just "don't make it worse". I've been around for long enough.

          Show
          Ismael Juma added a comment - Sure, my expectations around specialization are just "don't make it worse". I've been around for long enough.
          Hide
          Jason Zaugg added a comment -
          Show
          Jason Zaugg added a comment - Backport: https://github.com/scala/scala/pull/2006
          Hide
          Paul Phillips added a comment -

          36f78dd

          Show
          Paul Phillips added a comment - 36f78dd

            People

            • Assignee:
              Paul Phillips
              Reporter:
              Ismael Juma
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development