java.interop icon indicating copy to clipboard operation
java.interop copied to clipboard

Package-private classes used in generics not properly exposed

Open jpobst opened this issue 4 years ago • 0 comments

Context: https://developercommunity.visualstudio.com/t/after-1656-my-project-wont-compile/1492830

When you try to publicly expose a class that is package private, we identify this case and expose it as JLO instead (actually the best base class that is public):

public class MyClass
{
    class MyNestedClass { }
    public MyNestedClass GetNestedClass () { return null; }
}
public class MyClass : Java.Lang.Object
{
  public Java.Lang.Object GetNestedClass () { ... }
}

However if the package-private class is a generic argument, we do not perform this fixup and expose the package-private type:

public class MyClass
{
    class MyNestedClass { }
    public java.util.List<MyNestedClass> GetNestedClass () { return null; }
}
public class MyClass : Java.Lang.Object
{
  public IList<MyClass.MyNestedClass> GetNestedClass () { ... }
}

Which results in the compile error:

error CS0426: The type name 'MyNestedClass' does not exist in the type 'MyClass'

jpobst avatar Sep 10 '21 15:09 jpobst