diff options
author | Paul Phillips <paulp@improving.org> | 2011-08-16 16:53:16 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-08-16 16:53:16 +0000 |
commit | d8359a20a088a4724431ce9c7dd93869c2ad23cb (patch) | |
tree | daecc28fd7443c37bfe13cffd1d77dd96b409756 /src | |
parent | 20859263f2a2cf85464b333b9842bb31c020ee5e (diff) | |
download | scala-d8359a20a088a4724431ce9c7dd93869c2ad23cb.tar.gz scala-d8359a20a088a4724431ce9c7dd93869c2ad23cb.tar.bz2 scala-d8359a20a088a4724431ce9c7dd93869c2ad23cb.zip |
Improved the error message given when a concret...
Improved the error message given when a concrete method implementation
doesn't match the abstract one. No review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 9f957af136..10918ecffa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -533,19 +533,30 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R mismatches match { // Only one mismatched parameter: say something useful. case (pa, pc) :: Nil => - val addendum = - if (pa.typeSymbol == pc.typeSymbol) { + val abstractSym = pa.typeSymbol + val concreteSym = pc.typeSymbol + def subclassMsg(c1: Symbol, c2: Symbol) = ( + ": %s is a subclass of %s, but method parameter types must match exactly.".format( + c1.fullLocationString, c2.fullLocationString) + ) + val addendum = ( + if (abstractSym == concreteSym) { // TODO: what is the optimal way to test for a raw type at this point? // Compilation has already failed so we shouldn't have to worry overmuch // about forcing types. - if (underlying.isJavaDefined && pa.typeArgs.isEmpty && pa.typeSymbol.typeParams.nonEmpty) + if (underlying.isJavaDefined && pa.typeArgs.isEmpty && abstractSym.typeParams.nonEmpty) ". To implement a raw type, use %s[_]".format(pa) else if (pa.prefix =:= pc.prefix) ": their type parameters differ" else ": their prefixes (i.e. enclosing instances) differ" } + else if (abstractSym isSubClass concreteSym) + subclassMsg(abstractSym, concreteSym) + else if (concreteSym isSubClass abstractSym) + subclassMsg(concreteSym, abstractSym) else "" + ) undefined("\n(Note that %s does not match %s%s)".format(pa, pc, addendum)) case xs => |