Permalink
Browse files

SI-8148 fix anonymous functions with placeholders

Quasiquotes used to fail to generate proper fresh identifiers for
anonymous functions like:

  q"_ + _"

Due to improper initialization of FreshNameCreator in quasiquote
parser which was erroneously not preserved throughout parsing of
the code snippet but re-created on every invocation.
  • Loading branch information...
1 parent 681308a commit 973c7066b8e0ab3529ce42989091f31d410a32ab @densh densh committed Jan 14, 2014
@@ -55,7 +55,7 @@ trait Parsers { self: Quasiquotes =>
def isHole(name: Name): Boolean = holeMap.contains(name)
- override implicit def fresh: FreshNameCreator = new FreshNameCreator(nme.QUASIQUOTE_PREFIX)
+ override implicit lazy val fresh: FreshNameCreator = new FreshNameCreator(nme.QUASIQUOTE_PREFIX)
override val treeBuilder = new ParserTreeBuilder {
override implicit def fresh: FreshNameCreator = parser.fresh
@@ -193,4 +193,4 @@ trait Parsers { self: Quasiquotes =>
}
object FreshName extends FreshNameExtractor(nme.QUASIQUOTE_PREFIX)
-}
+}
@@ -224,4 +224,9 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
property("SI-8009") = test {
q"`foo`".asInstanceOf[reflect.internal.SymbolTable#Ident].isBackquoted
}
+
+ property("SI-8148") = test {
+ val q"($a, $b) => $_" = q"_ + _"
+ assert(a.name != b.name)
+ }
}

0 comments on commit 973c706

Please sign in to comment.