Skip to content

Commit 185188c

Browse files
dwijnandtgodzik
authored andcommitted
(Re-)Drop inaccessible subclasses from refineUsingParent
This reverts commit cecd053. [Cherry-picked 3d79d40]
1 parent 603973e commit 185188c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,11 @@ object TypeOps:
943943
for tp <- mixins.reverseIterator do
944944
protoTp1 <:< tp
945945
maximizeType(protoTp1, NoSpan)
946-
wildApprox(protoTp1)
946+
val inst = wildApprox(protoTp1)
947+
if !inst.classSymbol.exists then
948+
// E.g. i21790, can't instantiate S#CA as a subtype of O.A, because O.CA isn't accessible
949+
NoType
950+
else inst
947951
}
948952

949953
if (protoTp1 <:< tp2) instantiate()

tests/pos/i21790.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package p
2+
3+
trait S:
4+
sealed trait A
5+
private class CA() extends A
6+
7+
object O extends S
8+
9+
trait T
10+
11+
class Test:
12+
def f(e: T) = e match
13+
case _: O.A =>
14+
case _ =>

0 commit comments

Comments
 (0)