aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-07-21 18:50:15 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-03 17:28:33 +0200
commit3065790f8536f8a6c088d6c6115f71ce45ca5ae0 (patch)
tree17c65e88bfa367d8f895bfb55a53ddb07eb575e7 /src/dotty/tools/dotc
parent9d90361eeb76f3b090a96033e20ed1a272c3493c (diff)
downloaddotty-3065790f8536f8a6c088d6c6115f71ce45ca5ae0.tar.gz
dotty-3065790f8536f8a6c088d6c6115f71ce45ca5ae0.tar.bz2
dotty-3065790f8536f8a6c088d6c6115f71ce45ca5ae0.zip
Added utility method: underlyingSymbol
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala7
-rw-r--r--src/dotty/tools/dotc/transform/SuperAccessors.scala2
-rw-r--r--src/dotty/tools/dotc/typer/ErrorReporting.scala9
3 files changed, 16 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 00c3d7666..61c700760 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -598,6 +598,13 @@ object SymDenotations {
field orElse getter
}
+ /** The field accessed by a getter or setter, or
+ * if it does not exists, the getter of a setter, or
+ * if that does not exist the symbol itself.
+ */
+ def underlyingSymbol(implicit ctx: Context): Symbol =
+ if (is(Accessor)) accessedFieldOrGetter orElse symbol else symbol
+
/** The chain of owners of this denotation, starting with the denoting symbol itself */
final def ownersIterator(implicit ctx: Context) = new Iterator[Symbol] {
private[this] var current = symbol
diff --git a/src/dotty/tools/dotc/transform/SuperAccessors.scala b/src/dotty/tools/dotc/transform/SuperAccessors.scala
index cd9de03ec..5720c3bd9 100644
--- a/src/dotty/tools/dotc/transform/SuperAccessors.scala
+++ b/src/dotty/tools/dotc/transform/SuperAccessors.scala
@@ -356,7 +356,7 @@ class SuperAccessors extends MacroTransform with IdentityDenotTransformer { this
case Super(_, mix) =>
if ((sym.isTerm) && !(sym is Method) || (sym is Accessor)) {
- ctx.error(s"super may be not be used on ${sym.accessedFieldOrGetter orElse sym}", tree.pos)
+ ctx.error(s"super may be not be used on ${sym.underlyingSymbol}", tree.pos)
} else if (isDisallowed(sym)) {
ctx.error(s"super not allowed here: use this.${name.decode} instead", tree.pos)
}
diff --git a/src/dotty/tools/dotc/typer/ErrorReporting.scala b/src/dotty/tools/dotc/typer/ErrorReporting.scala
index 89e73013f..f20d25792 100644
--- a/src/dotty/tools/dotc/typer/ErrorReporting.scala
+++ b/src/dotty/tools/dotc/typer/ErrorReporting.scala
@@ -6,7 +6,7 @@ import ast._
import core._
import Trees._
import Types._, ProtoTypes._, Contexts._, Decorators._, Denotations._, Symbols._
-import Applications._, Implicits._
+import Applications._, Implicits._, Flags._
import util.Positions._
import printing.Showable
import printing.Disambiguation.disambiguated
@@ -48,6 +48,13 @@ object ErrorReporting {
class Errors(implicit ctx: Context) {
+ /** An explanatory note to be added to error messages
+ * when there's a problem with abstract var defs */
+ def abstractVarMessage(sym: Symbol): String =
+ if (sym.underlyingSymbol.is(Mutable))
+ "\n(Note that variables need to be initialized to be defined)"
+ else ""
+
def expectedTypeStr(tp: Type): String = tp match {
case tp: FunProto =>
val result = tp.resultType match {