From 4505c2b05c622e5438dddb9a3a9b3296819baaa0 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 28 Oct 2011 02:43:59 +0000 Subject: Better report on missing methods. Discovered an overloaded method with multiple unimplemented variants only had one listed. Fixed, no review. --- .../scala/tools/nsc/typechecker/RefChecks.scala | 7 ++-- test/files/neg/abstract-report2.check | 12 ++++--- test/files/neg/abstract-report3.check | 39 ++++++++++++++++++++++ test/files/neg/abstract-report3.scala | 1 + 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 test/files/neg/abstract-report3.check create mode 100644 test/files/neg/abstract-report3.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index a5053eb559..c3c353385c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -523,9 +523,10 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R // Group missing members by the name of the underlying symbol, // to consolidate getters and setters. val grouped = missing groupBy (sym => analyzer.underlyingSymbol(sym).name) - val missingMethods = grouped.toList map { - case (name, sym :: Nil) => sym - case (name, syms) => syms.sortBy(!_.isGetter).head + val missingMethods = grouped.toList flatMap { + case (name, syms) => + if (syms exists (_.isSetter)) syms filterNot (_.isGetter) + else syms } def stubImplementations: List[String] = { diff --git a/test/files/neg/abstract-report2.check b/test/files/neg/abstract-report2.check index 32d52e00f2..35a99bdd25 100644 --- a/test/files/neg/abstract-report2.check +++ b/test/files/neg/abstract-report2.check @@ -1,5 +1,5 @@ abstract-report2.scala:3: error: class Foo needs to be abstract, since: -it has 12 unimplemented members. +it has 13 unimplemented members. /** As seen from class Foo, the missing signatures are as follows. * For convenience, these are usable as stub implementations. */ @@ -15,11 +15,12 @@ it has 12 unimplemented members. def retainAll(x$1: java.util.Collection[_]): Boolean = ??? def size(): Int = ??? def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ??? + def toArray(): Array[Object] = ??? class Foo extends Collection[Int] ^ abstract-report2.scala:5: error: class Bar needs to be abstract, since: -it has 12 unimplemented members. +it has 13 unimplemented members. /** As seen from class Bar, the missing signatures are as follows. * For convenience, these are usable as stub implementations. */ @@ -35,11 +36,12 @@ it has 12 unimplemented members. def retainAll(x$1: java.util.Collection[_]): Boolean = ??? def size(): Int = ??? def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ??? + def toArray(): Array[Object] = ??? class Bar extends Collection[List[_ <: String]] ^ abstract-report2.scala:7: error: class Baz needs to be abstract, since: -it has 12 unimplemented members. +it has 13 unimplemented members. /** As seen from class Baz, the missing signatures are as follows. * For convenience, these are usable as stub implementations. */ @@ -55,11 +57,12 @@ it has 12 unimplemented members. def retainAll(x$1: java.util.Collection[_]): Boolean = ??? def size(): Int = ??? def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ??? + def toArray(): Array[Object] = ??? class Baz[T] extends Collection[T] ^ abstract-report2.scala:11: error: class Dingus needs to be abstract, since: -it has 23 unimplemented members. +it has 24 unimplemented members. /** As seen from class Dingus, the missing signatures are as follows. * For convenience, these are usable as stub implementations. */ @@ -74,6 +77,7 @@ it has 23 unimplemented members. 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] = ??? + def toArray(): Array[Object] = ??? // Members declared in scala.collection.GenTraversableOnce def isTraversableAgain: Boolean = ??? diff --git a/test/files/neg/abstract-report3.check b/test/files/neg/abstract-report3.check new file mode 100644 index 0000000000..ac3f4abd5a --- /dev/null +++ b/test/files/neg/abstract-report3.check @@ -0,0 +1,39 @@ +abstract-report3.scala:1: error: class Foo needs to be abstract, since: +it has 25 unimplemented members. +/** As seen from class Foo, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + // Members declared in java.util.concurrent.BlockingQueue + def add(x$1: T): Boolean = ??? + def contains(x$1: Any): Boolean = ??? + def drainTo(x$1: java.util.Collection[_ >: T],x$2: Int): Int = ??? + def drainTo(x$1: java.util.Collection[_ >: T]): Int = ??? + def offer(x$1: T,x$2: Long,x$3: java.util.concurrent.TimeUnit): Boolean = ??? + def offer(x$1: T): Boolean = ??? + def poll(x$1: Long,x$2: java.util.concurrent.TimeUnit): T = ??? + def put(x$1: T): Unit = ??? + def remainingCapacity(): Int = ??? + def remove(x$1: Any): Boolean = ??? + def take(): T = ??? + + // Members declared in java.util.Collection + def addAll(x$1: java.util.Collection[_ <: T]): Boolean = ??? + def clear(): Unit = ??? + def containsAll(x$1: java.util.Collection[_]): Boolean = ??? + def isEmpty(): Boolean = ??? + def iterator(): java.util.Iterator[T] = ??? + 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] = ??? + def toArray(): Array[Object] = ??? + + // Members declared in java.util.Queue + def element(): T = ??? + def peek(): T = ??? + def poll(): T = ??? + def remove(): T = ??? + +class Foo[T] extends java.util.concurrent.BlockingQueue[T] { } + ^ +one error found diff --git a/test/files/neg/abstract-report3.scala b/test/files/neg/abstract-report3.scala new file mode 100644 index 0000000000..d3cce86a6b --- /dev/null +++ b/test/files/neg/abstract-report3.scala @@ -0,0 +1 @@ +class Foo[T] extends java.util.concurrent.BlockingQueue[T] { } \ No newline at end of file -- cgit v1.2.3