Skip to content

Populate type annotations to annotation map inline #44173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rdulmina
Copy link
Contributor

Purpose

$title

Fixes #44172

@rdulmina rdulmina requested review from Copilot, gimantha and chiranSachintha and removed request for hasithaa, sameerajayasoma, MaryamZi and gimantha June 16, 2025 06:37
@rdulmina rdulmina added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Jun 16, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR inlines type annotation mapping throughout the compiler, updates related tests, and refactors several analysis and desugaring components to propagate annotation creation more directly.

  • Updated unit tests to reflect new cyclic reference messages and moved compilation steps into setup methods.
  • Extended symbol collection (annotations, classes) in GlobalVariableRefAnalyzer and simplified dependency tracking in DataflowAnalyzer.
  • Refactored ConstantValueResolver, Desugar, and AnnotationDesugar to use inline annotation map invocations and block-based initialization.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/jballerina-unit-test/.../ForwardReferencingGlobalDefinitionTest.java Updated expected cyclic reference messages and positions
tests/jballerina-unit-test/.../AnnotationRuntimeTest.java Moved resultTwo compilation into @BeforeClass setup
compiler/ballerina-lang/.../GlobalVariableRefAnalyzer.java Added support for annotation and class symbols in cycle analysis
compiler/ballerina-lang/.../DataflowAnalyzer.java Simplified dependency recording; replaced manual calls with analyzeNode
compiler/ballerina-lang/.../ConstantValueResolver.java Removed unused pkgID field; updated record type def generation
compiler/ballerina-lang/.../Desugar.java Overloaded desugarTopLevelNodes to inline init-body building
compiler/ballerina-lang/.../AnnotationDesugar.java Changed defineTypeAnnotations/defineFunctionAnnotations signatures
Comments suppressed due to low confidence (1)

compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java:1613

  • The local variable fieldNames is declared without initialization and may be unassigned if the constructor’s type tag is not TABLE. This can lead to a compile error or unexpected behavior. Consider initializing it (e.g., List<String> fieldNames = new ArrayList<>();) or explicitly handling the non-TABLE case before returning.
List<String> fieldNames;

@rdulmina
Copy link
Contributor Author

NPE for

function checkClosuresWithObjectConstrExprInVarAssignment(int b1)  {
    final int a1 = 10;
    object {
        int a2;
        function foo(int b2);
    } obj1;

    obj1 = object {
        int a2 = b1;
        function foo(int b2)  {
            var obj2 = object {
                function bar() returns int {
                    return a1;
                }

            };

        }
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Populate type annotations to annotation map inline
1 participant