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

GROOVY-7971: @CS flow typing incorrectly casting to map at runtime #1293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

paulk-asert
Copy link
Contributor

No description provided.

@eric-milles
Copy link
Member

eric-milles commented Jun 29, 2020

Does this change accommodate checking instanceof under a ternary expression or as part of a larger boolean expression?

int m(o) {
  (o instanceof List || o instanceof Map ? o.size() : 1)
}
// or
def x = (o instanceof List || o instanceof Map) && o.isEmpty()

#1269 is not specific to if/else, but as you noted is more restrictive.

Does this change fix the runtime cast exception of your Deque vs. Stack example under static compilation?

@paulk-asert
Copy link
Contributor Author

@eric-milles No, those cases aren't covered but the if case is. The Stack/Deque case is one of the test cases. The full solution I think will require us to push through Union and Intersection types (though I don't like those names) throughout. I started doing that but never finished. There are lots of hidden assumptions about the current approach throughout the codebase and will take some time. I see this as fixing up a common case while we work longer on the more complete solution. With the if in place, I believe we could have workarounds for the other cases. We could target them as special cases too but it makes the codebase messier the more of these hacks we have.

@daniellansun
Copy link
Contributor

PR #1269 or PR #1293 ?

@daniellansun
Copy link
Contributor

daniellansun commented Jul 4, 2020

The PR seems to break Grails joint build:
https://github.com/apache/groovy/runs/836663285?check_suite_focus=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants