Skip to content

Package protected class cannot extend a public sealed generic class with a protected constructor #12756

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

Closed
noresttherein opened this issue Mar 23, 2023 · 2 comments

Comments

@noresttherein
Copy link

noresttherein commented Mar 23, 2023

Reproduction steps

Scala version: 2.13.10

package test {
	sealed class Seal[X] protected (x :String) {
		protected def this() = this("")
	}
	protected[test] class Walrus extends Seal
}

Problem

constructor Seal in class Seal cannot be accessed in package test from package test
 Access to protected constructor Seal not permitted because
 enclosing package test is not a subclass of
 class Seal in package test where target is defined
	protected[test] class Walrus extends Seal

A bummer because it is a useful technique for 'unsealing' a class for a class in another file.

@SethTisue
Copy link
Member

SethTisue commented Mar 24, 2023

assuming you mean extends Seal[String] or some such and not just extends Seal (because otherwise "Missing type parameter for test.Seal"), Scala 3 accepts this

offhand this like something we'd be unlikely to tinker with in a Scala 2 context, but I could certainly be wrong

@SethTisue SethTisue added this to the Backlog milestone Mar 24, 2023
@SethTisue SethTisue added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Mar 24, 2023
@som-snytt
Copy link

Duplicates #12379

@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2023
@som-snytt som-snytt removed the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Mar 29, 2023
@SethTisue SethTisue removed this from the Backlog milestone Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants