Kotlin class inherit java class. But kotlin compiler say type mismatch

Hi, I am clone coding The Definitive Guide to Spring Batch using kotlin. But I faced a problem about covariant. When I build step by StepBuilder, kotlin compiler say Type mismatch. Required: ItemReader<out Customer!> Found: CustomerFileReader.

fun customerItemReader(
    @Value("#{jobParameters['customerFile']}") inputFile: Resource?
): FlatFileItemReader<Any> {
    return FlatFileItemReaderBuilder<Any>()

fun customerFileReader(): CustomerFileReader {
    return CustomerFileReader(customerItemReader(null))

fun copyFileStep(): Step {
    return stepBuilderFactory["copyFileStep"]
        .chunk<Customer, Customer>(10) // I don't want change this to chunk<Customer, Customer>(10)
        .reader(customerFileReader()) // This line has problem about covariant
class CustomerFileReader(
    private val delegate: ItemStreamReader<Any>
) : ItemStreamReader<Customer> {

    override fun read(): Customer? {
        if (curItem == null)
            curItem = delegate.read()

        var item = curItem as Customer?
        curItem = null

        if (item != null) {
            item.transactions = mutableListOf()

            while (peek() is Transaction) {
                item.transactions.add(curItem as Transaction)
                curItem = null
        return item

I thought that CustomerFileReader is subtype of ItemReader<out Customer!>. Let me know why compilation error occur and how to solve this problem.
Thank you!

Github link

Sorry, It’s not problem about covariant. I just import Customer class in different package. :joy: