ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.54k stars 733 forks source link

[Bug]: Incorrect `Create variable with type` code actions are generated for external function bodies with non-error return types #42621

Open nipunayf opened 2 weeks ago

nipunayf commented 2 weeks ago

Description

$title. We cannot break a union return type into multiple code actions as we do with dependable types. There should be only one code action representing the final return type, i.e string|int|boolean|error.

image

Steps to Reproduce

Prompt code actions for the following cursor position.

client class MyClient {
    resource function get albums/[string id](typedesc<string> targetType = <>)
        returns targetType|int|boolean|error = external;
}

function name() {
    MyClient myCl = new;
    <CURSOR>myCl->/albums/["path"]();
}

Affected Version(s)

Ballerina 2201.8.6 (Swan Lake Update 8)

OS, DB, other environment details and versions

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

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response