Skip to content

[BUG] Compilation order with explicit mappings #240

@thomaslhostis

Description

@thomaslhostis

Describe the bug
When defining two mappers, the first one is defined explicitly and overrides the map function, and the second one uses the first one implicitly, if those two mappers are defined in different files and I modify the second mapper, then I get a compilation error.

To Reproduce
Full example here: https://github.com/thomaslhostis/mappie-compile-issue

Two data classes:

class Range(
    val startsOn: java.time.LocalDate,
    val endsOn: java.time.LocalDate,
)
class RangeResource(
    val startsOn: kotlinx.datetime.LocalDate,
    val endsOn: kotlinx.datetime.LocalDate,
)

First mapper (JavaToKotlinLocalDateMapper.kt):

object JavaToKotlinLocalDateMapper : ObjectMappie<java.time.LocalDate, kotlinx.datetime.LocalDate>() {
    override fun map(from: java.time.LocalDate) = from.toKotlinLocalDate()
}

Second mapper (RangeMapper.kt):

object RangeMapper : ObjectMappie<Range, RangeResource>()

When I modify the file RangeMapper.kt without modifying JavaToKotlinLocalDateMapper.kt, I get a compilation error. If I modify the file JavaToKotlinLocalDateMapper.kt after RangeMapper.kt, I don't get any error.

Expected behavior
Should compile no matter the order of modification of the files.

Kotlin version
2.2.0

Mappie version
1.4.1

Mappie and Kotlin compatibility
Yes

Invocation method
Gradle

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions