How to allow Result<T> to be return type in Kotlin?

1k Views Asked by At

I researched an error Why can't 'kotlin.Result' be used as a return type? and want to enable it by -Xallow-result-return-type.

I use kotlin-maven-plugin and my pom.xml build section:

<build>
    <plugins>
        <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <configuration>
                <jvmTarget>1.8</jvmTarget>
                <!-- Possible solution in order to return Result<T> type bypassing Kotlin developers recommendations -->
                <args>
                    <arg>-Xallow-result-return-type</arg>
                </args>
            </configuration>
        </plugin>
    </plugins>
</build>

As far as I checked kotlin-maven-plugin docs there is no such an option.

The error I am getting is

Kotlin: 'kotlin.Result' cannot be used as a return type

Am I doing anything wrong? How to enable Result<T> as a return type?

0

There are 0 best solutions below