Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5641

Compilation fails when chaining methods with function calls as params

    Details

    • Type: Bug
    • Status: Pull Request Sent (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 7.43.0.Final
    • Fix Version/s: None
    • Component/s: executable model
    • Labels:
      None

      Description

      Given the following rule:

      global java.util.Set controlSet;
      global org.example.drools.service.DummyService dummyService;
      
      declare A
       x: String
      end
      
      rule "will execute per each Measurement having ID color"
      no-loop
      when
       $m: Measurement( id == "color", $colorVal : val )
       $a: A()
       String() from dummyService.dummy($m.getSomethingBy($a.x), $a)
      then
       controlSet.add($colorVal);
      end

       

      The compilation fails with:

      [...]/target/generated-sources/drools-model-compiler/main/java/rules/Rules7ad4e52deb9d4184b7d7e4646c172273RuleMethods0.java:[27,111] no suitable method found for from(org.drools.model.Global<org.example.drools.service.DummyService>,org.drools.model.Variable<rules.A>,org.drools.model.Variable<org.example.drools.model.Measurement>,rules.P45.LambdaExtractor4580D2619F79AA1C0CC3F15809293690)
      [ERROR] method org.drools.model.DSL.<T>from(T) is not applicable
      [ERROR] (cannot infer type-variable(s) T
      [ERROR] (actual and formal argument lists differ in length))
      [ERROR] method org.drools.model.DSL.<T>from(org.drools.model.Variable<T>) is not applicable
      [ERROR] (cannot infer type-variable(s) T
      [ERROR] (actual and formal argument lists differ in length))
      [ERROR] method org.drools.model.DSL.<T>from(org.drools.model.functions.Function0<T>) is not applicable
      [ERROR] (cannot infer type-variable(s) T
      [ERROR] (actual and formal argument lists differ in length))
      [ERROR] method org.drools.model.DSL.<T>from(org.drools.model.Variable<T>,org.drools.model.functions.Function1<T,?>) is not applicable
      [ERROR] (cannot infer type-variable(s) T
      [ERROR] (actual and formal argument lists differ in length))
      [ERROR] method org.drools.model.DSL.<A,B>from(org.drools.model.Variable<A>,org.drools.model.Variable<B>,org.drools.model.functions.Function2<A,B,?>) is not applicable
      [ERROR] (cannot infer type-variable(s) A,B
      [ERROR] (actual and formal argument lists differ in length))
      [ERROR] method org.drools.model.DSL.<A,B,C>from(org.drools.model.Variable<A>,org.drools.model.Variable<B>,org.drools.model.Variable<C>,org.drools.model.functions.Function3<A,B,C,?>) is not applicable
      [ERROR] (inference variable B has incompatible equality constraints org.example.drools.model.Measurement,rules.A)
      [ERROR] method org.drools.model.DSL.<A,B,C,D>from(org.drools.model.Variable<A>,org.drools.model.Variable<B>,org.drools.model.Variable<C>,org.drools.model.Variable<D>,org.drools.model.functions.Function4<A,B,C,D,?>) is not applicable
      [ERROR] (cannot infer type-variable(s) A,B,C,D
      [ERROR] (actual and formal argument lists differ in length))

       

      This error is reproducible with the latest 7.44.0-SNAPSHOT .

      The parameters are flipped between the LambdaExtractor and the RuleMethods generated classes.

       

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                lucamolteni Luca Molteni
                Reporter:
                cchiru Ciprian Chiru
              • Votes:
                6 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: