Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

399
Views
Kotlin @FunctionalInterface compiles with multiple abstract methods

When trying to compile a Java @FunctionalInterface having more than 1 non-abstract method a compilation error is raised.

However, when doing the same in Kotlin, no errors or warnings are raised, i.e. the following Kotlin interface compiles successfully:

@FunctionalInterface
interface Foo {
    fun foo()
    fun foo(params: Map<String, String>)
}

Is this the intended behaviour or a bug in the Kotlin compiler?

Please note that the generated bytecode for the above Kotlin snippet is equivalent to the following Java snippet (which – correctly – doesn't compile):

@FunctionalInterface
// metadata omitted
public interface Foo {
   void foo();
   void foo(@NotNull Map var1);
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Issue KT-25512 has been submitted to JetBrains's issue tracker (by another user) to report the fact that the compiler misbehaves when @FunctionalInterface is applied to a non-SAM interface, and as of 10 Feb 2019 the issue is still open with no activity.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!