Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler throws IllegalArgumentException handling specialized method implementation #6286

Closed
scabug opened this issue Aug 26, 2012 · 3 comments
Closed

Comments

@scabug
Copy link

@scabug scabug commented Aug 26, 2012

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)
@scabug
Copy link
Author

@scabug scabug commented Aug 26, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6286?orig=1
Reporter: Adam Klein (aklein-at-novus.com)
Affected Versions: 2.10.0
Other Milestones: 2.11.0-M3
Attachments:

  • exception.txt (created on Aug 26, 2012 9:41:02 PM UTC, 8757 bytes)

@scabug
Copy link
Author

@scabug scabug commented Sep 6, 2012

@non said:
The crucial point here seems to be the "val arr = values".

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

@scabug
Copy link
Author

@scabug scabug commented Sep 6, 2012

@non said:
(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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants