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

reify could transport Select node's symbols to the other side #6627

Closed
scabug opened this issue Nov 8, 2012 · 5 comments
Closed

reify could transport Select node's symbols to the other side #6627

scabug opened this issue Nov 8, 2012 · 5 comments

Comments

@scabug
Copy link

scabug commented Nov 8, 2012

Usage would be:

  val List_contains = termSym(reify((_: List[Any]).contains(null)))

I suppose we could then collapse it into a macro to avoid seeing the reify call here.

But first, I'm stuck with a NoSymbol on the Select(..., "contains") node.

scala> val cm = reflect.runtime.currentMirror
cm: reflect.runtime.universe.Mirror = JavaMirror with 

scala> val t = cm.universe.reify ( (_: List[Any]).contains(null) ).tree
t: cm.universe.Tree = ((x$1: List[Any]) => (x$1: List[Any]).contains(null))

scala> val symTrees = t.collect { case s: cm.universe.SymTree => s }
symTrees: List[cm.universe.SymTree] = List(((x$1: List[Any]) => (x$1: List[Any]).contains(null)), <synthetic> val x$1: List[Any] = _, List, Any, (x$1: List[Any]).contains, x$1, List, Any)
res3: String = 
(((x$1: List[Any]) => (x$1: List[Any]).contains(null)),Function,<none>)
(<synthetic> val x$1: List[Any] = _,ValDef,<none>)
(List,Ident,type List)
(Any,Ident,class Any)
((x$1: List[Any]).contains,Select,<none>)
(x$1,Ident,<none>)
(List,Ident,type List)
(Any,Ident,class Any)
@scabug
Copy link
Author

scabug commented Nov 8, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6627?orig=1
Reporter: @retronym
Affected Versions: 2.10.0-RC1

@scabug
Copy link
Author

scabug commented Nov 8, 2012

@retronym said:
Patched by Eugene on a branch:

https://github.com/scalamacros/kepler/commits/topic/reify-select-symbols

@scabug
Copy link
Author

scabug commented Nov 8, 2012

@xeno-by said:
The tests are failing, but I'm looking into it.

@scabug
Copy link
Author

scabug commented Nov 8, 2012

@xeno-by said (edited on Nov 8, 2012 10:03:49 AM UTC):
https://scala-webapps.epfl.ch/jenkins/job/scala-checkin-manual/647/console

Looks like the simple match I implemented doesn't trivially work. Several test failures from the linked jenkins log are fixed by updating the check file (e.g. if a symbol is assigned to a method with a symbolic name like "", it starts to print correctly as "", not as "$plus"). Edit. Yay for JIRA being smart and not letting me to write the plus symbol verbatim.

But there is tricky stuff. I'm quite unsettled by messages like "not found: value " in subsequent toolboxive compilation of certain reified snippets. Also I'm not sure that letting stuff like "$u.build.selectOverloadedMethod($m.staticModule("scala.Array").asModule.moduleClass, "apply", 5))" leak into reify output is a good idea.

All in all, I suggest we postpone this activity in favor of the context-carrying trees research. If that one succeeds, we won't need the symbol business to work with macros.

@scabug
Copy link
Author

scabug commented Dec 4, 2012

@retronym said:
Agreed this isn't a great idea, closing.

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