summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDenys Shabalin <denys.shabalin@typesafe.com>2014-02-06 19:51:43 +0100
committerDenys Shabalin <denys.shabalin@typesafe.com>2014-02-07 12:47:45 +0100
commit1e5654c8bd10a3649ccc97c42a7949b179480073 (patch)
tree62bb8d1c833099d858209affc49b152eaf5e2a58 /test
parentd60b8323dda884653f31410806c269d15140e5e6 (diff)
downloadscala-1e5654c8bd10a3649ccc97c42a7949b179480073.tar.gz
scala-1e5654c8bd10a3649ccc97c42a7949b179480073.tar.bz2
scala-1e5654c8bd10a3649ccc97c42a7949b179480073.zip
Represent tq"" as SyntacticEmptyTypeTree rather than TypeTree()
Such representation codifies the fact that type tree that doesn't have embedded syntactic equivalent must have been inferred or otherwise provided by the compiler rather than specified by the end user. Additionally it also ensures that we can still match trees without explicit types (e.g. vals without type) after typechecking. Otherwise the same quote couldn't be used in situations like: val q"val x = 42" = typecheck(q"val x = 42")
Diffstat (limited to 'test')
-rw-r--r--test/files/scalacheck/quasiquotes/TypeConstructionProps.scala2
-rw-r--r--test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala6
-rw-r--r--test/files/scalacheck/quasiquotes/TypecheckedProps.scala9
3 files changed, 15 insertions, 2 deletions
diff --git a/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
index 0984032084..78b54a4e49 100644
--- a/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
@@ -30,7 +30,7 @@ object TypeConstructionProps extends QuasiquoteProperties("type construction")
}
property("empty tq") = test {
- val tt: TypeTree = tq" "
+ val tt: TypeTree = tq""
assert(tt.tpe == null)
assert(tt.original == null)
}
diff --git a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
index 44f110a3d5..0fdcc19052 100644
--- a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
@@ -52,4 +52,10 @@ object TypeDeconstructionProps extends QuasiquoteProperties("type deconstruction
assert(arglast ≈ tq"C")
assert(restpe ≈ tq"D")
}
+
+ property("match empty type tree") = test {
+ val tq"" = TypeTree()
+ // matches because type tree isn't syntactic without original
+ val tq"" = tq"${typeOf[Int]}"
+ }
}
diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
index 2f501435e3..3afb47952c 100644
--- a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
@@ -75,4 +75,11 @@ object TypecheckedProps extends QuasiquoteProperties("typechecked") {
assert(f.original ≈ pq"Test.this.Cell")
assert(args ≈ List(pq"v"))
}
-} \ No newline at end of file
+
+ property("extract inferred val type") = test {
+ val typechecked = typecheck(q"val x = 42")
+ val q"val x = 42" = typechecked
+ val q"val x: ${tq""} = 42" = typechecked
+ val q"val x: ${t: Type} = 42" = typechecked
+ }
+}