Skip to content

Commit

Permalink
Qute: fix generated ValueResolver for default methods with params
Browse files Browse the repository at this point in the history
- follows up on quarkusio#43602
  • Loading branch information
mkouba committed Oct 2, 2024
1 parent a4fcec1 commit fdd1ae4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
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

0 comments on commit fdd1ae4

Please sign in to comment.