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

Qute: fix generated ValueResolver for default methods with params #43653

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -707,15 +707,15 @@ private void matchMethod(MethodInfo method, ClassInfo clazz, MethodCreator resol
}

if (Modifier.isStatic(method.flags())) {
if (Modifier.isInterface(clazz.flags())) {
if (Modifier.isInterface(method.declaringClass().flags())) {
tryCatch.assign(invokeRet,
tryCatch.invokeStaticInterfaceMethod(MethodDescriptor.of(method), realParamsHandle));
} else {
tryCatch.assign(invokeRet,
tryCatch.invokeStaticMethod(MethodDescriptor.of(method), realParamsHandle));
}
} else {
if (Modifier.isInterface(clazz.flags())) {
if (Modifier.isInterface(method.declaringClass().flags())) {
tryCatch.assign(invokeRet,
tryCatch.invokeInterfaceMethod(MethodDescriptor.of(method), whenBase, realParamsHandle));
} else {
Expand Down Expand Up @@ -853,15 +853,15 @@ private void matchMethods(String matchName, int matchParamsCount, Collection<Met
}

if (Modifier.isStatic(method.flags())) {
if (Modifier.isInterface(clazz.flags())) {
if (Modifier.isInterface(method.declaringClass().flags())) {
tryCatch.assign(invokeRet,
tryCatch.invokeStaticInterfaceMethod(MethodDescriptor.of(method), realParamsHandle));
} else {
tryCatch.assign(invokeRet,
tryCatch.invokeStaticMethod(MethodDescriptor.of(method), realParamsHandle));
}
} else {
if (Modifier.isInterface(clazz.flags())) {
if (Modifier.isInterface(method.declaringClass().flags())) {
tryCatch.assign(invokeRet,
tryCatch.invokeInterfaceMethod(MethodDescriptor.of(method), whenBase, realParamsHandle));
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.quarkus.it.qute;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
Expand All @@ -13,10 +16,10 @@ public class DefaultMethodResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public TemplateInstance get() {
return new hello(new Name());
return new hello(new Name(), LocalDateTime.now(), ZoneOffset.UTC);
}

record hello(Name name) implements TemplateInstance {
record hello(Name name, LocalDateTime time, ZoneOffset zoneOffset) implements TemplateInstance {
};

public static class Name implements Something {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Hello {name.fullName}!
Hello {name.fullName} at {time.toInstant(zoneOffset)}!
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void testTemplates() throws InterruptedException {
.contentType(is(ContentType.HTML.toString()))
.body(containsString("Hello Ciri!"));
RestAssured.when().get("/beer").then().body(containsString("Beer Pilsner, completed: true, done: true"));
RestAssured.when().get("/defaultmethod").then().body(containsString("Hello MK!"));
RestAssured.when().get("/defaultmethod").then().body(containsString("Hello MK"));
}

@Test
Expand Down