diff options
author | Paul Phillips <paulp@improving.org> | 2011-10-14 02:16:17 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-10-14 02:16:17 +0000 |
commit | fcd0998f1e0f2307e9b0cbae6bf2c36234ca8d17 (patch) | |
tree | 3eb2fa53283a9f399cd3e11a15a391b9d0307ca3 /test/files/neg | |
parent | bca8959a1ab162dadec51c0db7d062315f5e4d6e (diff) | |
download | scala-fcd0998f1e0f2307e9b0cbae6bf2c36234ca8d17.tar.gz scala-fcd0998f1e0f2307e9b0cbae6bf2c36234ca8d17.tar.bz2 scala-fcd0998f1e0f2307e9b0cbae6bf2c36234ca8d17.zip |
Better error when abstract methods are missing.
When many methods are missing, print a list of signatures the way they
need to be implemented, and throw in ??? stub implementations so it
should be compilable code. If anyone would like this logic exposed more
generally (for the IDE or whatever) just let me know. No review.
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/abstract-report.check | 24 | ||||
-rw-r--r-- | test/files/neg/abstract-report.scala | 1 | ||||
-rw-r--r-- | test/files/neg/abstract-report2.check | 99 | ||||
-rw-r--r-- | test/files/neg/abstract-report2.scala | 11 | ||||
-rw-r--r-- | test/files/neg/t2208.check | 2 | ||||
-rw-r--r-- | test/files/neg/t2213.check | 26 | ||||
-rw-r--r-- | test/files/neg/t856.check | 12 | ||||
-rw-r--r-- | test/files/neg/tcpoly_ticket2101.check | 2 |
8 files changed, 165 insertions, 12 deletions
diff --git a/test/files/neg/abstract-report.check b/test/files/neg/abstract-report.check new file mode 100644 index 0000000000..bd550f39f4 --- /dev/null +++ b/test/files/neg/abstract-report.check @@ -0,0 +1,24 @@ +abstract-report.scala:1: error: class Unimplemented needs to be abstract, since: +it has 12 unimplemented members. +/** As seen from class Unimplemented, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + // Members declared in scala.collection.GenTraversableOnce + def isTraversableAgain: Boolean = ??? + def toIterator: Iterator[String] = ??? + def toStream: Stream[String] = ??? + + // Members declared in scala.collection.TraversableOnce + def copyToArray[B >: String](xs: Array[B],start: Int,len: Int): Unit = ??? + def exists(p: String => Boolean): Boolean = ??? + def find(p: String => Boolean): Option[String] = ??? + def forall(p: String => Boolean): Boolean = ??? + def foreach[U](f: String => U): Unit = ??? + def hasDefiniteSize: Boolean = ??? + def isEmpty: Boolean = ??? + def seq: scala.collection.TraversableOnce[String] = ??? + def toTraversable: Traversable[String] = ??? + +class Unimplemented extends TraversableOnce[String] { } + ^ +one error found diff --git a/test/files/neg/abstract-report.scala b/test/files/neg/abstract-report.scala new file mode 100644 index 0000000000..538e093547 --- /dev/null +++ b/test/files/neg/abstract-report.scala @@ -0,0 +1 @@ +class Unimplemented extends TraversableOnce[String] { }
\ No newline at end of file diff --git a/test/files/neg/abstract-report2.check b/test/files/neg/abstract-report2.check new file mode 100644 index 0000000000..32d52e00f2 --- /dev/null +++ b/test/files/neg/abstract-report2.check @@ -0,0 +1,99 @@ +abstract-report2.scala:3: error: class Foo needs to be abstract, since: +it has 12 unimplemented members. +/** As seen from class Foo, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + def add(x$1: Int): Boolean = ??? + def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ??? + def clear(): Unit = ??? + def contains(x$1: Any): Boolean = ??? + def containsAll(x$1: java.util.Collection[_]): Boolean = ??? + def isEmpty(): Boolean = ??? + def iterator(): java.util.Iterator[Int] = ??? + def remove(x$1: Any): Boolean = ??? + def removeAll(x$1: java.util.Collection[_]): Boolean = ??? + def retainAll(x$1: java.util.Collection[_]): Boolean = ??? + def size(): Int = ??? + def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ??? + +class Foo extends Collection[Int] + ^ +abstract-report2.scala:5: error: class Bar needs to be abstract, since: +it has 12 unimplemented members. +/** As seen from class Bar, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + def add(x$1: List[_ <: String]): Boolean = ??? + def addAll(x$1: java.util.Collection[_ <: List[_ <: String]]): Boolean = ??? + def clear(): Unit = ??? + def contains(x$1: Any): Boolean = ??? + def containsAll(x$1: java.util.Collection[_]): Boolean = ??? + def isEmpty(): Boolean = ??? + def iterator(): java.util.Iterator[List[_ <: String]] = ??? + def remove(x$1: Any): Boolean = ??? + def removeAll(x$1: java.util.Collection[_]): Boolean = ??? + def retainAll(x$1: java.util.Collection[_]): Boolean = ??? + def size(): Int = ??? + def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ??? + +class Bar extends Collection[List[_ <: String]] + ^ +abstract-report2.scala:7: error: class Baz needs to be abstract, since: +it has 12 unimplemented members. +/** As seen from class Baz, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + def add(x$1: T): Boolean = ??? + def addAll(x$1: java.util.Collection[_ <: T]): Boolean = ??? + def clear(): Unit = ??? + def contains(x$1: Any): Boolean = ??? + def containsAll(x$1: java.util.Collection[_]): Boolean = ??? + def isEmpty(): Boolean = ??? + def iterator(): java.util.Iterator[T] = ??? + def remove(x$1: Any): Boolean = ??? + def removeAll(x$1: java.util.Collection[_]): Boolean = ??? + def retainAll(x$1: java.util.Collection[_]): Boolean = ??? + def size(): Int = ??? + def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ??? + +class Baz[T] extends Collection[T] + ^ +abstract-report2.scala:11: error: class Dingus needs to be abstract, since: +it has 23 unimplemented members. +/** As seen from class Dingus, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + // Members declared in java.util.Collection + def add(x$1: String): Boolean = ??? + def addAll(x$1: java.util.Collection[_ <: String]): Boolean = ??? + def clear(): Unit = ??? + def contains(x$1: Any): Boolean = ??? + def containsAll(x$1: java.util.Collection[_]): Boolean = ??? + def iterator(): java.util.Iterator[String] = ??? + def remove(x$1: Any): Boolean = ??? + def removeAll(x$1: java.util.Collection[_]): Boolean = ??? + def retainAll(x$1: java.util.Collection[_]): Boolean = ??? + def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ??? + + // Members declared in scala.collection.GenTraversableOnce + def isTraversableAgain: Boolean = ??? + def toIterator: Iterator[(Set[Int], String)] = ??? + def toStream: Stream[(Set[Int], String)] = ??? + + // Members declared in scala.math.Ordering + def compare(x: List[Int],y: List[Int]): Int = ??? + + // Members declared in scala.collection.TraversableOnce + def copyToArray[B >: (Set[Int], String)](xs: Array[B],start: Int,len: Int): Unit = ??? + def exists(p: ((Set[Int], String)) => Boolean): Boolean = ??? + def find(p: ((Set[Int], String)) => Boolean): Option[(Set[Int], String)] = ??? + def forall(p: ((Set[Int], String)) => Boolean): Boolean = ??? + def foreach[U](f: ((Set[Int], String)) => U): Unit = ??? + def hasDefiniteSize: Boolean = ??? + def isEmpty: Boolean = ??? + def seq: scala.collection.TraversableOnce[(Set[Int], String)] = ??? + def toTraversable: Traversable[(Set[Int], String)] = ??? + +class Dingus extends Bippy[String, Set[Int], List[Int]] + ^ +four errors found diff --git a/test/files/neg/abstract-report2.scala b/test/files/neg/abstract-report2.scala new file mode 100644 index 0000000000..b6327b0766 --- /dev/null +++ b/test/files/neg/abstract-report2.scala @@ -0,0 +1,11 @@ +import java.util.Collection + +class Foo extends Collection[Int] + +class Bar extends Collection[List[_ <: String]] + +class Baz[T] extends Collection[T] + +trait Bippy[T1, T2, T3] extends Collection[T1] with TraversableOnce[(T2, String)] with Ordering[T3] + +class Dingus extends Bippy[String, Set[Int], List[Int]]
\ No newline at end of file diff --git a/test/files/neg/t2208.check b/test/files/neg/t2208.check index a97b20cba7..64bb3a77c8 100644 --- a/test/files/neg/t2208.check +++ b/test/files/neg/t2208.check @@ -1,4 +1,4 @@ t2208.scala:7: error: type arguments [Any] do not conform to type Alias's type parameter bounds [X <: Test.A] class C extends Alias[Any] // not ok, normalisation should check bounds before expanding Alias ^ -one error found
\ No newline at end of file +one error found diff --git a/test/files/neg/t2213.check b/test/files/neg/t2213.check index f59503ee2a..9fb3bb2eb7 100644 --- a/test/files/neg/t2213.check +++ b/test/files/neg/t2213.check @@ -1,15 +1,25 @@ t2213.scala:9: error: class C needs to be abstract, since: -value y in class A of type Int is not defined -value x in class A of type Int is not defined -method g in class A of type => Int is not defined -method f in class A of type => Int is not defined +it has 4 unimplemented members. +/** As seen from class C, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + def f: Int = ??? + def g: Int = ??? + val x: Int = ??? + val y: Int = ??? + class C extends A {} ^ t2213.scala:11: error: object creation impossible, since: -value y in class A of type Int is not defined -value x in class A of type Int is not defined -method g in class A of type => Int is not defined -method f in class A of type => Int is not defined +it has 4 unimplemented members. +/** As seen from object Q, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + def f: Int = ??? + def g: Int = ??? + val x: Int = ??? + val y: Int = ??? + object Q extends A { } ^ two errors found diff --git a/test/files/neg/t856.check b/test/files/neg/t856.check index d0bbde6c58..02978e1622 100644 --- a/test/files/neg/t856.check +++ b/test/files/neg/t856.check @@ -1,6 +1,14 @@ t856.scala:3: error: class ComplexRect needs to be abstract, since: -method _2 in trait Product2 of type => Double is not defined -method canEqual in trait Equals of type (that: Any)Boolean is not defined +it has 2 unimplemented members. +/** As seen from class ComplexRect, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + // Members declared in scala.Equals + def canEqual(that: Any): Boolean = ??? + + // Members declared in scala.Product2 + def _2: Double = ??? + class ComplexRect(val _1:Double, _2:Double) extends Complex { ^ one error found diff --git a/test/files/neg/tcpoly_ticket2101.check b/test/files/neg/tcpoly_ticket2101.check index eac582e8ba..ad0fd8bda2 100644 --- a/test/files/neg/tcpoly_ticket2101.check +++ b/test/files/neg/tcpoly_ticket2101.check @@ -1,4 +1,4 @@ tcpoly_ticket2101.scala:2: error: type arguments [T2,X] do not conform to class T's type parameter bounds [A[Y] <: T[A,B],B] class T2[X] extends T[T2, X] // ill-typed ^ -one error found
\ No newline at end of file +one error found |