diff options
author | Den Shabalin <den.shabalin@gmail.com> | 2013-12-02 15:12:54 +0100 |
---|---|---|
committer | Den Shabalin <den.shabalin@gmail.com> | 2013-12-10 16:02:13 +0100 |
commit | 0ccd4bcac64efe72d9758fbfb6a6dbce44cf308e (patch) | |
tree | a3531dc11a14924c9c527a086215c2b2504b296d /test/files/scalacheck | |
parent | 26959249070cc0a00270e192885940dab050a693 (diff) | |
download | scala-0ccd4bcac64efe72d9758fbfb6a6dbce44cf308e.tar.gz scala-0ccd4bcac64efe72d9758fbfb6a6dbce44cf308e.tar.bz2 scala-0ccd4bcac64efe72d9758fbfb6a6dbce44cf308e.zip |
SI-6842 Make splicing less sensitive to precise types of trees
Previously trees that represent parameters, case clauses and
type variables had strictly defined ValDef, TypeDef and CaseDef
types which caused problems in compositionality.
Now this checks are moved to runtime so it's possible to pass
a tree that is CaseDef but has Tree type.
Diffstat (limited to 'test/files/scalacheck')
3 files changed, 26 insertions, 14 deletions
diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala index 2ec679e78b..2af656c7c9 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala @@ -2,12 +2,25 @@ import org.scalacheck._, Prop._, Gen._, Arbitrary._ import scala.reflect.runtime.universe._, Flag._, build.ScalaDot object DefinitionConstructionProps - extends QuasiquoteProperties("definition construction") - with ClassConstruction - with TraitConstruction - with TypeDefConstruction - with ValDefConstruction - with PackageConstruction + extends QuasiquoteProperties("definition construction") + with ClassConstruction + with TraitConstruction + with TypeDefConstruction + with ValDefConstruction + with PackageConstruction { + property("SI-6842") = test { + val x: Tree = q"val x: Int" + assertEqAst(q"def f($x) = 0", "def f(x: Int) = 0") + assertEqAst(q"class C($x)", "class C(val x: Int)") + assertEqAst(q"class C { $x => }", "class C { x: Int => }") + assertEqAst(q"trait B { $x => }", "trait B { x: Int => }") + assertEqAst(q"object A { $x => }", "object A { x: Int => }") + val t: Tree = q"type T" + assertEqAst(q"def f[$t] = 0", "def f[T] = 0") + assertEqAst(q"class C[$t]", "class C[T]") + assertEqAst(q"trait B[$t]", "trait B[T]") + } +} trait ClassConstruction { self: QuasiquoteProperties => val anyRef = ScalaDot(TypeName("AnyRef")) @@ -283,7 +296,7 @@ trait MethodConstruction { self: QuasiquoteProperties => assertEqAst(q"@$a def foo", "@Foo[A,B] def foo") } - property("splice annotation with multiple argument lists") = test{ + property("splice annotation with multiple argument lists") = test { val a = q"new Foo(a)(b)" assertEqAst(q"@$a def foo", "@Foo(a)(b) def foo") } diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala index cb46a60dbe..adad48fcdf 100644 --- a/test/files/scalacheck/quasiquotes/ErrorProps.scala +++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala @@ -105,13 +105,6 @@ object ErrorProps extends QuasiquoteProperties("errors") { q"f($sb)" """) - property("casedef expected") = fails( - "reflect.runtime.universe.CaseDef expected but reflect.runtime.universe.Tree found", - """ - val t = EmptyTree - q"_ { case $t }" - """) - property("can't splice with ... card here") = fails( "Can't splice with ... here", """ diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala index ded8fd9c16..338c379fc3 100644 --- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala @@ -210,6 +210,12 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") { assertEqAst(q"{..$xs}", "{1; 2}") } + property("SI-6842") = test { + val cases: List[Tree] = cq"a => b" :: cq"_ => c" :: Nil + assertEqAst(q"1 match { case ..$cases }", "1 match { case a => b case _ => c }") + assertEqAst(q"try 1 catch { case ..$cases }", "try 1 catch { case a => b case _ => c }") + } + property("SI-8009") = test { q"`foo`".asInstanceOf[reflect.internal.SymbolTable#Ident].isBackquoted } |