From 302c0ea8c8e1db2fdf05165f701a244cf05f8411 Mon Sep 17 00:00:00 2001 From: Pascal Weisenburger Date: Sun, 27 Mar 2022 23:52:31 +0200 Subject: [PATCH] Add regression tests Closes lampepfl#3058 Closes lampepfl#10943 Closes lampepfl#12216 Closes lampepfl#12655 --- tests/neg/i10943.check | 7 +++++++ tests/neg/i10943.scala | 6 ++++++ tests/pos/i12216.scala | 24 ++++++++++++++++++++++++ tests/pos/i12655.scala | 12 ++++++++++++ tests/pos/i3058.scala | 14 ++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 tests/neg/i10943.check create mode 100644 tests/neg/i10943.scala create mode 100644 tests/pos/i12216.scala create mode 100644 tests/pos/i12655.scala create mode 100644 tests/pos/i3058.scala diff --git a/tests/neg/i10943.check b/tests/neg/i10943.check new file mode 100644 index 000000000000..93924afb3927 --- /dev/null +++ b/tests/neg/i10943.check @@ -0,0 +1,7 @@ +-- [E007] Type Mismatch Error: tests/neg/i10943.scala:5:10 ------------------------------------------------------------- +5 | val a = new A : Int // error + | ^^^^^ + | Found: T.A + | Required: Int + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i10943.scala b/tests/neg/i10943.scala new file mode 100644 index 000000000000..4a9697c31874 --- /dev/null +++ b/tests/neg/i10943.scala @@ -0,0 +1,6 @@ +import language.experimental.fewerBraces + +object T: + class A + val a = new A : Int // error +end T diff --git a/tests/pos/i12216.scala b/tests/pos/i12216.scala new file mode 100644 index 000000000000..8618f3cb5069 --- /dev/null +++ b/tests/pos/i12216.scala @@ -0,0 +1,24 @@ +import scala.language.implicitConversions + +sealed abstract class CtorType[P] + +object CtorType { + final class Props[P] extends CtorType[P] { + def whyHelloThere(props: P): Unit = () + } +} + +trait Comp[P, CT[p] <: CtorType[p]] { + val ctor: CT[P] +} +object Comp { + implicit def autoCtor[P, CT[p] <: CtorType[p]](c: Comp[P, CT]): CT[P] = c.ctor +} + +object Test { + val comp: Comp[Int, CtorType.Props] = ??? + + comp.whyHelloThere(3) + + Comp.autoCtor(comp).whyHelloThere(3) +} diff --git a/tests/pos/i12655.scala b/tests/pos/i12655.scala new file mode 100644 index 000000000000..4d9d90f3134d --- /dev/null +++ b/tests/pos/i12655.scala @@ -0,0 +1,12 @@ +trait Signature: + type Impl[A, U] + +type Operation[Z <: Signature, A, U] = (z: Z) => z.Impl[A, U] + +case class Perform0[Z <: Signature, A, U](op: Operation[Z, A, U]) + +case class Perform1[Z <: Signature, A, U](op: (z: Z) => z.Impl[A, U]) + +def perform0[Z <: Signature, A, U](op: Operation[Z, A, U]): Unit = ??? + +def perform1[Z <: Signature, A, U](op: (z: Z) => z.Impl[A, U]): Unit = ??? diff --git a/tests/pos/i3058.scala b/tests/pos/i3058.scala new file mode 100644 index 000000000000..88502a5d707b --- /dev/null +++ b/tests/pos/i3058.scala @@ -0,0 +1,14 @@ +trait C[T] { type U } + +object C { type Aux[X, Y] = C[X] { type U = Y } } + + +def a: C[Int] { type U = Int } = ??? + +def b[T](c: C[T]): C[T] { type U = c.U } = ??? + + +def t[T, U](c: C.Aux[T, U]) = ??? + + +object Test { t(b(a)) }