Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/ast/CheckTrees.scala.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down
5 changes: 2 additions & 3 deletions src/dotty/tools/dotc/transform/ValueClasses.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -1132,7 +1132,7 @@ class RefChecks extends MiniPhase { thisTransformer =>
}

val doTransform =
sym.isSourceMethod &&
sym.isRealMethod &&
sym.isCase &&
sym.name == nme.apply &&
isClassTypeAccessible(tree)
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down