Skip to content

Commit 3d79d40

Browse files
committed
(Re-)Drop inaccessible subclasses from refineUsingParent
This reverts commit cecd053.
1 parent fb83893 commit 3d79d40

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
@@ -930,7 +930,11 @@ object TypeOps:
930930
for tp <- mixins.reverseIterator do
931931
protoTp1 <:< tp
932932
maximizeType(protoTp1, NoSpan)
933-
wildApprox(protoTp1)
933+
val inst = wildApprox(protoTp1)
934+
if !inst.classSymbol.exists then
935+
// E.g. i21790, can't instantiate S#CA as a subtype of O.A, because O.CA isn't accessible
936+
NoType
937+
else inst
934938
}
935939

936940
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)