# Internal methods in interface

**URL:** <https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590>\
**Category:** Language Design\
**Created:** [February 12, 2018, 1:08pm UTC](https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590 "2018-02-12T13:08:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tieskedh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tieskedh/32/2816_2.png) [@tieskedh](https://discuss.kotlinlang.org/u/tieskedh)\
**Post date:** [February 12, 2018, 1:08pm UTC](https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590/1 "2018-02-12T13:08:19Z")

</div>

I like to see the option to add internal methods to an internal interface.

example:

```
internal interface MyInterface{
    internal fun myFun()
}
class Test : MyInterface{
   override internal fun myFun() = Unit
}

```

---

<div class="post-metadata">

**Author:** ![fvasco](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/fvasco/32/1961_2.png) [@fvasco](https://discuss.kotlinlang.org/u/fvasco)\
**Post date:** [February 12, 2018, 1:34pm UTC](https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590/2 "2018-02-12T13:34:49Z")

</div>

Internal interface cannot expose _public_ methods (interface itself is not _public_).

---

<div class="post-metadata">

**Author:** ![tieskedh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tieskedh/32/2816_2.png) [@tieskedh](https://discuss.kotlinlang.org/u/tieskedh)\
**Post date:** [February 12, 2018, 1:40pm UTC](https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590/3 "2018-02-12T13:40:37Z")

</div>

I updated my suggestion.  
(the next time I try to be clear from the beginning)

---

<div class="post-metadata">

**Author:** ![pdvrieze](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pdvrieze/32/1882_2.png) [@pdvrieze](https://discuss.kotlinlang.org/u/pdvrieze)\
**Post date:** [February 13, 2018, 9:18pm UTC](https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590/4 "2018-02-13T21:18:54Z")

</div>

The question here is can you inherit from an internal interface (what about classes) and should you? At the same time I have similar wishes (I’d like to have protected members in interfaces - with default methods you almost get multiple inheritance).

---

<div class="post-metadata">

**Author:** ![tieskedh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tieskedh/32/2816_2.png) [@tieskedh](https://discuss.kotlinlang.org/u/tieskedh)\
**Post date:** [December 24, 2019, 12:01pm UTC](https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590/5 "2019-12-24T12:01:58Z")

</div>

The minimum requirements to fullfill my use-case:

- An interface/abstract class with an abstract internal function needs to be internal  
(Cross-module can be explored later on)
- An interface can be inherited from by non-abstract classes (from inside the same module)

later on this can be expanded to:

- An interface can be inherited by other internal interfaces/abstract classes (with the same rules)

followed by:

- An interface can be implemented by public interfaces/abstract classes as long as it provides an (final?) implementation for the abstract internal functions.

and, maybe later explore cross-module functions.

(I don’t know anything about the compiler side, so I just did it based upon restrictions)

---

<div class="post-metadata">

**Author:** ![jhdcruz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jhdcruz/32/10172_2.png) [@jhdcruz](https://discuss.kotlinlang.org/u/jhdcruz)\
**Post date:** [January 9, 2023, 5:53am UTC](https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590/6 "2023-01-09T05:53:48Z")

</div>

Just dropping this for others who stumbled upon here looking for the same functionality.

This feature is tracked here: _(vote if your looking for the same functionality)_

- [implement an interface with other visibility than public : KT-24328 (jetbrains.com)](https://youtrack.jetbrains.com/issue/KT-24328/implement-an-interface-with-other-visibility-than-public)
- [Support for visibility modifiers in interface methods : KT-55813 (jetbrains.com)](https://youtrack.jetbrains.com/issue/KT-55813/Support-for-visibility-modifiers-in-interface-methods)

---

<div class="post-metadata">

**Author:** ![benwoodworth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@benwoodworth](https://discuss.kotlinlang.org/u/benwoodworth)\
**Post date:** [January 12, 2023, 11:45pm UTC](https://discuss.kotlinlang.org/t/internal-methods-in-interface/6590/7 "2023-01-12T23:45:50Z")

</div>

Also, [this comment](https://youtrack.jetbrains.com/issue/KT-22286/Support-interfaces-with-ability-to-extend-and-implement-them-only-in-the-same-module-sealed-on-steroids#focus=Comments-27-3712355.0-0) about sealed interfaces in [KT-22268](https://youtrack.jetbrains.com/issue/KT-22286/):

> An important addition to this request that had been recently realized is that `sealed interface` shall support `internal` members. This would allow library API design and evolution without ugly hacks.
