Skip to content

Commit 8b47342

Browse files
author
Aleksei.Cherepanov
committed
[JPS] Allow writing the subtypes map in compiler-maps-only mode
^KTIJ-30296 Fixed Merge-request: KT-MR-16967 Merged-by: Aleksei Cherepanov <[email protected]> (cherry picked from commit fdff5f1)
1 parent 3dcabe1 commit 8b47342

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

build-common/src/org/jetbrains/kotlin/incremental/AbstractIncrementalCache.kt

+15-7
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ abstract class AbstractIncrementalCache<ClassName>(
128128
*
129129
* The `srcFile` argument may be `null` (e.g., if we are processing .class files in jars where source files are not available).
130130
*/
131-
protected fun addToClassStorage(classProtoData: ClassProtoData, srcFile: File?) {
131+
protected fun addToClassStorage(classProtoData: ClassProtoData, srcFile: File?, useCompilerMapsOnly: Boolean = false) {
132132
val (proto, nameResolver) = classProtoData
133133

134134
val supertypes = proto.supertypes(TypeTable(proto.typeTable))
@@ -143,11 +143,17 @@ abstract class AbstractIncrementalCache<ClassName>(
143143
removedSupertypes.forEach { subtypesMap.removeValues(it, setOf(child)) }
144144

145145
supertypesMap[child] = parents
146-
srcFile?.let { classFqNameToSourceMap[child] = it }
147-
classAttributesMap[child] = ICClassesAttributes(ProtoBuf.Modality.SEALED == Flags.MODALITY.get(proto.flags))
146+
if (!useCompilerMapsOnly) {
147+
srcFile?.let { classFqNameToSourceMap[child] = it }
148+
classAttributesMap[child] = ICClassesAttributes(ProtoBuf.Modality.SEALED == Flags.MODALITY.get(proto.flags))
149+
}
148150
}
149151

150-
protected fun removeAllFromClassStorage(removedClasses: Collection<FqName>, changesCollector: ChangesCollector) {
152+
protected fun removeAllFromClassStorage(
153+
removedClasses: Collection<FqName>,
154+
changesCollector: ChangesCollector,
155+
useCompilerMapsOnly: Boolean = false,
156+
) {
151157
if (removedClasses.isEmpty()) return
152158

153159
val removedFqNames = removedClasses.toSet()
@@ -179,9 +185,11 @@ abstract class AbstractIncrementalCache<ClassName>(
179185
}
180186
}
181187

182-
removedFqNames.forEach {
183-
classFqNameToSourceMap.remove(it)
184-
classAttributesMap.remove(it)
188+
if (!useCompilerMapsOnly) {
189+
removedFqNames.forEach {
190+
classFqNameToSourceMap.remove(it)
191+
classAttributesMap.remove(it)
192+
}
185193
}
186194
}
187195

build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt

+4-10
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,7 @@ open class IncrementalJvmCache(
197197
}
198198
}
199199
KotlinClassHeader.Kind.CLASS -> {
200-
if (!icContext.useCompilerMapsOnly) {
201-
addToClassStorage(kotlinClassInfo.protoData as ClassProtoData, sourceFiles?.let { sourceFiles.single() })
202-
}
200+
addToClassStorage(kotlinClassInfo.protoData as ClassProtoData, sourceFiles?.let { sourceFiles.single() }, icContext.useCompilerMapsOnly)
203201

204202
protoMap.process(kotlinClassInfo, changesCollector)
205203

@@ -257,10 +255,7 @@ open class IncrementalJvmCache(
257255
javaSourcesProtoMap.process(jvmClassName, serializedJavaClass, collector)
258256
}
259257
source?.let { sourceToClassesMap.add(source, jvmClassName) }
260-
if (!icContext.useCompilerMapsOnly) {
261-
addToClassStorage(serializedJavaClass.toProtoData(), source)
262-
// collector.addJavaProto(ClassProtoData(proto, nameResolver))
263-
}
258+
addToClassStorage(serializedJavaClass.toProtoData(), source, icContext.useCompilerMapsOnly)
264259
dirtyOutputClassesMap.notDirty(jvmClassName)
265260
}
266261

@@ -317,9 +312,8 @@ open class IncrementalJvmCache(
317312
}
318313
}
319314

320-
if (!icContext.useCompilerMapsOnly) {
321-
removeAllFromClassStorage(dirtyClasses.map { it.fqNameForClassNameWithoutDollars }, changesCollector)
322-
}
315+
removeAllFromClassStorage(dirtyClasses.map { it.fqNameForClassNameWithoutDollars }, changesCollector, icContext.useCompilerMapsOnly)
316+
323317
dirtyOutputClassesMap.clean()
324318
}
325319

0 commit comments

Comments
 (0)