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

Could not find proxy error with macros #8272

Closed
scabug opened this issue Feb 13, 2014 · 7 comments
Closed

Could not find proxy error with macros #8272

scabug opened this issue Feb 13, 2014 · 7 comments

Comments

@scabug
Copy link

scabug commented Feb 13, 2014

I have a regression with macros but I don't really know when/how it was introduced. You can reproduce it by cloning this branch, then go to the specs2-matcher-extra sub-project and execute "test:compile":

 last tree to typer: TypeTree(object CatMatcher$4)
              symbol: object CatMatcher$4 in class MTest (flags: <module> <synthetic>)
   symbol definition: class CatMatcher$4 extends runtime.AbstractFunction1 with Serializable
                 tpe: org.specs2.matcher.MTest#CatMatcher$4.type
       symbol owners: object CatMatcher$4 -> class MTest -> package matcher
      context owners: method apply -> anonymous class $anonfun$apply$7 -> method apply -> anonymous class $anonfun$test$1 -> method test -> class MTest -> package matcher

== Enclosing template or block ==

DefDef( // final def apply(): String
  <method> final <triedcooking>
  "apply"
  []
  List(Nil)
  <tpt> // tree.tpe=String
  "fieldValue" // fieldValue: String, tree.tpe=String
)

== Expanded type of tree ==

TypeRef(
  pre = TypeRef(TypeSymbol(class MTest extends MustExpectations))
  TypeSymbol(
    class CatMatcher$4 extends runtime.AbstractFunction1 with Serializable

  )
)

unhandled exception while transforming MTest.scala
[error] uncaught exception during compilation: java.lang.IllegalArgumentException
[trace] Stack trace suppressed: run last specs2-matcher-extra/test:compile for the full output.
[error] (specs2-matcher-extra/test:compile) java.lang.IllegalArgumentException: Could not find proxy for fieldValue: String in List(value fieldValue, value $anonfun, value <local CatMatcher>, class CatMatcher$3, class MTest, package matcher, package specs2, package org, package <root>) (currentOwner= method apply )

I don't know how to reduce it to something simpler but hopefully you can reproduce the problem and have some insight on what's going wrong.

@scabug
Copy link
Author

scabug commented Feb 13, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8272?orig=1
Reporter: @etorreborre
Affected Versions: 2.10.3, 2.11.0-RC1

@scabug
Copy link
Author

scabug commented Feb 13, 2014

@xeno-by said:
Hi, thanks for reporting! Is this also a problem for 2.11?

I tried to look into it, but the link you provided doesn't work for me. Also, these days 2.11.0-RC1 activities take a lot of time, so I'd appreciate if you could track the regression to a certain commit. That would make it easier to provide a fix / suggest a workaround.

@scabug
Copy link
Author

scabug commented Feb 18, 2014

@etorreborre said:
I've found the source of the regression. This is the change from resetAllAttrs to resetLocalAttrs. I also get the same error when using Scala 2.11.0-M8.

@scabug
Copy link
Author

scabug commented Feb 18, 2014

@etorreborre said:
And resetAllAttrs works fine with both 2.10 and 2.11.0-M8.

@scabug
Copy link
Author

scabug commented Feb 18, 2014

@xeno-by said:
Will fix today.

@scabug
Copy link
Author

scabug commented Feb 18, 2014

@xeno-by said:
Can't reproduce. Both with resetLocalAttrs and with resetAllAttrs I'm getting the same error:

[error] /Users/xeno_by/Projects/specs2/matcher-extra/src/test/scala/org/specs2/matcher/MTest.scala:9: type mismatch;
[error]  found   : Unit
[error]  required: CatMatcher
[error]     matchA[Cat].name("Kitty")
[error]                     ^

Actually, I have a guess about what might be the problem here. How about changing

flatMap(_.scalaArgs.collectFirst { case Function(ValDef(_, a, _, _) :: Nil, b) => a -> c.resetLocalAttrs(b) }).

to

flatMap(_.scalaArgs.map(arg => c.resetLocalAttrs(arg)).collectFirst { case Function(ValDef(_, a, _, _) :: Nil, b) => a -> b }).

Would that help?

@scabug
Copy link
Author

scabug commented Feb 18, 2014

@etorreborre said:
That works fine, thanks. However I find a bit weird that you can't reproduce my "test:compile" issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants