Do not return nested/local classes as a part of package fragment

#KT-13757 Fixed
This commit is contained in:
Denis Zharkov
2016-09-07 14:23:16 +03:00
parent 4bf61db9f9
commit 44f5df00fe
6 changed files with 62 additions and 9 deletions
@@ -0,0 +1,5 @@
package test;
public class JavaOuter {
public static class JavaNested {}
}
@@ -0,0 +1,5 @@
package test
class Outer {
class Nested
}
@@ -0,0 +1,10 @@
import test.Outer
import test.JavaOuter
fun main(args: Array<String>) {
Outer.Nested()
test.`Outer$Nested`()
JavaOuter.JavaNested()
test.`JavaOuter$JavaNested`()
}
@@ -0,0 +1,7 @@
compiler/testData/compileKotlinAgainstCustomBinaries/prohibitNestedClassesByDollarName/main.kt:6:10: error: unresolved reference: `Outer$Nested`
test.`Outer$Nested`()
^
compiler/testData/compileKotlinAgainstCustomBinaries/prohibitNestedClassesByDollarName/main.kt:9:10: error: unresolved reference: `JavaOuter$JavaNested`
test.`JavaOuter$JavaNested`()
^
COMPILATION_ERROR
@@ -386,4 +386,21 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
File library2 = compileLibrary("library-2");
doTestWithTxt(usage, library2);
}
public void testProhibitNestedClassesByDollarName() throws Exception {
File library = compileLibrary("library");
KotlinTestUtils.compileJavaFiles(
Collections.singletonList(
new File(getTestDataDirectory() + "/library/test/JavaOuter.java")
),
Arrays.asList("-d", tmpdir.getPath())
);
Pair<String, ExitCode> outputMain = compileKotlin("main.kt", tmpdir, tmpdir, library);
KotlinTestUtils.assertEqualsToFile(
new File(getTestDataDirectory(), "output.txt"), normalizeOutput(outputMain)
);
}
}