Shadowed declarations filtering: more correct selection of imported declarations
This commit is contained in:
@@ -64,14 +64,17 @@ public class ShadowedDeclarationsFilter(
|
|||||||
val importedDeclarationsSet = importedDeclarations.toSet()
|
val importedDeclarationsSet = importedDeclarations.toSet()
|
||||||
val nonImportedDeclarations = declarations.filter { it !in importedDeclarationsSet }
|
val nonImportedDeclarations = declarations.filter { it !in importedDeclarationsSet }
|
||||||
|
|
||||||
|
val importedDeclarationsBySignature = importedDeclarationsSet.groupBy { signature(it) }
|
||||||
|
|
||||||
val call = expression.getCall(bindingContext) ?: return nonImportedDeclarations
|
val call = expression.getCall(bindingContext) ?: return nonImportedDeclarations
|
||||||
|
|
||||||
val notShadowed = nonImportedDeclarations
|
val notShadowed = HashSet<DeclarationDescriptor>()
|
||||||
.groupBy { signature(it) to packageName(it) } // same signature non-imported declarations from different packages do not shadow each other
|
// same signature non-imported declarations from different packages do not shadow each other
|
||||||
.values()
|
for ((pair, group) in nonImportedDeclarations.groupBy { signature(it) to packageName(it) }) {
|
||||||
.flatMapTo(HashSet<DeclarationDescriptor>()) { group ->
|
val imported = importedDeclarationsBySignature[pair.first]
|
||||||
filterEqualSignatureGroup(group + importedDeclarations, call, descriptorsToImport = group)
|
val all = if (imported != null) group + imported else group
|
||||||
}
|
notShadowed.addAll(filterEqualSignatureGroup(all, call, descriptorsToImport = group))
|
||||||
|
}
|
||||||
return declarations.filter { it in notShadowed }
|
return declarations.filter { it in notShadowed }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user