Skip to content

Commit d24451f

Browse files
committed
ignore capture annotations in abstract class checks
1 parent de98fcd commit d24451f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ object RefChecks {
590590
clazz.nonPrivateMembersNamed(mbr.name)
591591
.filterWithPredicate(
592592
impl => isConcrete(impl.symbol)
593-
&& mbrDenot.matchesLoosely(impl, alwaysCompareTypes = true))
593+
&& withMode(Mode.IgnoreCaptures)(mbrDenot.matchesLoosely(impl, alwaysCompareTypes = true)))
594594
.exists
595595

596596
/** The term symbols in this class and its baseclasses that are
@@ -737,7 +737,7 @@ object RefChecks {
737737
def checkNoAbstractDecls(bc: Symbol): Unit = {
738738
for (decl <- bc.info.decls)
739739
if (decl.is(Deferred)) {
740-
val impl = decl.matchingMember(clazz.thisType)
740+
val impl = withMode(Mode.IgnoreCaptures)(decl.matchingMember(clazz.thisType))
741741
if (impl == NoSymbol || decl.owner.isSubClass(impl.owner))
742742
&& !ignoreDeferred(decl)
743743
then

tests/neg-custom-args/captures/override-adapt-box.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class IO
88
class C
99

1010
def test(io: {*} IO) = {
11-
class B extends A[{io} C] { // X =:= {io} C // error
11+
class B extends A[{io} C] { // X =:= {io} C
1212
override def foo(x: {io} C): {io} C = ??? // error
1313
}
1414
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import language.experimental.captureChecking
2+
3+
class IO
4+
5+
abstract class A[X] {
6+
def foo(x: Unit): X
7+
def bar(op: X => Int): Int
8+
}
9+
10+
class C
11+
12+
def test(io: {*} IO) = {
13+
class B extends A[{io} C] { // X =:= {io} C
14+
def foo(x: Unit): {io} C = ???
15+
def bar(op: ({io} C) => Int): Int = 0
16+
}
17+
}

0 commit comments

Comments
 (0)