Restore heuristic to compute inner class names in ClassifierResolutionContext

This commit restores the heuristic removed in 9df02b2366, but only
enables it in case the class wasn't found with the name mapped initially
according to the InnerClasses attribute values. This helps to support
class files which do not have the InnerClasses attribute for all nested
referenced classes, such as those generated by Groovy.

Note that in theory it's still possible for this code to behave
incorrectly, for example a reference to a class `C` nested in a
_top-level_ class named `A$B` will not be loaded by this code correctly.
This is a lower-priority issue and it will need to be fixed later.

 #KT-27874 Fixed
This commit is contained in:
Alexander Udalov
2018-10-31 16:53:27 +01:00
parent a3231e561c
commit 61d3b6ee1f
11 changed files with 64 additions and 7 deletions
@@ -109,8 +109,8 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
}
@Test
fun testGroovyTraitsWithFields() {
Project("groovyTraitsWithFields").build("build") {
fun testGroovyInterop() {
Project("groovyInterop").build("build") {
assertSuccessful()
}
}
@@ -0,0 +1,9 @@
public class ClassWithReferenceToInner {
public void f1(Thread.State state) {}
public void f2(Outer.Nested nested) {}
}
class Outer {
class Nested {}
}
@@ -0,0 +1,6 @@
fun main(args: Array<String>) {
System.out.println(MyTraitAccessor().myField)
System.out.println(ClassWithReferenceToInner().f1(null))
System.out.println(ClassWithReferenceToInner().f2(null))
}
@@ -1,3 +0,0 @@
fun main(args: Array<String>) {
System.out.println(MyTraitAccessor().myField)
}