You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes: #826
Context: #682
Given the following Kotlin code:
internal class MyClass {
public interface MyInterface { }
}
The default Java representation of this would be:
public MyClass {
public MyInterface { }
}
In order to prevent this from being bound, our Kotlin fixups
attempted to change the Java representation to:
private class MyClass {
private interface MyInterface { }
}
However there was a bug preventing the internal interface from being
marked as `private`, because we are setting the visibility on the
parent type's `InnerClassAccessFlags`, *not* the nested type itself.
When we output the XML we use use the declaring class'
`InnerClassAccessFlags`, we instead look at the flags on the nested
type's `.class` file, which was still `public`:
<class name="MyClass" visibility="private" … />
<class name="MyClass.MyInterface" visibility="public" … />
This would result in a `generator` warning when trying to bind
`MyClass.MyInterface`, as the parent `MyClass` type is skipped:
warning BG8604: top ancestor MyClass not found for nested type MyClass.MyInterface
Fix this by finding the appropriate inner class `.class` file and
updating the access flags there, recursively:
<class name="MyClass" visibility="private" … />
<class name="MyClass.MyInterface" visibility="private" … />
Note: the [`InnerClasses` Attribute][0] for an inner class may
contain the declaring class. For example, the `InnerClasses` for
`InternalClassWithNestedInterface$NestedInterface` contains
`InternalClassWithNestedInterface$NestedInterface`.
We must thus protect recursive `HideInternalInnerClass()` invocations
from processing the current type, to avoid infinite recursion.
[0]: https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.6
0 commit comments