Prefer package with class files to class with the same name
See comments in JvmDependenciesIndexImpl and in the test #KT-15464 Fixed
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
package test;
|
||||
|
||||
public class Boo {
|
||||
public interface Nested {}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package test;
|
||||
|
||||
public class Foo {
|
||||
public interface Nested {
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test.Boo.SubBoo;
|
||||
|
||||
public class C {
|
||||
public interface Nested {}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package test.Foo;
|
||||
|
||||
public class Bar {
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/innerClassPackageConflict2/source.kt:10:9: error: unresolved reference: Nested
|
||||
val v3: Nested? = null
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/innerClassPackageConflict2/source.kt:11:18: error: unresolved reference: Nested
|
||||
val v4: test.Foo.Nested? = null
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/innerClassPackageConflict2/source.kt:14:18: error: unresolved reference: Nested
|
||||
val v6: test.Boo.Nested? = null
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import test.Foo.*
|
||||
|
||||
// Note that unlike in Java, in Kotlin we currently mostly prefer package to class in qualified name resolution.
|
||||
// So here, for example, we see both the package and the class with the name test.Foo, and prefer the former.
|
||||
// So 'Bar' should be resolved, 'Nested' should be unresolved.
|
||||
// For javac, the opposite is true: 'Bar' would be unresolved in a similar situation, 'Nested' would be resolved.
|
||||
|
||||
val v1: Bar? = null
|
||||
val v2: test.Foo.Bar? = null
|
||||
val v3: Nested? = null
|
||||
val v4: test.Foo.Nested? = null
|
||||
|
||||
val v5: test.Boo.SubBoo.C.Nested? = null
|
||||
val v6: test.Boo.Nested? = null
|
||||
Reference in New Issue
Block a user