File tree Expand file tree Collapse file tree 6 files changed +18
-12
lines changed Expand file tree Collapse file tree 6 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ object CheckTrees {
131
131
check(guard.tpe.derivesFrom(defn.BooleanClass))
132
132
case Return(expr, from) =>
133
133
check(expr.isValue); check(from.isTerm)
134
- check(from.tpe.termSymbol.isSourceMethod )
134
+ check(from.tpe.termSymbol.isRealMethod )
135
135
case Try(block, handler, finalizer) =>
136
136
check(block.isTerm)
137
137
check(finalizer.isTerm)
Original file line number Diff line number Diff line change @@ -478,9 +478,16 @@ object SymDenotations {
478
478
}
479
479
}
480
480
481
- /** Is this a user defined "def" method? Excluded are accessors and anonymous functions. */
482
- final def isSourceMethod (implicit ctx : Context ) =
483
- this .is(Method , butNot = AccessorOrLabel ) && ! isAnonymousFunction
481
+ /** Is this a "real" method? A real method is a method which is:
482
+ * - not an accessor
483
+ * - not a label
484
+ * - not an anonymous function
485
+ * - not a companion method
486
+ */
487
+ final def isRealMethod (implicit ctx : Context ) =
488
+ this .is(Method , butNot = AccessorOrLabel ) &&
489
+ ! isAnonymousFunction &&
490
+ ! isCompanionMethod
484
491
485
492
/** Is this a setter? */
486
493
final def isGetter (implicit ctx : Context ) =
Original file line number Diff line number Diff line change @@ -20,12 +20,11 @@ object ValueClasses {
20
20
}
21
21
22
22
def isMethodWithExtension (d : SymDenotation )(implicit ctx : Context ) =
23
- d.isSourceMethod &&
23
+ d.isRealMethod &&
24
24
isDerivedValueClass(d.owner) &&
25
25
! d.isConstructor &&
26
26
! d.is(SuperAccessor ) &&
27
- ! d.is(Macro ) &&
28
- ! d.isCompanionMethod
27
+ ! d.is(Macro )
29
28
30
29
/** The member that of a derived value class that unboxes it. */
31
30
def valueClassUnbox (d : ClassDenotation )(implicit ctx : Context ): Symbol =
Original file line number Diff line number Diff line change @@ -312,7 +312,7 @@ trait Checking {
312
312
def doubleDefError (decl : Symbol , other : Symbol ): Unit = {
313
313
def ofType = if (decl.isType) " " else d " : ${other.info}"
314
314
def explanation =
315
- if (! decl.isSourceMethod ) " "
315
+ if (! decl.isRealMethod ) " "
316
316
else " \n (both definitions have the same erased type signature)"
317
317
ctx.error(d " $decl is already defined as $other$ofType$explanation" , decl.pos)
318
318
}
Original file line number Diff line number Diff line change @@ -297,9 +297,9 @@ object RefChecks {
297
297
" (this rule is designed to prevent ``accidental overrides'')" )
298
298
} else if (other.isStable && ! member.isStable) { // (1.4)
299
299
overrideError(" needs to be a stable, immutable value" )
300
- } else if (member.is(Lazy ) && ! other.isSourceMethod && ! other.is(Deferred | Lazy )) {
300
+ } else if (member.is(Lazy ) && ! other.isRealMethod && ! other.is(Deferred | Lazy )) {
301
301
overrideError(" cannot override a concrete non-lazy value" )
302
- } else if (other.is(Lazy , butNot = Deferred ) && ! other.isSourceMethod && ! member.is(Lazy )) {
302
+ } else if (other.is(Lazy , butNot = Deferred ) && ! other.isRealMethod && ! member.is(Lazy )) {
303
303
overrideError(" must be declared lazy to override a concrete lazy value" )
304
304
} else if (other.is(Deferred ) && member.is(Macro ) && member.extendedOverriddenSymbols.forall(_.is(Deferred ))) { // (1.9)
305
305
overrideError(" cannot be used here - term macros cannot override abstract methods" )
@@ -1132,7 +1132,7 @@ class RefChecks extends MiniPhase { thisTransformer =>
1132
1132
}
1133
1133
1134
1134
val doTransform =
1135
- sym.isSourceMethod &&
1135
+ sym.isRealMethod &&
1136
1136
sym.isCase &&
1137
1137
sym.name == nme.apply &&
1138
1138
isClassTypeAccessible(tree)
Original file line number Diff line number Diff line change @@ -708,7 +708,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
708
708
ctx.error(" return outside method definition" , tree.pos)
709
709
(EmptyTree , WildcardType )
710
710
}
711
- else if (owner != cx.outer.owner && owner.isSourceMethod ) {
711
+ else if (owner != cx.outer.owner && owner.isRealMethod ) {
712
712
if (owner.isCompleted) {
713
713
val from = Ident (TermRef (NoPrefix , owner.asTerm))
714
714
val proto = returnProto(owner, cx.scope)
You can’t perform that action at this time.
0 commit comments