Skip to content

[BUG] fromExpression non-nullable return value handling #246

Description

@Janiaje

Describe the bug
Mappie des not recognise if I provided a default for a nullable field when assigning to a non nullable field.

To Reproduce
Mapping:

to::createdAt fromExpression { it.createdAt ?: now() }

Exception

Target ToClass::createdAt of type LocalDateTime cannot be assigned from expression of type @FlexibleNullability LocalDateTime?

Operational workaround:

to::createdAt fromExpression { (it.createdAt ?: now()) as LocalDateTime }

Expected behavior
Mappie recognises if an expression's return value is not nullable

Kotlin version
2.2.10

Mappie version
2.2.10-1.4.2

Mappie and Kotlin compatibility
Is the Mappie version compatible with the Kotlin version?
Yes

Invocation method
The method of invocation, i.e. Gradle, Maven or CLI.
Gradle

Additional context
Add any other context about the problem here.

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