diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/customArgs/overloadsOnAbstractTypes.scala | 22 | ||||
-rw-r--r-- | tests/pos/i2152.scala | 7 | ||||
-rw-r--r-- | tests/run/1938-2.scala | 37 |
3 files changed, 66 insertions, 0 deletions
diff --git a/tests/neg/customArgs/overloadsOnAbstractTypes.scala b/tests/neg/customArgs/overloadsOnAbstractTypes.scala new file mode 100644 index 000000000..0c9ed12bb --- /dev/null +++ b/tests/neg/customArgs/overloadsOnAbstractTypes.scala @@ -0,0 +1,22 @@ + +class Test1 { + type A + type B <: A + + def foo(): A = ??? + def foo(): A = ??? // error + + def bar(): A = ??? + def bar(): B = ??? // error +} + +class Test2 { + type A + type B <: A + + def foo(x: A) = ??? + def foo(x: A) = ??? // error + + def bar(x: A) = ??? + def bar(x: B) = ??? // error +} diff --git a/tests/pos/i2152.scala b/tests/pos/i2152.scala new file mode 100644 index 000000000..2171a487e --- /dev/null +++ b/tests/pos/i2152.scala @@ -0,0 +1,7 @@ +class Contra[-D](task: AnyRef) +object Test { + def narrow(task: AnyRef): Contra[task.type] = new Contra(task) + def ident[Before](elems: Contra[Before]): Contra[Before] = elems + val foo = null + ident(narrow(foo)) +} diff --git a/tests/run/1938-2.scala b/tests/run/1938-2.scala new file mode 100644 index 000000000..32e4c4518 --- /dev/null +++ b/tests/run/1938-2.scala @@ -0,0 +1,37 @@ +object ProdNonEmpty { + def _1: Int = 0 + def _2: String = "???" // Slight variation with scalac: this test passes + // with ??? here. I think dotty behavior is fine + // according to the spec given that methods involved + // in pattern matching should be pure. + def isEmpty = false + def unapply(s: String): this.type = this + def get = this +} + +object ProdEmpty { + def _1: Int = ??? + def _2: String = ??? + def isEmpty = true + def unapply(s: String): this.type = this + def get = this +} + +object Test { + def main(args: Array[String]): Unit = { + "" match { + case ProdNonEmpty(0, _) => () + case _ => ??? + } + + "" match { + case ProdNonEmpty(1, _) => ??? + case _ => () + } + + "" match { + case ProdEmpty(_, _) => ??? + case _ => () + } + } +} |