Kotlin Error : 'public' function exposes its 'public/*package*/' return type argument
I presume that by "package public" you meant "package private"? In your example, FooBuilder.FooSettings
has no visibility modifier so uses the Java default of package private. Assuming that's what you meant...
You will be able to access the package private class, FooSettings
, in your Kotlin code, but only if you put that Kotlin code in a package matching the one where FooSettings
is declared.
You'll still get the same compilation error, but that's not because you can't access the type: it's because you're trying to use it in a context which is more visible than the type's declaration. i.e. you're trying to take a package private type and use it as part of a public method's signature, which isn't allowed. To get round that problem you need to mark your Kotlin class as internal
.
It's might also be worth mentioning that internal
for Kotlin means it's visible in that module, not in that package. This is all explained in more detail here.