Skip to content

Commit dcdd51d

Browse files
committed
Fix RefCheck rules
1 parent 25c04af commit dcdd51d

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,14 @@ object RefChecks {
143143
* 1.8.1 M's type is a subtype of O's type, or
144144
* 1.8.2 M is of type []S, O is of type ()T and S <: T, or
145145
* 1.8.3 M is of type ()S, O is of type []T and S <: T, or
146-
* 1.9 M must not be an erased definition
147-
* 1.10. If M is a 2.x macro def, O cannot be deferred unless there's a concrete method overriding O.
148-
* 1.11. If M is not a macro def, O cannot be a macro def.
146+
* 1.9 If M is an erased definition, it must override at least one concrete member
149147
* 2. Check that only abstract classes have deferred members
150148
* 3. Check that concrete classes do not have deferred definitions
151149
* that are not implemented in a subclass.
152150
* 4. Check that every member with an `override` modifier
153151
* overrides some other member.
154152
* TODO check that classes are not overridden
155-
* TODO This still needs to be cleaned up; the current version is a staright port of what was there
153+
* TODO This still needs to be cleaned up; the current version is a straight port of what was there
156154
* before, but it looks too complicated and method bodies are far too large.
157155
*/
158156
private def checkAllOverrides(clazz: Symbol)(implicit ctx: Context): Unit = {
@@ -376,14 +374,8 @@ object RefChecks {
376374
overrideError("may not override a non-lazy value")
377375
} else if (other.is(Lazy) && !other.isRealMethod && !member.is(Lazy)) {
378376
overrideError("must be declared lazy to override a lazy value")
379-
} else if (member.is(Erased)) { // (1.9)
380-
overrideError("is an erased method, may not override anything")
381-
} else if (member.is(Macro, butNot = Scala2x)) { // (1.9)
382-
overrideError("is a macro, may not override anything")
383-
} else if (other.is(Deferred) && member.is(Scala2Macro) && member.extendedOverriddenSymbols.forall(_.is(Deferred))) { // (1.10)
384-
overrideError("cannot be used here - term macros cannot override abstract methods")
385-
} else if (other.is(Macro) && !member.is(Macro)) { // (1.11)
386-
overrideError("cannot be used here - only term macros can override term macros")
377+
} else if (member.is(Erased) && other.is(Deferred) && member.extendedOverriddenSymbols.forall(_.is(Deferred))) { // (1.9)
378+
overrideError("is erased, cannot override only abstract methods")
387379
} else if (!compatibleTypes(memberTp(self), otherTp(self)) &&
388380
!compatibleTypes(memberTp(upwardsSelf), otherTp(upwardsSelf))) {
389381
overrideError("has incompatible type" + err.whyNoMatchStr(memberTp(self), otherTp(self)))

0 commit comments

Comments
 (0)