Skip to content

Commit

Permalink
Merge pull request #43653 from mkouba/issue-43489-next
Browse files Browse the repository at this point in the history
Qute: fix generated ValueResolver for default methods with params
  • Loading branch information
mkouba authored Oct 2, 2024
2 parents c01bf2c + fdd1ae4 commit b208ba2
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 b208ba2

Please sign in to comment.