Skip to content

Commit c83b8a8

Browse files
authored
Cleanup bunch of small issues in JdepsGetExtension.kt (#819)
- Remove explicit casts unneeded because of smart casts. - Remove `collectSuperTypes` parameter as it is always `true`. - Remove the mention of Remapper from the comment - its use was removed in 71246c9 - Typo fixes.
1 parent 7ba80e7 commit c83b8a8

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenExtension.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@ import java.nio.file.Paths
5252
/**
5353
* Kotlin compiler extension that tracks classes (and corresponding classpath jars) needed to
5454
* compile current kotlin target. Tracked data should include all classes whose changes could
55-
* affect target's compilation out : direct class dependencies (i.e external classes directly
55+
* affect target's compilation out : direct class dependencies (i.e. external classes directly
5656
* used), but also their superclass, interfaces, etc.
5757
* The primary use of this extension is to improve Kotlin module compilation avoidance in build
5858
* systems (like Buck).
5959
*
60-
* Tracking of classes is done with a Remapper, which exposes all object types used by the class
61-
* bytecode being generated. Tracking of the ancestor classes is done via modules and class
60+
* Tracking of classes and their ancestors is done via modules and class
6261
* descriptors that got generated during analysis/resolve phase of Kotlin compilation.
6362
*
64-
* Note: annotation processors dependencies may need to be tracked separatly (and may not need
63+
* Note: annotation processors dependencies may need to be tracked separately (and may not need
6564
* per-class ABI change tracking)
6665
*
6766
* @param project the current compilation project
@@ -130,10 +129,10 @@ class JdepsGenExtension(
130129
) {
131130
when (val resultingDescriptor = resolvedCall.resultingDescriptor) {
132131
is FunctionImportedFromObject -> {
133-
collectTypeReferences((resolvedCall.resultingDescriptor as FunctionImportedFromObject).containingObject.defaultType)
132+
collectTypeReferences(resultingDescriptor.containingObject.defaultType)
134133
}
135134
is PropertyImportedFromObject -> {
136-
collectTypeReferences((resolvedCall.resultingDescriptor as PropertyImportedFromObject).containingObject.defaultType)
135+
collectTypeReferences(resultingDescriptor.containingObject.defaultType)
137136
}
138137
is JavaMethodDescriptor -> {
139138
getClassCanonicalPath((resultingDescriptor.containingDeclaration as ClassDescriptor).typeConstructor)?.let { explicitClassesCanonicalPaths.add(it) }
@@ -223,26 +222,23 @@ class JdepsGenExtension(
223222
* types.
224223
*/
225224
private fun collectTypeReferences(kotlinType: KotlinType,
226-
isExplicit: Boolean = true,
227-
collectSuperTypes: Boolean = true) {
225+
isExplicit: Boolean = true) {
228226
if (isExplicit) {
229227
addExplicitDep(kotlinType)
230228
} else {
231229
addImplicitDep(kotlinType)
232230
}
233231

234-
if (collectSuperTypes) {
235-
kotlinType.supertypes().forEach {
236-
addImplicitDep(it)
237-
}
232+
kotlinType.supertypes().forEach {
233+
addImplicitDep(it)
238234
}
239235

240236
collectTypeArguments(kotlinType, isExplicit)
241237
}
242238

243-
fun collectTypeArguments(kotlinType: KotlinType,
244-
isExplicit: Boolean,
245-
visitedKotlinTypes: MutableSet<KotlinType> = mutableSetOf()) {
239+
private fun collectTypeArguments(kotlinType: KotlinType,
240+
isExplicit: Boolean,
241+
visitedKotlinTypes: MutableSet<KotlinType> = mutableSetOf()) {
246242
visitedKotlinTypes.add(kotlinType)
247243
kotlinType.arguments.map { it.type }.forEach { typeArgument ->
248244
if (isExplicit) {

0 commit comments

Comments
 (0)