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

Compiler throws IllegalArgumentException handling specialized method implementation

    Details

      Description

      Here is a code sample in which this exception occurs. I have attached the full exception output.

      trait Foo[@specialized(Int) A] {
        def fun[@specialized(Int) B](init: B)(f: (B, A) => B): B
      }
      
      class Bar(values: Array[Int]) extends Foo[Int] {
        def fun[@specialized(Int) C](init: C)(f: (C, Int) => C): C = {
          val arr = values
          f(init, arr(0))
        }
      }
      

      The exception starts:

      [error] uncaught exception during compilation: java.lang.IllegalArgumentException
      java.lang.IllegalArgumentException: Could not find proxy for val arr: Array[Int] in List(value arr, method fun$mcI$sp, class Bar, package <empty>, package <root>) (currentOwner= method fun$mIcI$sp )
      	at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1(LambdaLift.scala:303)
      	at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
      	at scala.tools.nsc.transform.LambdaLift$LambdaLifter$$anonfun$scala$tools$nsc$transform$LambdaLift$LambdaLifter$$searchIn$1$2.apply(LambdaLift.scala:308)
      	at scala.Option.getOrElse(Option.scala:120)
      

        Activity

        Hide
        Erik Osheim added a comment -

        The crucial point here seems to be the "val arr = values".

        If changed to use values(0) directly, things are fine.

        Show
        Erik Osheim added a comment - The crucial point here seems to be the "val arr = values". If changed to use values(0) directly, things are fine.
        Hide
        Erik Osheim added a comment -

        (That last comment would probably be obvious to compiler hackers.)

        My current idea about what's going on here is that there's a problem with owners. These debug messages seem to point the way:

        [log lambdalift(->constructors)] proxy value x (flags: <triedcooking>) from method arg$mIcI$sp
        in class Bar (flags: <method> <specialized> <triedcooking>) has logical enclosure method arg$mc
        I$sp in class Bar (flags: <method> <specialized> <triedcooking>)
        [log lambdalift(->constructors)] searching for value x(method arg$mcI$sp) in method arg$mIcI$sp
         method arg$mIcI$sp
        [log lambdalift(->constructors)] searching for value x(method arg$mcI$sp) in class Bar class Ba
        r
        [log lambdalift(->constructors)] searching for value x(method arg$mcI$sp) in package <empty> pa
        ckage <empty>
        [log lambdalift(->constructors)] searching for value x(method arg$mcI$sp) in package <root> pac
        kage <root>
        

        It looks like the compiler is searching for arg$mcI$sp's "x" inside the wrong method (arg$mIcI$sp).

        Show
        Erik Osheim added a comment - (That last comment would probably be obvious to compiler hackers.) My current idea about what's going on here is that there's a problem with owners. These debug messages seem to point the way: [log lambdalift(->constructors)] proxy value x (flags: <triedcooking>) from method arg$mIcI$sp in class Bar (flags: <method> <specialized> <triedcooking>) has logical enclosure method arg$mc I$sp in class Bar (flags: <method> <specialized> <triedcooking>) [log lambdalift(->constructors)] searching for value x(method arg$mcI$sp) in method arg$mIcI$sp method arg$mIcI$sp [log lambdalift(->constructors)] searching for value x(method arg$mcI$sp) in class Bar class Ba r [log lambdalift(->constructors)] searching for value x(method arg$mcI$sp) in package <empty> pa ckage <empty> [log lambdalift(->constructors)] searching for value x(method arg$mcI$sp) in package <root> pac kage <root> It looks like the compiler is searching for arg$mcI$sp's "x" inside the wrong method (arg$mIcI$sp).

          People

          • Assignee:
            Eugene Vigdorchik
            Reporter:
            Adam Klein
            TracCC:
            Chris Lewis, Erik Osheim, Vlad Ureche
          • Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development