diff options
-rw-r--r-- | src/dotty/tools/dotc/ast/CheckTrees.scala.disabled | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 13 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/ValueClasses.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Checking.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/RefChecks.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 2 |
6 files changed, 18 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/ast/CheckTrees.scala.disabled b/src/dotty/tools/dotc/ast/CheckTrees.scala.disabled index 254f002c1..255619f35 100644 --- a/src/dotty/tools/dotc/ast/CheckTrees.scala.disabled +++ b/src/dotty/tools/dotc/ast/CheckTrees.scala.disabled @@ -131,7 +131,7 @@ object CheckTrees { check(guard.tpe.derivesFrom(defn.BooleanClass)) case Return(expr, from) => check(expr.isValue); check(from.isTerm) - check(from.tpe.termSymbol.isSourceMethod) + check(from.tpe.termSymbol.isRealMethod) case Try(block, handler, finalizer) => check(block.isTerm) check(finalizer.isTerm) diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index b93585324..1ad718c29 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -478,9 +478,16 @@ object SymDenotations { } } - /** Is this a user defined "def" method? Excluded are accessors and anonymous functions. */ - final def isSourceMethod(implicit ctx: Context) = - this.is(Method, butNot = AccessorOrLabel) && !isAnonymousFunction + /** Is this a "real" method? A real method is a method which is: + * - not an accessor + * - not a label + * - not an anonymous function + * - not a companion method + */ + final def isRealMethod(implicit ctx: Context) = + this.is(Method, butNot = AccessorOrLabel) && + !isAnonymousFunction && + !isCompanionMethod /** Is this a setter? */ final def isGetter(implicit ctx: Context) = diff --git a/src/dotty/tools/dotc/transform/ValueClasses.scala b/src/dotty/tools/dotc/transform/ValueClasses.scala index f17a0e757..30802f426 100644 --- a/src/dotty/tools/dotc/transform/ValueClasses.scala +++ b/src/dotty/tools/dotc/transform/ValueClasses.scala @@ -20,12 +20,11 @@ object ValueClasses { } def isMethodWithExtension(d: SymDenotation)(implicit ctx: Context) = - d.isSourceMethod && + d.isRealMethod && isDerivedValueClass(d.owner) && !d.isConstructor && !d.is(SuperAccessor) && - !d.is(Macro) && - !d.isCompanionMethod + !d.is(Macro) /** The member that of a derived value class that unboxes it. */ def valueClassUnbox(d: ClassDenotation)(implicit ctx: Context): Symbol = diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala index 148e31885..ffb74839d 100644 --- a/src/dotty/tools/dotc/typer/Checking.scala +++ b/src/dotty/tools/dotc/typer/Checking.scala @@ -312,7 +312,7 @@ trait Checking { def doubleDefError(decl: Symbol, other: Symbol): Unit = { def ofType = if (decl.isType) "" else d": ${other.info}" def explanation = - if (!decl.isSourceMethod) "" + if (!decl.isRealMethod) "" else "\n (both definitions have the same erased type signature)" ctx.error(d"$decl is already defined as $other$ofType$explanation", decl.pos) } diff --git a/src/dotty/tools/dotc/typer/RefChecks.scala b/src/dotty/tools/dotc/typer/RefChecks.scala index eeed83bb5..97d005112 100644 --- a/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/src/dotty/tools/dotc/typer/RefChecks.scala @@ -297,9 +297,9 @@ object RefChecks { "(this rule is designed to prevent ``accidental overrides'')") } else if (other.isStable && !member.isStable) { // (1.4) overrideError("needs to be a stable, immutable value") - } else if (member.is(Lazy) && !other.isSourceMethod && !other.is(Deferred | Lazy)) { + } else if (member.is(Lazy) && !other.isRealMethod && !other.is(Deferred | Lazy)) { overrideError("cannot override a concrete non-lazy value") - } else if (other.is(Lazy, butNot = Deferred) && !other.isSourceMethod && !member.is(Lazy)) { + } else if (other.is(Lazy, butNot = Deferred) && !other.isRealMethod && !member.is(Lazy)) { overrideError("must be declared lazy to override a concrete lazy value") } else if (other.is(Deferred) && member.is(Macro) && member.extendedOverriddenSymbols.forall(_.is(Deferred))) { // (1.9) overrideError("cannot be used here - term macros cannot override abstract methods") @@ -1132,7 +1132,7 @@ class RefChecks extends MiniPhase { thisTransformer => } val doTransform = - sym.isSourceMethod && + sym.isRealMethod && sym.isCase && sym.name == nme.apply && isClassTypeAccessible(tree) diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 191a13ad0..566e8289a 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -708,7 +708,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit ctx.error("return outside method definition", tree.pos) (EmptyTree, WildcardType) } - else if (owner != cx.outer.owner && owner.isSourceMethod) { + else if (owner != cx.outer.owner && owner.isRealMethod) { if (owner.isCompleted) { val from = Ident(TermRef(NoPrefix, owner.asTerm)) val proto = returnProto(owner, cx.scope) |