Skip to content

Incremental compilation: handle constructor proxies #11360

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

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,19 @@ class ExtractDependencies extends Phase {
builder.append(".")
}
val flatName = dep.to.flatName
// We create fake companion object symbols to hold the static members
// of Java classes, make sure to use the name of the actual Java class
// here.
val clsFlatName = if (dep.to.is(JavaDefined)) flatName.stripModuleClassSuffix else flatName
// Some companion objects are fake (that is, they're a compiler fiction
// that doesn't correspond to a class that exists at runtime), this
// can happen in two cases:
// - If a Java class has static members.
// - If we create constructor proxies for a class (see NamerOps#addConstructorProxies).
//
// In both cases it's vital that we don't send the object name to
// zinc: when sbt is restarted, zinc will inspect the binary
// dependencies to see if they're still on the classpath, if it
// doesn't find them it will invalidate whatever referenced them, so
// any reference to a fake companion will lead to extra recompilations.
// Instead, use the class name since it's guaranteed to exist at runtime.
val clsFlatName = if (dep.to.isOneOf(JavaDefined | ConstructorProxy)) flatName.stripModuleClassSuffix else flatName
builder.append(clsFlatName.mangledString)
builder.toString
}
Expand Down