Skip to main content
A functional interface, declared with the fun modifier, is an interface that contains exactly one abstract method. Also known as a Single Abstract Method (SAM) interface, it explicitly opts into SAM conversion. This compiler feature allows the interface to be instantiated using a concise lambda expression whose signature matches the abstract method, bypassing the need for verbose anonymous object expressions. Declaration Syntax To define a functional interface, prepend the standard interface keyword with the fun modifier.
Structural Constraints The Kotlin compiler enforces strict rules for an interface to qualify as a fun interface:
  1. Single Abstract Method: It must declare exactly one abstract method.
  2. Multiple Implemented Methods: It may contain any number of non-abstract methods (methods with default implementations).
  3. No State: Like standard interfaces, it cannot maintain state (no backing fields).
  4. Subtyping: It can implement other standard interfaces, provided the resulting contract still yields exactly one abstract method.
SAM Conversion Mechanics Without the fun modifier, a Kotlin interface must be instantiated using an object expression. When the fun modifier is present, the compiler automatically maps a lambda expression to the single abstract method.
Type Aliases vs. Fun Interfaces While type aliases can also provide a shorthand for function types, fun interface creates a distinct, nominal type.
Because fun interface is nominally typed, the compiler guarantees type safety by preventing implicit casting between identical function signatures that belong to different functional interfaces. Java Interoperability Kotlin automatically applies SAM conversion to Java interfaces that contain a single abstract method (e.g., Runnable, Callable). The fun interface construct exists specifically to enable this same lambda-instantiation behavior for interfaces defined natively in Kotlin.
Tired of Poor Kotlin Skills? Fix That With Deep Grasping!Learn More