diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/hkgadt.check | 31 | ||||
-rw-r--r-- | test/files/neg/hkgadt.scala | 35 | ||||
-rw-r--r-- | test/files/neg/t9361.check | 11 | ||||
-rw-r--r-- | test/files/neg/t9361.scala | 5 | ||||
-rw-r--r-- | test/files/neg/t9781.check | 4 | ||||
-rw-r--r-- | test/files/neg/t9781.scala | 4 |
6 files changed, 90 insertions, 0 deletions
diff --git a/test/files/neg/hkgadt.check b/test/files/neg/hkgadt.check new file mode 100644 index 0000000000..ef302a9abf --- /dev/null +++ b/test/files/neg/hkgadt.check @@ -0,0 +1,31 @@ +hkgadt.scala:7: error: type mismatch; + found : scala.collection.immutable.Set[Int] + required: F[Int] + case Bar() => Set(1) + ^ +hkgadt.scala:13: error: type mismatch; + found : Boolean(true) + required: A + case Bar1() => true + ^ +hkgadt.scala:24: error: type mismatch; + found : scala.collection.immutable.Set[Int] + required: F[Int] + case Bar() => Set(1) + ^ +hkgadt.scala:25: error: type mismatch; + found : List[Int] + required: F[Int] + case Baz() => List(1) + ^ +hkgadt.scala:32: error: type mismatch; + found : Boolean(true) + required: A + case Bar1() => true + ^ +hkgadt.scala:33: error: type mismatch; + found : Int(1) + required: A + case Baz1() => 1 + ^ +6 errors found diff --git a/test/files/neg/hkgadt.scala b/test/files/neg/hkgadt.scala new file mode 100644 index 0000000000..0107d2bdde --- /dev/null +++ b/test/files/neg/hkgadt.scala @@ -0,0 +1,35 @@ +object HKGADT { + sealed trait Foo[F[_]] + final case class Bar() extends Foo[List] + + def frob[F[_]](foo: Foo[F]): F[Int] = + foo match { + case Bar() => Set(1) + } + + sealed trait Foo1[F] + final case class Bar1() extends Foo1[Int] + def frob1[A](foo: Foo1[A]): A = foo match { + case Bar1() => true + } +} + +object HKGADT2 { + sealed trait Foo[F[_]] + final case class Bar() extends Foo[List] + final case class Baz() extends Foo[Set] + + def frob[F[_]](foo: Foo[F]): F[Int] = + foo match { + case Bar() => Set(1) + case Baz() => List(1) + } + + sealed trait Foo1[F] + final case class Bar1() extends Foo1[Int] + final case class Baz1() extends Foo1[Boolean] + def frob1[A](foo: Foo1[A]): A = foo match { + case Bar1() => true + case Baz1() => 1 + } +} diff --git a/test/files/neg/t9361.check b/test/files/neg/t9361.check new file mode 100644 index 0000000000..847d137f7d --- /dev/null +++ b/test/files/neg/t9361.check @@ -0,0 +1,11 @@ +t9361.scala:4: error: type mismatch; + found : Tc[_$2] where type _$2 + required: Nothing[] + new Foo { def tc = null.asInstanceOf[Tc[_]] } + ^ +t9361.scala:4: error: type mismatch; + found : Foo[Nothing] + required: Foo[Tc]{type T = Nothing} + new Foo { def tc = null.asInstanceOf[Tc[_]] } + ^ +two errors found diff --git a/test/files/neg/t9361.scala b/test/files/neg/t9361.scala new file mode 100644 index 0000000000..b689461e4d --- /dev/null +++ b/test/files/neg/t9361.scala @@ -0,0 +1,5 @@ +abstract class Foo[Tc[_]] { def tc: Tc[_] } +object Foo { + def foo[Tc[_]](): Foo[Tc] { type T = Nothing } = + new Foo { def tc = null.asInstanceOf[Tc[_]] } +} diff --git a/test/files/neg/t9781.check b/test/files/neg/t9781.check new file mode 100644 index 0000000000..422c51013a --- /dev/null +++ b/test/files/neg/t9781.check @@ -0,0 +1,4 @@ +t9781.scala:3: error: not found: value undefinedSymbol + c(undefinedSymbol) += 1 + ^ +one error found diff --git a/test/files/neg/t9781.scala b/test/files/neg/t9781.scala new file mode 100644 index 0000000000..70234dcca5 --- /dev/null +++ b/test/files/neg/t9781.scala @@ -0,0 +1,4 @@ +object T9781 { + val c: collection.mutable.Map[Int, Int] = ??? + c(undefinedSymbol) += 1 +} |