Skip to content

Commit

Permalink
Merge pull request #20515 from mkouba/issue-20512
Browse files Browse the repository at this point in the history
Qute type-safe validation fix
  • Loading branch information
mkouba authored Oct 4, 2021
2 parents 14f8aa8 + 25793af commit 597f550
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,7 @@ private static TemplateExtensionMethodBuildItem findTemplateExtensionMethod(Info
private static AnnotationTarget findProperty(String name, ClassInfo clazz, IndexView index) {
Set<DotName> interfaceNames = new HashSet<>();
while (clazz != null) {
addInterfaces(clazz, index, interfaceNames);
interfaceNames.addAll(clazz.interfaceNames());
// Fields
for (FieldInfo field : clazz.fields()) {
Expand Down Expand Up @@ -1756,6 +1757,19 @@ private static AnnotationTarget findProperty(String name, ClassInfo clazz, Index
return null;
}

private static void addInterfaces(ClassInfo clazz, IndexView index, Set<DotName> interfaceNames) {
if (clazz == null) {
return;
}
List<DotName> names = clazz.interfaceNames();
if (!names.isEmpty()) {
interfaceNames.addAll(names);
for (DotName name : names) {
addInterfaces(index.getClassByName(name), index, interfaceNames);
}
}
}

/**
* Find a non-static non-synthetic method with the given name, matching number of params and assignable parameter types.
*
Expand All @@ -1771,7 +1785,7 @@ private static AnnotationTarget findMethod(VirtualMethodPart virtualMethod, Clas
IndexView index, Function<String, String> templateIdToPathFun, Map<String, Match> results) {
Set<DotName> interfaceNames = new HashSet<>();
while (clazz != null) {
interfaceNames.addAll(clazz.interfaceNames());
addInterfaces(clazz, index, interfaceNames);
for (MethodInfo method : clazz.methods()) {
if (Modifier.isPublic(method.flags()) && !Modifier.isStatic(method.flags())
&& !ValueResolverGenerator.isSynthetic(method.flags())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class InterfaceValidationSuccessTest {
@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(Metrics.class, Count.class, Wrapper.class)
.addClasses(Metrics.class, Count.class, Wrapper.class, NumericWrapper.class)
.addAsResource(new StringAsset("{@java.util.List list}"
+ "{list.empty}:{list.toString}"),
"templates/list.html")
Expand Down Expand Up @@ -76,7 +76,10 @@ public interface Wrapper<T> {
String name(int age);
}

public interface Count extends Wrapper<Integer> {
public interface NumericWrapper extends Wrapper<Integer> {
}

public interface Count extends NumericWrapper {
}

public interface Metrics {
Expand Down

0 comments on commit 597f550

Please sign in to comment.