From cecd05356beecd232053d4c593af54bcc12cad0e Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Wed, 6 Nov 2024 18:16:33 +0100 Subject: [PATCH] Revert "Drop inaccessible subclasses from refineUsingParent" --- .../src/dotty/tools/dotc/core/Decorators.scala | 2 +- compiler/src/dotty/tools/dotc/core/TypeOps.scala | 6 +----- tests/pos/i21790.scala | 14 -------------- 3 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 tests/pos/i21790.scala diff --git a/compiler/src/dotty/tools/dotc/core/Decorators.scala b/compiler/src/dotty/tools/dotc/core/Decorators.scala index 96a2d45db80d..29d4b3fa4052 100644 --- a/compiler/src/dotty/tools/dotc/core/Decorators.scala +++ b/compiler/src/dotty/tools/dotc/core/Decorators.scala @@ -292,7 +292,7 @@ object Decorators { case _ => String.valueOf(x).nn /** Returns the simple class name of `x`. */ - def className: String = if x == null then "" else x.getClass.getSimpleName.nn + def className: String = x.getClass.getSimpleName.nn extension [T](x: T) def assertingErrorsReported(using Context): T = { diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 79eac7bde38d..2403a6e22bc6 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -930,11 +930,7 @@ object TypeOps: for tp <- mixins.reverseIterator do protoTp1 <:< tp maximizeType(protoTp1, NoSpan) - val inst = wildApprox(protoTp1) - if !inst.classSymbol.exists then - // E.g. i21790, can't instantiate S#CA as a subtype of O.A, because O.CA isn't accessible - NoType - else inst + wildApprox(protoTp1) } if (protoTp1 <:< tp2) instantiate() diff --git a/tests/pos/i21790.scala b/tests/pos/i21790.scala deleted file mode 100644 index 0cc7db935ac7..000000000000 --- a/tests/pos/i21790.scala +++ /dev/null @@ -1,14 +0,0 @@ -package p - -trait S: - sealed trait A - private class CA() extends A - -object O extends S - -trait T - -class Test: - def f(e: T) = e match - case _: O.A => - case _ =>