Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev reload ignores Kotlin compiler arguments #15418

Closed
TheKotlinDev opened this issue Mar 2, 2021 · 1 comment · Fixed by #15552
Closed

Dev reload ignores Kotlin compiler arguments #15418

TheKotlinDev opened this issue Mar 2, 2021 · 1 comment · Fixed by #15552
Assignees
Labels
area/kotlin env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@TheKotlinDev
Copy link

Describe the bug
When using Kotlin's Result type (which is somewhat experimental), you must pass an argument to the compiler to enable Result type to be returned by a function.

Argument required to enable Result return type: -Xallow-result-return-type

How to pass args to build tools

If using maven:

<plugin>
    <artifactId>kotlin-maven-plugin</artifactId>
    <configuration>
        <jvmTarget>1.8</jvmTarget>
        <args>
            <arg>-Xallow-result-return-type</arg>
        </args>
    </configuration>
    <groupId>org.jetbrains.kotlin</groupId>
    <version>${kotlin.version}</version>

If using gradle:

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
    kotlinOptions.freeCompilerArgs = ["-Xallow-result-return-type"]

}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
    kotlinOptions.freeCompilerArgs = ["-Xallow-result-return-type"]
}

Writing a simple hello world example using the Result type works on first compilation:

@Path("/hello")
class GreetingResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    fun hello4() = getAGreetingFailure().getOrDefault("Something went wrong")

    fun getAGreetingFailure(): Result<String> = kotlin.runCatching {
        throw Error("An Error")
    }
}

Expected behavior

  • When running in dev mode
  • When changing the string inside error (Error("Something else")) or making any other trivial change

Quarkus is able to "reload" the application and continue working as expected.

Actual behavior
(Describe the actual behavior clearly and concisely.)

On reload, instead of getting back "Something else" when hitting the /hello endpoint, I see compilation errors Kotlin.Result cannot be used as a return type

image

To Reproduce

Link to a small reproducer - https://github.com/MrMoner/kotlin-result-pattern-demo

Steps to reproduce the behavior:

  1. Hit localhost /hello in dev mode
  2. Make a trivial change to force reload
  3. Hit endpoint again

Environment (please complete the following information):

  • Output of ver: Microsoft Windows [Version 10.0.19041.844]
  • Output of java -version:
    openjdk version "11.0.10" 2021-01-19
    OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
  • Quarkus version: 1.12.0.Final
  • Build tool (ie. output of mvnw --version or gradlew --version): apache-maven-3.6.3
@TheKotlinDev TheKotlinDev added the kind/bug Something isn't working label Mar 2, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 2, 2021

/cc @evanchooly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kotlin env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants