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

ConditionalExpr resolves to wrong type #1743

Closed
kgeilmann opened this issue Aug 13, 2018 · 6 comments
Closed

ConditionalExpr resolves to wrong type #1743

kgeilmann opened this issue Aug 13, 2018 · 6 comments

Comments

@kgeilmann
Copy link
Contributor

The type solver always resolves conditional expressions to the type of the then part, which makes e.g. s == null ? null : s.toString() surprisingly being resolved to the null type instead of String.

@ftomassetti
Copy link
Member

The current implementation is wrong and the rules for implementing it correctly are far from trivial. There is a pretty significant part of the JLS discussing about this: https://docs.oracle.com/javase/specs/jls/se10/html/jls-15.html#jls-15.25

@jlerbsc
Copy link
Collaborator

jlerbsc commented Dec 16, 2020

Reference conditional expression refer to #2978

jlerbsc added a commit that referenced this issue Dec 17, 2020
Partially fix the issue #1743 ConditionalExpr resolves to wrong type
@jlerbsc
Copy link
Collaborator

jlerbsc commented Dec 17, 2020

This issue is resolved but we have to manage case of conditional reference expression and poly expression.

@jlerbsc
Copy link
Collaborator

jlerbsc commented Dec 28, 2020

Poly expression is resolved with PR #2994

jlerbsc added a commit that referenced this issue Dec 31, 2020
Partially fix issue #1743 ConditionalExpr resolves to wrong type - tr…
@jlerbsc
Copy link
Collaborator

jlerbsc commented Dec 31, 2020

TODO manage lub function (in TypeHelper.leastUpperBound) and update TypeExtractor.visit(ConditionalExpr node, Boolean solveLambdas) to manage reference conditional expression.

@jlerbsc
Copy link
Collaborator

jlerbsc commented Feb 3, 2023

Resolved in PR #3880

@jlerbsc jlerbsc closed this as completed Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants