Is it allowed for a `public class` to implement an...
# getting-started
l
Is it allowed for a
public class
to implement an
internal interface
?
🚫 2
Ok, then I have some caching issue in my Android Studio because it doesn't show it as error...
image.png
I don't get a compile error somehow
Android Studio Giraffe (Canary)
m
That is not an error, it's a warning. It's saying that the
MyClass
is never used elsewhere. Either use it somewhere or add
@Suppress("UNUSED")
on top of the class. Note: the warning can be there for a good reason, suppressing it only makes sense for libraries and you do not want to add test for that class.
l
The screenshot referred to my original question:
MyClass
should be underscored squiggly red, as it is a
public class
which extends an
internal interface
.
This should not compile
m
internal
just means it's not visible outside the current module/project, if it's in the same module/project it's compile fine I would say (it might fail if you return/expose the interface as a type in some method)
l
I would think that you should not be able even to create such class, as a
public
class would then be able to expose an
internal
interface to outside code
m
That's the whole point, you do not expose the interface (it's members) outside your module. https://discuss.kotlinlang.org/t/what-is-the-purpose-of-an-internal-interface/25384/12
l
Ah, so the methods of an
internal
interface are still publicly visible...
Thank you for the helpful link!