Groovy
  1. Groovy
  2. GROOVY-4941

Static methods cannot be called during AST transformation via AstBuilder.buildFromSpec()

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ast builder
    • Labels:
      None
    • Environment:
      Groovy Version: 1.8.0/1.9-beta-1
    • Flags:
      Patch

      Description

      Static methods cannot be called during AST transformation via AstBuilder.buildFromSpec() because AstSpecificationCompiler.staticMethodCall() doesn't take a ClassNode object and if I try to call it with a Class object, I get "ClassNode#getTypeClass is called before the type class is set" error. I have no idea why the method takes a Class object instead.

      I attached a program to reproduce the error. Please unzip the Test.zip and run Main.groovy then you'll get the following error:


      Caught: BUG! exception in phase 'canonicalization' in source unit 'src\Main.groovy' ClassNode#getTypeClass for Clazz is called before the type class is set
      BUG! exception in phase 'canonicalization' in source unit 'src\Main.groovy' ClassNode#getTypeClass for Clazz is called before the type class is set
      at AnASTTransformation$_visit_closure1_closure2_closure3_closure4.doCall(AnASTTransformation.groovy:39)
      at AnASTTransformation$_visit_closure1_closure2_closure3_closure4.doCall(AnASTTransformation.groovy)
      at AnASTTransformation$_visit_closure1_closure2_closure3.doCall(AnASTTransformation.groovy:38)
      at AnASTTransformation$_visit_closure1_closure2_closure3.doCall(AnASTTransformation.groovy)
      at AnASTTransformation$_visit_closure1_closure2.doCall(AnASTTransformation.groovy:35)
      at AnASTTransformation$_visit_closure1_closure2.doCall(AnASTTransformation.groovy)
      at AnASTTransformation$_visit_closure1.doCall(AnASTTransformation.groovy:34)
      at AnASTTransformation$_visit_closure1.doCall(AnASTTransformation.groovy)
      at AnASTTransformation.visit(AnASTTransformation.groovy:33)


      I also attached a patch for the trunk to add a version that takes a ClassNode object.

      1. patch
        0.9 kB
        Masato Nagai
      2. Test.zip
        1 kB
        Masato Nagai

        Activity

        Masato Nagai created issue -
        Guillaume Delcroix made changes -
        Field Original Value New Value
        Assignee Guillaume Laforge [ guillaume ] Hamlet D'Arcy [ hamletdrc ]
        Pascal Schumacher made changes -
        Assignee Hamlet D'Arcy [ hamletdrc ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733867 ] Default workflow, editable Closed status [ 12745665 ]
        Mark Thomas made changes -
        Patch Submitted Yes [ 10763 ]
        Flags Patch [ 10430 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12967639 ] Default workflow, editable Closed status [ 12975377 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Masato Nagai
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development