diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/anyval-anyref-parent.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-abstract.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-abstract.scala | 12 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-class.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-class.scala | 11 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-nonmacro.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-nonmacro.scala | 9 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-object.check | 7 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-object.scala | 12 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-polymorphic.check | 10 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-polymorphic.scala | 13 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-trait.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-trait.scala | 12 | ||||
-rw-r--r-- | test/files/neg/t7859.check | 19 | ||||
-rw-r--r-- | test/files/neg/t7859/A_1.scala | 5 | ||||
-rw-r--r-- | test/files/neg/t7859/B_2.scala | 9 | ||||
-rw-r--r-- | test/files/neg/valueclasses.check | 43 | ||||
-rw-r--r-- | test/files/neg/valueclasses.scala | 13 |
18 files changed, 169 insertions, 26 deletions
diff --git a/test/files/neg/anyval-anyref-parent.check b/test/files/neg/anyval-anyref-parent.check index 8c2aa36583..8a00fb394d 100644 --- a/test/files/neg/anyval-anyref-parent.check +++ b/test/files/neg/anyval-anyref-parent.check @@ -4,9 +4,9 @@ trait Foo2 extends AnyVal // fail anyval-anyref-parent.scala:5: error: Any does not have a constructor class Bar1 extends Any // fail ^ -anyval-anyref-parent.scala:6: error: value class needs to have exactly one public val parameter +anyval-anyref-parent.scala:6: error: value class parameter must be a val and not be private[this] class Bar2(x: Int) extends AnyVal // fail - ^ + ^ anyval-anyref-parent.scala:10: error: illegal inheritance; superclass Any is not a subclass of the superclass Object of the mixin trait Immutable diff --git a/test/files/neg/macro-bundle-abstract.check b/test/files/neg/macro-bundle-abstract.check new file mode 100644 index 0000000000..4b07adcc95 --- /dev/null +++ b/test/files/neg/macro-bundle-abstract.check @@ -0,0 +1,4 @@ +macro-bundle-abstract.scala:5: error: class Bundle$Bundle needs to be abstract, since method deferred in trait Bundle of type => Int is not defined +trait Bundle extends Macro { + ^ +one error found diff --git a/test/files/neg/macro-bundle-abstract.scala b/test/files/neg/macro-bundle-abstract.scala new file mode 100644 index 0000000000..2b302045da --- /dev/null +++ b/test/files/neg/macro-bundle-abstract.scala @@ -0,0 +1,12 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +trait Bundle extends Macro { + def deferred: Int + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-class.check b/test/files/neg/macro-bundle-class.check new file mode 100644 index 0000000000..92695390ab --- /dev/null +++ b/test/files/neg/macro-bundle-class.check @@ -0,0 +1,4 @@ +macro-bundle-class.scala:10: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-class.scala b/test/files/neg/macro-bundle-class.scala new file mode 100644 index 0000000000..4b92cdd40f --- /dev/null +++ b/test/files/neg/macro-bundle-class.scala @@ -0,0 +1,11 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +class Bundle(val c: Context) extends Macro { + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-nonmacro.check b/test/files/neg/macro-bundle-nonmacro.check new file mode 100644 index 0000000000..5a265b5724 --- /dev/null +++ b/test/files/neg/macro-bundle-nonmacro.check @@ -0,0 +1,4 @@ +macro-bundle-nonmacro.scala:8: error: not found: value Bundle + def foo = Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-nonmacro.scala b/test/files/neg/macro-bundle-nonmacro.scala new file mode 100644 index 0000000000..c7d99f4582 --- /dev/null +++ b/test/files/neg/macro-bundle-nonmacro.scala @@ -0,0 +1,9 @@ +import scala.language.experimental.macros + +trait Bundle { + def impl = ??? +} + +object Macros { + def foo = Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-object.check b/test/files/neg/macro-bundle-object.check new file mode 100644 index 0000000000..e122001427 --- /dev/null +++ b/test/files/neg/macro-bundle-object.check @@ -0,0 +1,7 @@ +macro-bundle-object.scala:11: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : : Nothing +number of parameter sections differ + def foo = macro Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-object.scala b/test/files/neg/macro-bundle-object.scala new file mode 100644 index 0000000000..98c4238a62 --- /dev/null +++ b/test/files/neg/macro-bundle-object.scala @@ -0,0 +1,12 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +object Bundle extends Macro { + val c: Context = ??? + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-polymorphic.check b/test/files/neg/macro-bundle-polymorphic.check new file mode 100644 index 0000000000..204bd30bca --- /dev/null +++ b/test/files/neg/macro-bundle-polymorphic.check @@ -0,0 +1,10 @@ +macro-bundle-polymorphic.scala:10: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle.impl + ^ +macro-bundle-polymorphic.scala:11: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle[Int].impl + ^ +macro-bundle-polymorphic.scala:12: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle[Int, Nothing].impl + ^ +three errors found diff --git a/test/files/neg/macro-bundle-polymorphic.scala b/test/files/neg/macro-bundle-polymorphic.scala new file mode 100644 index 0000000000..0468d841bd --- /dev/null +++ b/test/files/neg/macro-bundle-polymorphic.scala @@ -0,0 +1,13 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +trait Bundle[T] extends Macro { + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl + def foo = macro Bundle[Int].impl + def foo = macro Bundle[Int, Nothing].impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-trait.check b/test/files/neg/macro-bundle-trait.check new file mode 100644 index 0000000000..972788c577 --- /dev/null +++ b/test/files/neg/macro-bundle-trait.check @@ -0,0 +1,4 @@ +macro-bundle-trait.scala:11: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-trait.scala b/test/files/neg/macro-bundle-trait.scala new file mode 100644 index 0000000000..ddc87f6db3 --- /dev/null +++ b/test/files/neg/macro-bundle-trait.scala @@ -0,0 +1,12 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +trait Bundle extends Macro { + val c: Context = ??? + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/t7859.check b/test/files/neg/t7859.check new file mode 100644 index 0000000000..5789e2a122 --- /dev/null +++ b/test/files/neg/t7859.check @@ -0,0 +1,19 @@ +B_2.scala:6: error: not found: value x + new p1.A(x).x + ^ +B_2.scala:6: error: value x in class A cannot be accessed in p1.A + new p1.A(x).x + ^ +B_2.scala:7: error: not found: value x + new B(x).x + ^ +B_2.scala:7: error: value x is not a member of B + new B(x).x + ^ +B_2.scala:8: error: not found: value x + new C(x).x + ^ +B_2.scala:8: error: value x in class C cannot be accessed in C + new C(x).x + ^ +6 errors found diff --git a/test/files/neg/t7859/A_1.scala b/test/files/neg/t7859/A_1.scala new file mode 100644 index 0000000000..e5b32d1c96 --- /dev/null +++ b/test/files/neg/t7859/A_1.scala @@ -0,0 +1,5 @@ +package p1 { + class A(private[p1] val x: Any) extends AnyVal +} +class B(private val x: Any) extends AnyVal + diff --git a/test/files/neg/t7859/B_2.scala b/test/files/neg/t7859/B_2.scala new file mode 100644 index 0000000000..2e0556bc7b --- /dev/null +++ b/test/files/neg/t7859/B_2.scala @@ -0,0 +1,9 @@ +class C(private val x: Any) extends AnyVal + +// Checking that makeNotPrivate(paramAccessor) doesn't make this visible during typer. +// The output is identical with/without `extends AnyVal`. +object Test { + new p1.A(x).x + new B(x).x + new C(x).x +} diff --git a/test/files/neg/valueclasses.check b/test/files/neg/valueclasses.check index 3b82a8358c..35d38aae60 100644 --- a/test/files/neg/valueclasses.check +++ b/test/files/neg/valueclasses.check @@ -4,40 +4,43 @@ trait T extends AnyVal // fail valueclasses.scala:6: error: value class may not be a member of another class class Bar(x: Int) extends AnyVal // fail ^ +valueclasses.scala:6: error: value class parameter must be a val and not be private[this] + class Bar(x: Int) extends AnyVal // fail + ^ valueclasses.scala:8: error: value class may not be a local class class Baz(x: Int) extends AnyVal // fail ^ -valueclasses.scala:12: error: value class needs to have exactly one public val parameter +valueclasses.scala:8: error: value class parameter must be a val and not be private[this] + class Baz(x: Int) extends AnyVal // fail + ^ +valueclasses.scala:12: error: value class needs to have exactly one val parameter class V1 extends AnyVal // fail ^ -valueclasses.scala:14: error: value class needs to have a publicly accessible val parameter -class V2(private[test] val x: Int) extends AnyVal // fail - ^ -valueclasses.scala:15: error: value class needs to have a publicly accessible val parameter -class V3(protected[test] val x: Int) extends AnyVal // fail - ^ -valueclasses.scala:16: error: value class needs to have a publicly accessible val parameter -class V4(protected val x: Int) extends AnyVal // fail - ^ -valueclasses.scala:17: error: value class needs to have a publicly accessible val parameter -class V5(private val x: Int) extends AnyVal // fail - ^ -valueclasses.scala:19: error: value class needs to have exactly one public val parameter +valueclasses.scala:19: error: value class needs to have exactly one val parameter class V6(val x: Int, val y: String) extends AnyVal // fail ^ -valueclasses.scala:20: error: field definition is not allowed in value class +valueclasses.scala:20: error: value class needs to have exactly one val parameter class V7(val x: Int, private[this] val y: String) extends AnyVal // fail - ^ -valueclasses.scala:21: error: value class needs to have exactly one public val parameter -class V8(var x: Int) extends AnyVal // fail ^ +valueclasses.scala:21: error: value class parameter must not be a var +class V8(var x: Int) extends AnyVal // fail + ^ valueclasses.scala:24: error: field definition is not allowed in value class val y = x // fail ^ valueclasses.scala:29: error: type parameter of value class may not be specialized class V12[@specialized T, U](val x: (T, U)) extends AnyVal // fail ^ -valueclasses.scala:31: error: value class needs to have exactly one public val parameter +valueclasses.scala:31: error: value class parameter must be a val and not be private[this] class V13(x: Int) extends AnyVal // fail + ^ +valueclasses.scala:33: error: value class parameter must be a val and not be private[this] +class V14(private[this] val x: Int) extends AnyVal // fail + ^ +valueclasses.scala:34: error: value class parameter must not be protected[this] +class V15(protected[this] val x: Int) extends AnyVal // fail + ^ +valueclasses.scala:36: error: value class needs to have exactly one val parameter +class V16()(val a: Any) extends AnyVal // fail, was allowed 2.10.x ^ -14 errors found +15 errors found diff --git a/test/files/neg/valueclasses.scala b/test/files/neg/valueclasses.scala index 7cac94ab11..06fde40a70 100644 --- a/test/files/neg/valueclasses.scala +++ b/test/files/neg/valueclasses.scala @@ -11,10 +11,10 @@ class Foo { class V1 extends AnyVal // fail -class V2(private[test] val x: Int) extends AnyVal // fail -class V3(protected[test] val x: Int) extends AnyVal // fail -class V4(protected val x: Int) extends AnyVal // fail -class V5(private val x: Int) extends AnyVal // fail +class V2(private[test] val x: Int) extends AnyVal // okay, wasn't allowed in 2.10.x +class V3(protected[test] val x: Int) extends AnyVal // okay, wasn't allowed in 2.10.x +class V4(protected val x: Int) extends AnyVal // okay, wasn't allowed in 2.10.x +class V5(private val x: Int) extends AnyVal // okay, wasn't allowed in 2.10.x class V6(val x: Int, val y: String) extends AnyVal // fail class V7(val x: Int, private[this] val y: String) extends AnyVal // fail @@ -29,3 +29,8 @@ class V11[T](val x: List[T]) extends AnyVal // ok class V12[@specialized T, U](val x: (T, U)) extends AnyVal // fail class V13(x: Int) extends AnyVal // fail + +class V14(private[this] val x: Int) extends AnyVal // fail +class V15(protected[this] val x: Int) extends AnyVal // fail + +class V16()(val a: Any) extends AnyVal // fail, was allowed 2.10.x |