Skip to content

Regression for copy method referring to lazy vals and Scala collections #24101

@WojciechMazur

Description

@WojciechMazur

Based on the OpenCB failure in trace4cats/trace4cats-opentelemetry - build logs
Same kind of errors also found in 3 other projects

Compiler version

Last good release: 3.8.0-RC1-bin-20250822-658c8bd-NIGHTLY
First bad release: 3.8.0-RC1-bin-20250823-712d5bc-NIGHTLY

Bisect points to 712d5bc (unlikely, rather related to usage of new Scala stdlib instead)

Minimized code

trait AttributeValue

case class CompletedSpan(
  name: String, // remove to make it compile
  attributes: Map[String, AttributeValue],
){
  lazy val allAttributes: Map[String, AttributeValue] = attributes
}

def Test = 
  val span: CompletedSpan = ???
  span.copy(attributes = span.allAttributes.filterNot { _ => false })

Output

Should compile

Error: (span.allAttributes : Map[String, AttributeValue]) is not a legal path
since it refers to nonfinal lazy value allAttributes
Error compiling project (Scala 3.8.0-RC1-bin-20250928-b67fcf2-NIGHTLY, JVM (21))

Expectation

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions