Skip to content

Commit

Permalink
Merge pull request #1289 from Friendseeker/trait-private-transitive-dep
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Nov 28, 2023
2 parents 71fdc0d + 0c8f192 commit eb8909f
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ object Incremental {

def previousAnalysisPruned: Analysis

def previousAnalysis: Analysis

/**
* @return true when the compilation cycle is compiling all the sources; false, otherwise.
*/
Expand Down Expand Up @@ -885,7 +887,18 @@ private final class AnalysisCallback(
case d @ (DefinitionType.ClassDef | DefinitionType.Trait) =>
val extraApiHash = {
if (d != DefinitionType.Trait) apiHash
else HashAPI(_.hashAPI(classApi), includePrivateDefsInTrait = true)
else {
val currentExtraHash = HashAPI(_.hashAPI(classApi), includePrivateDefsInTrait = true)
incHandlerOpt match {
case Some(handler) =>
val analysis = handler.previousAnalysis
val parents = analysis.relations.inheritance.external.forward(className)
val parentsAPI = parents.map(analysis.apis.externalAPI)
val parentsHashes = parentsAPI.map(_.extraHash())
parentsHashes.fold(currentExtraHash)(_ ^ _)
case None => currentExtraHash
}
}
}

classApis(className) = ApiInfo(apiHash, extraApiHash, savedClassApi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private[inc] abstract class IncrementalCommon(
invalidatedSources,
classfileManager,
pruned,
previous,
classesToRecompile,
profiler.registerCycle(
invalidatedClasses,
Expand Down Expand Up @@ -148,6 +149,7 @@ private[inc] abstract class IncrementalCommon(
invalidatedSources: Set[VirtualFile],
classFileManager: XClassFileManager,
pruned: Analysis,
override val previousAnalysis: Analysis,
classesToRecompile: Set[String],
registerCycle: (Set[String], APIChanges, Set[String], Boolean) => Unit
) extends IncrementalCallback(classFileManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ case class ProjectStructure(
compile(i).map { analysis =>
discoverMainClasses(Some(analysis.apis)) match {
case Seq(mainClassName) =>
val cp = ((i.si.allJars.map(_.toPath) :+ classesDir) ++ outputJar).map(_.toAbsolutePath)
val jars = i.si.allJars.map(_.toPath)
val cp = (jars ++ (unmanagedJars :+ output) ++ internalClasspath).map(_.toAbsolutePath)
val loader = ClasspathUtil.makeLoader(cp, i.si, baseDirectory)
val buffer = new ByteArrayOutputStream(8192)
val oldOut = System.out
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package a

trait A {
private val a1: String = ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package a

trait A {
private val a2: String = ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package b

trait B extends a.A
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"projects": [
{"name": "main", "dependsOn": ["a", "b","c"], "scalaVersion": "2.13.12"},
{"name": "c", "dependsOn": ["a","b"], "scalaVersion": "2.13.12"},
{"name": "b", "dependsOn": ["a"], "scalaVersion": "2.13.12"},
{"name": "a", "scalaVersion": "2.13.12"}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package c

class C extends b.B
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Main extends App {
val impl = new c.C()
println("OK")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> main/run
$ copy-file a/changes/A.scala a/A.scala
> main/run

0 comments on commit eb8909f

Please sign in to comment.