Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

403
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda