KT-9875 False unused import in kotlinSpacingRules.kt
#KT-9875 Fixed
This commit is contained in:
@@ -136,8 +136,11 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
||||
val resolutionScope = place.getResolutionScope(bindingContext, place.getResolutionFacade())
|
||||
val noImportsScope = resolutionScope.replaceImportingScopes(null)
|
||||
|
||||
return isInScope(noImportsScope)
|
||||
|| resolutionScope.getImplicitReceiversHierarchy().any { isInScope(it.type.memberScope.memberScopeAsImportingScope()) }
|
||||
if (isInScope(noImportsScope)) return true
|
||||
if (target !is ClassDescriptor) { // classes not accessible through receivers, only their constructors
|
||||
if (resolutionScope.getImplicitReceiversHierarchy().any { isInScope(it.type.memberScope.memberScopeAsImportingScope()) }) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package p
|
||||
|
||||
import p.Outer.Inner1
|
||||
import p.Outer.Inner2
|
||||
|
||||
class Outer {
|
||||
inner class Inner1
|
||||
inner class Inner2
|
||||
}
|
||||
|
||||
fun foo(p: Outer.() -> Unit){}
|
||||
|
||||
fun bar() {
|
||||
foo {
|
||||
fun Inner1.f() {}
|
||||
Inner2()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package p
|
||||
|
||||
import p.Outer.Inner1
|
||||
|
||||
class Outer {
|
||||
inner class Inner1
|
||||
inner class Inner2
|
||||
}
|
||||
|
||||
fun foo(p: Outer.() -> Unit){}
|
||||
|
||||
fun bar() {
|
||||
foo {
|
||||
fun Inner1.f() {}
|
||||
Inner2()
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,12 @@ public class OptimizeImportsTestGenerated extends AbstractOptimizeImportsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KT9875.kt")
|
||||
public void testKT9875() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/editor/optimizeImports/KT9875.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KeywordNames.kt")
|
||||
public void testKeywordNames() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/optimizeImports/KeywordNames.kt");
|
||||
|
||||
Reference in New Issue
Block a user