Skip to content

Seq.++ leaks private symbols to infered type signature #23885

@WojciechMazur

Description

@WojciechMazur

Based on failure in OpenCB for sbt/sbt - build logs

Compiler version

Last good release: 3.8.0-RC1-bin-20250818-aaa39c5-NIGHTLY
First bad release: 3.8.0-RC1-bin-20250819-1f13619-NIGHTLY
Bisect points to 1f13619

I have not inspected the ++ signature but probably it captures the argument. The infered reference to private symbol is probably not stripped.
It needs to be fixed before 3.8 - the opt-in experimental.cc is currently affecting the default compilation mode.

Minimized code

class Setting

object Test:
  private lazy val settings: Seq[Setting] = Nil
  
  def fails = Seq.empty[Setting] ++ settings
  def works: Seq[Setting] = Seq.empty[Setting] ++ settings

Output

Compiling project (Scala 3.8.0-RC1-bin-20250907-8c9c051-NIGHTLY, JVM (21))
[error] ./test.scala:6:7
[error] non-private method fails in object Test refers to private lazy value settings
[error] in its type signature => Seq[Setting]
[error]   def fails = Seq.empty[Setting] ++ settings
[error]       ^

Expectation

The typer should strip the captured symbol when CC is not enabled

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions