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

[Bug]: CloneWithType throws conversion error with union type #41930

Closed
chiranSachintha opened this issue Jan 4, 2024 · 0 comments · Fixed by #41937
Closed

[Bug]: CloneWithType throws conversion error with union type #41930

chiranSachintha opened this issue Jan 4, 2024 · 0 comments · Fixed by #41937
Assignees
Labels
Priority/Blocker Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Milestone

Comments

@chiranSachintha
Copy link
Member

Description

import ballerina/io;
import ballerinax/health.fhir.r4;

public type Extension r4:CodeableConceptExtension | r4:ExtensionExtension|r4:CodingExtension;


public function main() returns error? {
    json extCoding = {
        "valueCoding": {
            "system": "http://loinc.org",
            "code": "LA29518-0",
            "display": "he/him/his/himself"
        },
        "url": "http://open.epic.com/FHIR/StructureDefinition/extension/calculated-pronouns-to-use-for-text"
    };

    Extension ext = check extCoding.cloneWithType();
    io:print(ext);
}

The above program return error as

error: {ballerina/lang.value}ConversionError {"message":"'map<json>' value cannot be converted to 'health.fhir.r4:Element': 
                value of field 'system' adding to the record 'health.fhir.r4:Element' should be of type 'health.fhir.r4:Element', found '"http://loinc.org"'
                value of field 'code' adding to the record 'health.fhir.r4:Element' should be of type 'health.fhir.r4:Element', found '"LA29518-0"'
                value of field 'display' adding to the record 'health.fhir.r4:Element' should be of type 'health.fhir.r4:Element', found '"he/him/his/himself"'"}

When we change the type as

public type Extension r4:CodingExtension|r4:CodeableConceptExtension | r4:ExtensionExtension;

The above program works fine.

The issue arises when selecting a convertible type for extCoding variable.

Type convertibleType = TypeConverter.getConvertibleType(value, targetType,

This works in version 2201.7.0 but gives error in version 2201.8.4.

Steps to Reproduce

No response

Affected Version(s)

2201.8.4

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority/Blocker Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants