summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-10-14 02:16:17 +0000
committerPaul Phillips <paulp@improving.org>2011-10-14 02:16:17 +0000
commitfcd0998f1e0f2307e9b0cbae6bf2c36234ca8d17 (patch)
tree3eb2fa53283a9f399cd3e11a15a391b9d0307ca3 /src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
parentbca8959a1ab162dadec51c0db7d062315f5e4d6e (diff)
downloadscala-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 'src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
index 6c735a2d44..42f8188ac1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
@@ -123,6 +123,14 @@ trait TypeDiagnostics {
else nameString + " is not a member of " + targetKindString + target + addendum
)
}
+
+ /** An explanatory note to be added to error messages
+ * when there's a problem with abstract var defs */
+ def abstractVarMessage(sym: Symbol): String =
+ if (underlyingSymbol(sym).isVariable)
+ "\n(Note that variables need to be initialized to be defined)"
+ else ""
+
def notAMemberError(pos: Position, qual: Tree, name: Name) =
context.error(pos, notAMemberMessage(pos, qual, name))
@@ -161,6 +169,24 @@ trait TypeDiagnostics {
"missing parameter type" + suffix
}
+ /** The symbol which the given accessor represents (possibly in part).
+ * This is used for error messages, where we want to speak in terms
+ * of the actual declaration or definition, not in terms of the generated setters
+ * and getters.
+ */
+ def underlyingSymbol(member: Symbol): Symbol =
+ if (!member.hasAccessorFlag) member
+ else if (!member.isDeferred) member.accessed
+ else {
+ val getter = if (member.isSetter) member.getter(member.owner) else member
+ val flags = if (getter.setter(member.owner) != NoSymbol) DEFERRED | MUTABLE else DEFERRED
+
+ ( getter.owner.newValue(getter.pos, getter.name.toTermName)
+ setInfo getter.tpe.resultType
+ setFlag flags
+ )
+ }
+
def treeSymTypeMsg(tree: Tree): String = {
val sym = tree.symbol
def hasParams = tree.tpe.paramSectionCount > 0