Repository: quarkusio/quarkus
Issue: Iterating over a list of enums generated by Qute Namespace Extensions no longer works

### Describe the bug

We leverage Qute Namespace extensions to populate a list or dropdown with values from an enum. See https://quarkus.io/version/main/guides/qute-reference#namespace_extension_methods

```java
public enum State {
    OPEN("Open"), CLOSED("Closed");

    private final String displayName;

    State(String displayName) {
        this.displayName = displayName;
    }

    public String getDisplayName() {
        return displayName;
    }
}
```

```java
@TemplateExtension(namespace = "domain")
public static class DomainExtensions {

    static Set<State> states() {
        return EnumSet.allOf(State.class);
    }
}
```

```html
<ul>
    {#for state in domain:states}
        <li>{state.displayName}</li>
    {/for}
</ul>
```

However this now results in an exception, also when we use checked templates.


```
[1] Incorrect expression found: {state.displayName}
	- property/method [displayName] not found on class [java.util.Set<nl.wjglerum.SomePage$State>] nor handled by an extension method
	- at page.qute.html:31
	at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:186)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:829)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
	Suppressed: io.quarkus.qute.TemplateException: Incorrect expression found: {state.displayName}
	- property/method [displayName] not found on class [java.util.Set<nl.wjglerum.SomePage$State>] nor handled by an extension method
	- at page.qute.html:31
		at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:166)
		... 11 more
```

It does work correctly when you just want to render the enums, but as soon as you call a property from the enum it fails. It looks like Qute incorrectly tries to find this (virtual) method on the Set or List instance instead of the enum in the collection.

This used to work up until version 2.4.0.CR1 but just failed on the latest snapshot build from the main branch.

### Expected behavior

_No response_

### Actual behavior

_No response_

### How to Reproduce?

_No response_

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

_No response_

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information
Sample project:
[quarkus-qute-enum.zip](https://github.com/quarkusio/quarkus/files/7417590/quarkus-qute-enum.zip)
 

Changed files:
extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java
extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java

diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java
index 796acb8de6c..c9c68d7c169 100644
--- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java
+++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java
@@ -674,6 +674,15 @@ static Match validateNestedExpressions(TemplateAnalysis templateAnalysis, ClassI
                 ClassInfo returnType = index.getClassByName(method.returnType().name());
                 if (returnType != null) {
                     match.setValues(returnType, method.returnType());
+                    if (root.hasHints()) {
+                        // Root is a property with hint
+                        // E.g. 'it<loop#123>' and 'STATUS<when#123>'
+                        if (processHints(templateAnalysis, root.asHintInfo().hints, match, index, expression,
+                                generatedIdsToMatches, incorrectExpressions)) {
+                            // In some cases it's necessary to reset the iterator
+                            iterator = parts.iterator();
+                        }
+                    }
                 } else {
                     // Return type not available
                     return putResult(match, results, expression);
diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java
index 4e0525f6f58..35d7d921239 100644
--- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java
+++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java
@@ -3,10 +3,14 @@
 import static io.quarkus.qute.TemplateExtension.ANY;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+import java.util.EnumSet;
+import java.util.Set;
+
 import javax.enterprise.event.TransactionPhase;
 import javax.inject.Inject;
 
 import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -20,6 +24,9 @@ public class NamespaceTemplateExtensionTest {
     @RegisterExtension
     static final QuarkusUnitTest config = new QuarkusUnitTest()
             .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
+                    .addAsResource(new StringAsset(
+                            "{#for state in domain:states}{state.foo}{/for}"),
+                            "templates/foo.html")
                     .addClasses(StringExtensions.class, MyEnum.class, EnumExtensions.class));
 
     @Inject
@@ -43,6 +50,8 @@ public void testTemplateExtensions() {
                 engine.parse("{str:quark}").render());
         assertEquals("QUARKUS!",
                 engine.parse("{str:quarkus}").render());
+        assertEquals("openclosed",
+                engine.getTemplate("foo").render());
     }
 
     @TemplateExtension(namespace = "str")
@@ -73,9 +82,17 @@ static String quarkAny(String key) {
     }
 
     public enum MyEnum {
-
         ONE,
         TWO
+    }
+
+    public enum State {
+        OPEN,
+        CLOSED;
+
+        public String getFoo() {
+            return toString().toLowerCase();
+        }
 
     }
 
@@ -91,6 +108,11 @@ static TransactionPhase enumValue(String value) {
             return TransactionPhase.valueOf(value);
         }
 
+        @TemplateExtension(namespace = "domain")
+        static Set<State> states() {
+            return EnumSet.allOf(State.class);
+        }
+
     }
 
 }