summaryrefslogtreecommitdiff
path: root/test/files/neg/specification-scopes
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-14 22:16:52 -0800
committerPaul Phillips <paulp@improving.org>2012-01-14 22:16:52 -0800
commit9eb56b99610d734088a0dd2da7cded49211eff3a (patch)
treef1f841dd3f878128b3c0ef0a738aeba9758b9efe /test/files/neg/specification-scopes
parent3024efcbf902417017b6ec0a442a3db4cf930d22 (diff)
downloadscala-9eb56b99610d734088a0dd2da7cded49211eff3a.tar.gz
scala-9eb56b99610d734088a0dd2da7cded49211eff3a.tar.bz2
scala-9eb56b99610d734088a0dd2da7cded49211eff3a.zip
Test case backing spec.
Added code from SLS 2.0.2.
Diffstat (limited to 'test/files/neg/specification-scopes')
-rw-r--r--test/files/neg/specification-scopes/P_1.scala6
-rw-r--r--test/files/neg/specification-scopes/P_2.scala21
2 files changed, 27 insertions, 0 deletions
diff --git a/test/files/neg/specification-scopes/P_1.scala b/test/files/neg/specification-scopes/P_1.scala
new file mode 100644
index 0000000000..3b11f1167d
--- /dev/null
+++ b/test/files/neg/specification-scopes/P_1.scala
@@ -0,0 +1,6 @@
+package P {
+ object X { val x = 1; val y = 2; }
+}
+package Q {
+ object X { val x = true; val y = "" }
+}
diff --git a/test/files/neg/specification-scopes/P_2.scala b/test/files/neg/specification-scopes/P_2.scala
new file mode 100644
index 0000000000..d59f82e90d
--- /dev/null
+++ b/test/files/neg/specification-scopes/P_2.scala
@@ -0,0 +1,21 @@
+package P { // 'X' bound by package clause
+ import Console._ // 'println' bound by wildcard import
+ object A {
+ println("L4: "+X) // 'X' refers to 'P.X' here
+ object B {
+ import Q._ // 'X' bound by wildcard import
+ println("L7: "+X) // 'X' refers to 'Q.X' here
+ import X._ // 'x' and 'y' bound by wildcard import
+ println("L8: "+x) // 'x' refers to 'Q.X.x' here
+ object C {
+ val x = 3 // 'x' bound by local definition
+ println("L12: "+x); // 'x' refers to constant '3' here
+ { import Q.X._ // 'x' and 'y' bound by wildcard
+ println("L14: "+x) // reference to 'x' is ambiguous here
+ import X.y // 'y' bound by explicit import
+ println("L16: "+y); // 'y' refers to 'Q.X.y' here
+ { val x = "abc" // 'x' bound by local definition
+ import P.X._ // 'x' and 'y' bound by wildcard
+ println("L19: "+y) // reference to 'y' is ambiguous here
+ println("L20: "+x) // 'x' refers to string ''abc'' here
+}}}}}}