Skip to content

Generated names of context bound parameters change on incremental compilation causing unnecessary invalidations #18080

Closed
@mrdziuban

Description

@mrdziuban

Compiler version

3.3.0, also happens with 3.3.1-RC1

Minimized code

Unfortunately I haven't been able to come up with a minimal reproduction. This happens in a large, private codebase, and my attempts to replicate the behavior have so far been unsuccessful.

For what it's worth, this is a simplified version of what the code looks like (note that this doesn't reproduce the issue):

object myObject {
  sealed trait Thing {
    def call(): Option[String]
  }
  case class Thing1(o: Option[String]) extends Thing {
    def call(): Option[String] = o.map(s => s"Thing1($s)")
  }

  case class MyType[A](a: A)

  object MyType {
    implicit def myTypeClass[A: MyTypeClass]: MyTypeClass[MyType[A]] = MyTypeClass.derived
  }
}

If I change the string in Thing1.call from "Thing1($s)" to "Thing($s)" (or anything else that doesn't change the signature of Thing1.call) then recompile, I see that the context bound on MyType.myTypeClass has been renamed, causing invalidation of anything that depends on MyType.

Output

I've enabled debug output in sbt with the following settings:

ThisBuild / logLevel := Level.Debug
ThisBuild / incOptions ~= (_.withApiDebug(true).withRelationsDebug(true))

And I see a number of diffs to the API that look like this (shown as a git diff for syntax highlighting):

- [diff] implicit def myTypeClass[ A >: scala.this#Nothing <: scala.this#Any](implicit evidence$63: example.this#MyTypeClass[<A>]): example.this#MyTypeClass[example.myObject$.this#MyType[<A>]]
+ [diff] implicit def myTypeClass[ A >: scala.this#Nothing <: scala.this#Any](implicit evidence$81: example.this#MyTypeClass[<A>]): example.this#MyTypeClass[example.myObject$.this#MyType[<A>]]

Note that the only thing changed is the name of the MyTypeClass parameter, from evidence$63 to evidence$81.

Expectation

Context bound parameter names shouldn't change, or at least they shouldn't cause API invalidation.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions