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

Cons next leaks through next$access$1 #18884

Closed
nicolasstucki opened this issue Nov 9, 2023 · 2 comments · Fixed by #18907
Closed

Cons next leaks through next$access$1 #18884

nicolasstucki opened this issue Nov 9, 2023 · 2 comments · Fixed by #18907

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.3

Minimized code

The following code compiles but should not

def test(xs: ::[Int]): List[Int] =
  xs.next$access$1

Other manifestation

This method also apears in autocompletion

Screenshot 2023-11-09 at 11 03 49

Expectation

This code should not compile.

@nicolasstucki nicolasstucki added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label compat:scala2 and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 9, 2023
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Nov 9, 2023

Note that this accessor exists becase the next case parameter is private[scala]

final case class :: [+A](override val head: A, private[scala] var next: List[A @uncheckedVariance]) // sound because `next` is used only locally
  extends List[A] {
// scala 2 after typer
final case class ::[+A] extends List[A] with Product with Serializable {
  <caseaccessor> <paramaccessor> private[this] val head: A = _;
  override <stable> <caseaccessor> <accessor> <paramaccessor> def head: A = ::.this.head;
  <caseaccessor> <paramaccessor> private[this] var next: List[A] = _;
  <caseaccessor> <accessor> <paramaccessor> def next: List[A] = ::.this.next;
  <accessor> <paramaccessor> def next_=(x$1: List[A]): Unit = ::.this.next = x$1;
  def <init>(head: A, next: List[A]): Playground.::[A] = {
    ::.super.<init>();
    ()
  };
  ...
}

next$access$1 is created later in the superaccessors phase just before pickling.

@nicolasstucki
Copy link
Contributor Author

This also leaks in mirrors (see tests/run/typeclass-derivation3.check).

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 16, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 16, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 16, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 17, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 17, 2023
nicolasstucki added a commit that referenced this issue Nov 17, 2023
WojciechMazur added a commit that referenced this issue Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant