KT-9875 False unused import in kotlinSpacingRules.kt

#KT-9875 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-11-03 14:11:01 +03:00
parent 5e9aa38950
commit 218c0cfff7
4 changed files with 46 additions and 2 deletions
@@ -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
View File
@@ -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()
}
}
+17
View File
@@ -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");