Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop inaccessible subclasses from refineUsingParent #21799

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Decorators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ object Decorators {
case _ => String.valueOf(x).nn

/** Returns the simple class name of `x`. */
def className: String = x.getClass.getSimpleName.nn
def className: String = if x == null then "<null>" else x.getClass.getSimpleName.nn

extension [T](x: T)
def assertingErrorsReported(using Context): T = {
Expand Down
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,11 @@ object TypeOps:
for tp <- mixins.reverseIterator do
protoTp1 <:< tp
maximizeType(protoTp1, NoSpan)
wildApprox(protoTp1)
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
Comment on lines +924 to +928
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dwijnand The following change breaks the main branch by failling the tests/warn/i21860 test

}

if (protoTp1 <:< tp2) instantiate()
Expand Down
14 changes: 14 additions & 0 deletions tests/pos/i21790.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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 _ =>
Loading