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

JSpecify: handle intersection type in one place #1015

Merged
merged 9 commits into from
Aug 19, 2024

Conversation

msridhar
Copy link
Collaborator

@msridhar msridhar commented Aug 7, 2024

Intersection types may arise, e.g., as part of string concatenation. We handling of an intersection type for one scenario; broader handling definitely requires more testing and thinking.

Fixes #1013

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.00%. Comparing base (b20df77) to head (5a8bdd6).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1015      +/-   ##
============================================
+ Coverage     85.98%   86.00%   +0.01%     
- Complexity     2080     2086       +6     
============================================
  Files            83       83              
  Lines          6892     6901       +9     
  Branches       1328     1329       +1     
============================================
+ Hits           5926     5935       +9     
  Misses          551      551              
  Partials        415      415              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@msridhar msridhar marked this pull request as draft August 7, 2024 00:41
@msridhar msridhar marked this pull request as ready for review August 7, 2024 17:20
@msridhar msridhar enabled auto-merge (squash) August 7, 2024 17:20
@msridhar msridhar added the jspecify Related to support for jspecify standard (see jspecify.dev) label Aug 17, 2024
Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minimal tests nit, we might want the corresponding testNegative1 and testNegative2 cases, assuming I understand what intersection types do correctly.

" var x = (A<String> & Serializable) o;",
" // BUG: Diagnostic contains: Cannot assign from type B to type A<String> & Serializable",
" x = new B();",
" }",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, the case where we have:

            "    var x = (A<@Nullable String> & Serializable) o;",
            "    x = new B();",

Should have no error, right? Should we encode that test case just to make sure we never regress that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, and i think we will get a false positive on that test for now (since for some reason var-declared variables don't get types with all the right annotations). i'll add tests and open an issue for outstanding tasks, but will fix in a subsequent PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5a8bdd6 along with link to issue #1022

@msridhar msridhar disabled auto-merge August 19, 2024 00:41
@msridhar msridhar enabled auto-merge (squash) August 19, 2024 17:23
@msridhar msridhar merged commit ab10020 into uber:master Aug 19, 2024
11 checks passed
@msridhar msridhar deleted the issue-1013 branch August 19, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jspecify Related to support for jspecify standard (see jspecify.dev)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSpecify: Another "Did not find supertype" crash, with Strings
2 participants