diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/spec-overrides.check | 7 | ||||
-rw-r--r-- | test/files/neg/spec-overrides.scala | 26 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/files/neg/spec-overrides.check b/test/files/neg/spec-overrides.check new file mode 100644 index 0000000000..639186af40 --- /dev/null +++ b/test/files/neg/spec-overrides.check @@ -0,0 +1,7 @@ +spec-overrides.scala:8: error: Type parameter has to be specialized at least for the same types as in the overridden method. Missing types: Int + override def a[@specialized(Double) T](t: T): List[T] = Nil + ^ +spec-overrides.scala:12: error: Type parameter has to be specialized at least for the same types as in the overridden method. Missing types: Int + override def a[T](t: T): List[T] = Nil + ^ +two errors found diff --git a/test/files/neg/spec-overrides.scala b/test/files/neg/spec-overrides.scala new file mode 100644 index 0000000000..8c92b8ee25 --- /dev/null +++ b/test/files/neg/spec-overrides.scala @@ -0,0 +1,26 @@ +class P { + def a[@specialized(Int) T](t: T): List[T] = List(t) +} +class FX extends P { + override def a[@specialized(Int) T](t: T): List[T] = Nil +} +class FX1 extends P { + override def a[@specialized(Double) T](t: T): List[T] = Nil +} + +class FX2 extends P { + override def a[T](t: T): List[T] = Nil +} + +object Test extends Application { + val fx = new FX + val p = new P + + println(fx.a(3)) + println((fx: P).a(3)) + println((fx: P).a(3.0)) + + + // val d = new Derived[Int] + // println((d: Base[Int]).m(10)) +} |