ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

[Bug]: The `typeOf` API returns a `TypeDescriptorTypeSymbol` instead of an `IntersectionTypeSymbol` for a narrowed variable

Open nipunayf opened this issue 1 year ago • 0 comments

Description

With the change made by https://github.com/ballerina-platform/ballerina-lang/pull/39585, the type of a narrowed symbol should be an intersection type rather than its effective type.

Steps to Reproduce

Use the typeOf API on the node covered by the following cursor positions.

function test() {
    readonly & Person|int person = {name: "A", age: 0};
    if person is int {
        return;
    }
    _ = <START>person<END>.entries();
}

Affected Version(s)

Ballerina 2201.9.0 (Swan Lake Update 9)

OS, DB, other environment details and versions

OS: macOS 14.4.1 23E224 JDK: openjdk 20.0.2 2023-07-18

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

nipunayf avatar May 03 '24 06:05 nipunayf