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

Use wildcards for least upper bound of two lists #286

Open
3 tasks
MeAmAnUsername opened this issue Apr 8, 2022 · 0 comments
Open
3 tasks

Use wildcards for least upper bound of two lists #286

MeAmAnUsername opened this issue Apr 8, 2022 · 0 comments
Labels
Component: code generation Something that concerns the generated code Component: DSL Something that concerns the design of PIE DSL Priority: medium Status: specified Enhancement that is ready to implement Type: bug Something isn't working Type: enhancement New feature or request

Comments

@MeAmAnUsername
Copy link
Owner

MeAmAnUsername commented Apr 8, 2022

Summary
Use a list of upperbounded wildcard as least upper bound for two lists: val res: (_ <: Fruit)* = if(flag) apples else bananas

Todo

  • Write tests
    • At least one test for where the resulting element type is the top type
  • Implement

Reason
It currently uses a list of toptype, but that is less precise than a list of an upperbounded wildcard. It may actually be incorrect too It is also incorrect: if(true) [0] else ["zero"] generates invalid Java code, as it tries to make the assignment ArrayList<Object> obj = ArrayList<Integer>

Description
In case the least upper bound of the element types is toptype, just use a list of toptype (as it does now) instead of a list of a wildcard upperbounded by toptype, if that is possible (see possible incorrectness in reason above). just use a list of wildcards instead: ArrayList<?>

Implementation
Least upper bound of X* and Y* becomes (_ <: lub(X, Y))*, unless lub(X, Y) == TopType(), then it becomes (_)*

Related issues
None?

@MeAmAnUsername MeAmAnUsername added Type: bug Something isn't working Type: enhancement New feature or request Status: specified Enhancement that is ready to implement Component: DSL Something that concerns the design of PIE DSL Component: code generation Something that concerns the generated code Priority: medium labels Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: code generation Something that concerns the generated code Component: DSL Something that concerns the design of PIE DSL Priority: medium Status: specified Enhancement that is ready to implement Type: bug Something isn't working Type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant