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

Allow inner classes of universal traits #18796

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 30, 2023

Just forbid inner objects. This aligns with Scala 2 and allows us to keep Seq's definition as in Scala 2 when porting or capture checking the standard library.

Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

@@ -2785,11 +2785,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
checkDerivedValueClass(cls, body1)

val effectiveOwner = cls.owner.skipWeakOwner
if !cls.isRefinementClass
&& !cls.isAllOf(PrivateLocal)
if cls.is(ModuleClass)
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not have any neg tests for this case. The following seems to cover what we are missing.

trait Outer extends Any {
  trait Inner1
  trait Inner2 extends Any
  class Inner3
  class Inner4(a: Int) extends AnyVal // error
  case class Inner5(a: Int) // error
  object Inner6 // error
}

@odersky
Copy link
Contributor Author

odersky commented Oct 30, 2023

@nicolasstucki Can you please add the test? I am already deep in something else.

@odersky odersky assigned nicolasstucki and unassigned odersky Oct 30, 2023
@nicolasstucki
Copy link
Contributor

I will add the tests

Just forbid inner objects. This aligns with Scala 2 and
allows us to keep Seq's definition as in Scala 2.
@odersky odersky merged commit e2c9dc0 into scala:main Oct 30, 2023
18 checks passed
@odersky odersky deleted the drop-inner-class-restriction branch October 30, 2023 18:29
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants