Skip to content

Commit

Permalink
SI-8148 fix anonymous functions with placeholders
Browse files Browse the repository at this point in the history
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
densh committed Jan 16, 2014
1 parent 681308a commit 973c706
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -193,4 +193,4 @@ trait Parsers { self: Quasiquotes =>
}

object FreshName extends FreshNameExtractor(nme.QUASIQUOTE_PREFIX)
}
}
5 changes: 5 additions & 0 deletions test/files/scalacheck/quasiquotes/TermConstructionProps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.