Affects: Spring Boot JPA v 2.6.4

There appears to be a compiler issue when attempting to override interface methods with Spring for a Kotlin class using delegation. I cannot reproduce the issue with pure Kotlin interfaces so guessing it's something to do with the Spring plugins.

Brief overview below. Full repro here

package kotlincompilerbug

import org.springframework.data.jpa.repository.JpaRepository
import java.util.*

interface SomeRepo : JpaRepository<String, Long>

class ConcreteImplWithOverrides(val springGeneratedSomeRepoImpl: SomeRepo) : SomeRepo by springGeneratedSomeRepoImpl {

    // This is allowed by the compiler
    override fun <S : String?> save(entity: S): S { TODO("Not yet implemented") }

    // This fails to compile
    // Conflicting overloads: public open fun findById(id: Long): Optional<String> defined in ConcreteImplWithOverrides,
    // public open fun findById(id: Long): Optional<String!> defined in ConcreteImplWithOverrides
    override fun findById(id: Long): Optional<String> { TODO("Not yet implemented") }
}

Comment From: sdeleuze

Compiler plugins, including Spring one, are maintained by Kotlin team, so this should likely be raised on their side with your repro.