From a56bc34fb850a6dca40c4f8562f3cb2d5b69dcc7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 13 Mar 2015 17:44:04 +0100 Subject: add/strict Add -strict option to do some type checks that are encessary to ensure type soundness, but are stricter than what Scala 2.x enforces. The first such test is the "pattern cannot be uniquely instantiated" problem where we reject a non-variant case subclass of a covariant superclass in a pattern match. The error is now only issued in -struct mode, otherwise it will be a warning. We might move more tests into the same category. This should help the transition. --- tests/pending/pos/variances-local.scala | 7 ------ tests/pending/pos/viewtest1.scala | 42 --------------------------------- 2 files changed, 49 deletions(-) delete mode 100644 tests/pending/pos/variances-local.scala delete mode 100644 tests/pending/pos/viewtest1.scala (limited to 'tests/pending/pos') diff --git a/tests/pending/pos/variances-local.scala b/tests/pending/pos/variances-local.scala deleted file mode 100644 index 35e395095..000000000 --- a/tests/pending/pos/variances-local.scala +++ /dev/null @@ -1,7 +0,0 @@ -class Foo1[+T] { - private[this] type MyType = T -} - -class Foo2[+T] { - protected[this] type MyType = T -} diff --git a/tests/pending/pos/viewtest1.scala b/tests/pending/pos/viewtest1.scala deleted file mode 100644 index 38945ad2f..000000000 --- a/tests/pending/pos/viewtest1.scala +++ /dev/null @@ -1,42 +0,0 @@ -package test - -trait Ordered[a] { - def < (x: a): Boolean -} - -object O { - implicit def view (x: String): Ordered[String] = new Ordered[String] { - def < (y: String) = x.compareTo(y) < 0 - } -} - -object Empty extends Tree[Nothing] -case class Node[c <% Ordered[c]](elem: c, l: Tree[c], r: Tree[c]) extends Tree[c] - -abstract class Tree[+a <% Ordered[a]] { - def insert[b >: a <% Ordered[b]](x: b): Tree[b] = this match { - case Empty => - new Node(x, Empty, Empty) - case Node(elem, l, r) => - if (x == elem) this - else if (x < elem) Node(elem, l insert x, r) - else Node(elem, l, r insert x) - } - def elements: List[a] = this match { - case Empty => List() - case Node(elem, l, r) => - l.elements ::: List(elem) ::: r.elements - } -} - -object Test { - import O.view - - def main(args: Array[String]): Unit = { - var t: Tree[String] = Empty - for (s <- args) { - t = t insert s - } - println(t.elements) - } -} -- cgit v1.2.3