diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t5954.check | 16 | ||||
-rw-r--r-- | test/files/neg/t5954.scala | 46 | ||||
-rw-r--r-- | test/files/pos/package-case.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t2130-1.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t2130-2.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t3999b.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t4052.flags | 1 |
7 files changed, 67 insertions, 0 deletions
diff --git a/test/files/neg/t5954.check b/test/files/neg/t5954.check new file mode 100644 index 0000000000..3ca47cd430 --- /dev/null +++ b/test/files/neg/t5954.check @@ -0,0 +1,16 @@ +t5954.scala:36: error: implementation restriction: package object A cannot contain case class D. Instead, class D should be placed directly in package A. + case class D() + ^ +t5954.scala:35: error: implementation restriction: package object A cannot contain companion object C. Instead, object C should be placed directly in package A. + object C + ^ +t5954.scala:34: error: implementation restriction: package object A cannot contain companion trait C. Instead, trait C should be placed directly in package A. + trait C + ^ +t5954.scala:33: error: implementation restriction: package object A cannot contain companion object B. Instead, object B should be placed directly in package A. + object B + ^ +t5954.scala:32: error: implementation restriction: package object A cannot contain companion class B. Instead, class B should be placed directly in package A. + class B + ^ +5 errors found diff --git a/test/files/neg/t5954.scala b/test/files/neg/t5954.scala new file mode 100644 index 0000000000..9e6f5392c7 --- /dev/null +++ b/test/files/neg/t5954.scala @@ -0,0 +1,46 @@ +// if you ever think you've fixed the underlying reason for the implementation restrictions +// imposed by SI-5954, then here's a test that should pass with two "succes"es +// +//import scala.tools.partest._ +// +//object Test extends DirectTest { +// def code = ??? +// +// def problemCode = """ +// package object A { +// class B +// object B +// case class C() +// } +// """ +// +// def compileProblemCode() = { +// val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") +// compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(problemCode) +// } +// +// def show() : Unit = { +// for (i <- 0 until 2) { +// compileProblemCode() +// println(s"success ${i + 1}") +// } +// } +//} + +package object A { + // these should be prevented by the implementation restriction + class B + object B + trait C + object C + case class D() + // all the rest of these should be ok + class E + object F + val g = "omg" + var h = "wtf" + def i = "lol" + type j = String + class K(val k : Int) extends AnyVal + implicit class L(val l : Int) +} diff --git a/test/files/pos/package-case.flags b/test/files/pos/package-case.flags new file mode 100644 index 0000000000..2f174c4732 --- /dev/null +++ b/test/files/pos/package-case.flags @@ -0,0 +1 @@ +-Ycompanions-in-pkg-objs diff --git a/test/files/pos/t2130-1.flags b/test/files/pos/t2130-1.flags new file mode 100644 index 0000000000..2f174c4732 --- /dev/null +++ b/test/files/pos/t2130-1.flags @@ -0,0 +1 @@ +-Ycompanions-in-pkg-objs diff --git a/test/files/pos/t2130-2.flags b/test/files/pos/t2130-2.flags new file mode 100644 index 0000000000..2f174c4732 --- /dev/null +++ b/test/files/pos/t2130-2.flags @@ -0,0 +1 @@ +-Ycompanions-in-pkg-objs diff --git a/test/files/pos/t3999b.flags b/test/files/pos/t3999b.flags new file mode 100644 index 0000000000..2f174c4732 --- /dev/null +++ b/test/files/pos/t3999b.flags @@ -0,0 +1 @@ +-Ycompanions-in-pkg-objs diff --git a/test/files/pos/t4052.flags b/test/files/pos/t4052.flags new file mode 100644 index 0000000000..2f174c4732 --- /dev/null +++ b/test/files/pos/t4052.flags @@ -0,0 +1 @@ +-Ycompanions-in-pkg-objs |