Skip to content

Commit 97ce7c2

Browse files
committed
Avoid spurious check in RefChecks
1 parent a47aaf0 commit 97ce7c2

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -774,17 +774,19 @@ object RefChecks {
774774

775775
// For each member, check that the type of its symbol, as seen from `self`
776776
// can override the info of this member
777-
for (name <- membersToCheck)
778-
for (mbrd <- self.member(name).alternatives) {
779-
val mbr = mbrd.symbol
780-
val mbrType = mbr.info.asSeenFrom(self, mbr.owner)
781-
if (!mbrType.overrides(mbrd.info, relaxedCheck = false, matchLoosely = true))
782-
report.errorOrMigrationWarning(
783-
em"""${mbr.showLocated} is not a legal implementation of `$name` in $clazz
784-
| its type $mbrType
785-
| does not conform to ${mbrd.info}""",
786-
(if (mbr.owner == clazz) mbr else clazz).srcPos, from = `3.0`)
777+
withMode(Mode.IgnoreCaptures) {
778+
for (name <- membersToCheck)
779+
for (mbrd <- self.member(name).alternatives) {
780+
val mbr = mbrd.symbol
781+
val mbrType = mbr.info.asSeenFrom(self, mbr.owner)
782+
if (!mbrType.overrides(mbrd.info, relaxedCheck = false, matchLoosely = true))
783+
report.errorOrMigrationWarning(
784+
em"""${mbr.showLocated} is not a legal implementation of `$name` in $clazz
785+
| its type $mbrType
786+
| does not conform to ${mbrd.info}""",
787+
(if (mbr.owner == clazz) mbr else clazz).srcPos, from = `3.0`)
787788
}
789+
}
788790
}
789791

790792
/** Check that inheriting a case class does not constitute a variant refinement

tests/pos-custom-args/captures/overrides.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,3 @@ class Bar extends Foo:
1212
class Baz extends Bar:
1313
override def foo = () => println("baz")
1414
override def bar = "baz"
15-
//override def toString = bar
16-
17-
abstract class Message:
18-
protected def msg: String
19-
override def toString = msg
20-
21-
abstract class SyntaxMsg extends Message
22-
23-
class CyclicInheritance extends SyntaxMsg:
24-
def msg = "cyclic"
25-
26-
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
abstract class Message:
2+
lazy val message: String = ???
3+
def rawMessage = message
4+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
abstract class SyntaxMsg extends Message
3+
4+
class CyclicInheritance extends SyntaxMsg
5+
6+

0 commit comments

Comments
 (0)