You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "mariofusco (via GitHub)" <gi...@apache.org> on 2024/04/10 13:19:35 UTC

[PR] [KIE-1077] fix executable model generation with generics [incubator-kie-drools]

mariofusco opened a new pull request, #5836:
URL: https://github.com/apache/incubator-kie-drools/pull/5836

   Fixes https://github.com/apache/incubator-kie-issues/issues/1077


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KIE-1077] fix executable model generation with generics [incubator-kie-drools]

Posted by "mariofusco (via GitHub)" <gi...@apache.org>.
mariofusco merged PR #5836:
URL: https://github.com/apache/incubator-kie-drools/pull/5836


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KIE-1077] fix executable model generation with generics [incubator-kie-drools]

Posted by "mariofusco (via GitHub)" <gi...@apache.org>.
mariofusco commented on code in PR #5836:
URL: https://github.com/apache/incubator-kie-drools/pull/5836#discussion_r1559428184


##########
drools-util/src/main/java/org/drools/util/ClassUtils.java:
##########
@@ -597,11 +595,11 @@ public static Class<?> toRawClass(Type type) {
         if (type instanceof Class<?>) {
             return ( Class ) type;
         }
-        if (type instanceof ParameterizedType ) {
+        if (type instanceof ParameterizedType) {
             return toRawClass( (( ParameterizedType ) type).getRawType() );
         }
-        if (type instanceof TypeVariable ) {
-            return Object.class;
+        if (type instanceof TypeVariable typeVar) {
+            return typeVar.getBounds().length == 1 ? toRawClass(typeVar.getBounds()[0]) : Object.class;

Review Comment:
   This one-liner is the only actual fix. All other changes are refactors that I made to improve the code readability (and clarify to myself what was happening) while investigating this issue.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [KIE-1077] fix executable model generation with generics [incubator-kie-drools]

Posted by "lucamolteni (via GitHub)" <gi...@apache.org>.
lucamolteni commented on code in PR #5836:
URL: https://github.com/apache/incubator-kie-drools/pull/5836#discussion_r1559511963


##########
drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/GenericsTest.java:
##########
@@ -40,20 +40,20 @@ public void testGenericsAccumulateInlineCode() {
         // accumulate inline code supports generics
         String str =
                 "import " + Person.class.getCanonicalName() + ";\n" +
-                "import " + Address.class.getCanonicalName() + ";\n" +
-                "import " + List.class.getCanonicalName() + ";\n" +
-                "import " + ArrayList.class.getCanonicalName() + ";\n" +
-                "global List results;\n" +
-                "dialect \"mvel\"\n" +
-                "rule R when\n" +
-                "  $l : List() from accumulate (Person($addrList : addresses),\n" +
-                "         init( List<String> cityList = new ArrayList(); ),\n" +
-                "         action( for(Address addr: $addrList){String city = addr.getCity(); cityList.add(city);} ),\n" +
-                "         result( cityList )\n" +
-                "       )\n" +
-                "then\n" +
-                "  results.add($l);\n" +
-                "end";
+                        "import " + Address.class.getCanonicalName() + ";\n" +

Review Comment:
   Wrong formatting



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org