Skip to content
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

Fix Resource access that are not ambiguous are reported as ambiguous access #43589

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

Conversation

gimantha
Copy link
Contributor

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues.

Fixes #40606

Approach

Describe how you are implementing the solutions along with the design details.

Samples

Provide high-level details about the samples related to this feature.

Remarks

List any other known issues, related PRs, TODO items, or any other notes related to the PR.

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@gimantha gimantha added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Nov 17, 2024
…emantic/api/test/actions/SymbolsInResourceAccessActionTest.java
Copy link

codecov bot commented Nov 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.56%. Comparing base (8f7fe10) to head (d0b026e).
Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #43589   +/-   ##
=========================================
  Coverage     77.55%   77.56%           
- Complexity    58742    58753   +11     
=========================================
  Files          3448     3448           
  Lines        219709   219735   +26     
  Branches      28915    28923    +8     
=========================================
+ Hits         170401   170430   +29     
+ Misses        39920    39909   -11     
- Partials       9388     9396    +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +4091 to +4093
Optional<BResourceFunction> first = resourceFunctions.stream().filter(func -> func.pathSegmentSymbols
.get(func.pathSegmentSymbols.size() - 1).kind == SymbolKind.RESOURCE_PATH_IDENTIFIER_SEGMENT)
.findFirst();
Copy link
Contributor

Choose a reason for hiding this comment

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

This will only handle the test case in the issue right? We need to handle the bellow cases as well
case1:

public client class SimpleClient {
    resource function get metadata/a() returns string {
        return "";
    }

    resource function get [string id]/a() returns string {
        return "";
    }
}

case2:

public client class SimpleClient {
    resource function get metadata/[string]() returns string {
        return "";
    }

    resource function get [string]/a() returns string {
        return "";
    }
}

sampleClient->/metadata/a; // which method to invoke. Should be give priority to first match in the path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Case 1 is handled by the fix. case 2 should be ambiguous, because both resource methods are candidates, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, 2nd is ambiguous. Case one wont work if we change the order of the resource methods

@rdulmina
Copy link
Contributor

public client class SimpleClient {
    resource function get [string]/a/[string]/c() returns string {
        return "";
    }
    resource function get metadata/[string]/b/c() returns string {
        return "";
    }

}
sampleClient->/metadata/a/b/c;

We need to think wether we give ambiguous error for this or not. Second resource method maches with three singleton types while first matches with only two. Hence should we pick the second from the compile time?

We also needs to add test to check wether the correct method is invoked and results are returned

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.

[Bug]: Resource access that are not ambiguous are reported as ambiguous access
2 participants