Repository navigation
Assert the @Nullable type argument inferred for a var diamond local - #2041
Conversation
uber#1708 made `var inferredFromInitializer = new Box<>(null);` infer `Box<@nullable Object>`, which fixed uber#1633. `GenericDiamondTests.varLocalDoesNotProvideTargetTypeForDiamondInference` only checked that the false `passing @nullable parameter` warning on that line is gone, so it would also pass with a non-null type argument. It now dereferences `inferredFromInitializer.get()` and expects `dereferenced expression 'inferredFromInitializer.get()' is @Nullable`. As a control, a `var` initialized with `new Box<>("x")` is dereferenced with no diagnostic. A `var` initialized with a conditional expression still gets no `@Nullable` type argument, with diamonds or with a generic method; uber#2038 tracks it. The TODO in `ConditionalExprTests.varConditionalDoesNotProvideTargetTypeForGenericMethodInference` linked uber#1633 for that case and now links uber#2038. `varConditionalDoesNotProvideTargetTypeForDiamondInference` lost its uber#1633 TODO in uber#1708 and asserted nothing about the inferred type; it now dereferences `inferredFromInitializer.get()` under the same TODO, so a fix for uber#2038 makes both tests fail at the dereference. Fixes uber#1633 Assisted-by: Claude Code (claude-opus-5-5)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe tests update a TODO reference from issue 1633 to issue 2038. They also add conditional-expression and diamond-inference checks for dereferencing values inferred from nullable and non-null constructor arguments. Possibly related issues
Suggested reviewers: Priority: ⬇️ Low Change: Other Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2041 +/- ##
=========================================
Coverage 89.15% 89.15%
Complexity 38 38
=========================================
Files 119 119
Lines 12721 12721
Branches 2578 2578
=========================================
Hits 11341 11341
Misses 623 623
Partials 757 757 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
#1708 made
var inferredFromInitializer = new Box<>(null);inferBox<@Nullable Object>, which fixed #1633.GenericDiamondTests.varLocalDoesNotProvideTargetTypeForDiamondInferenceonly checked that the falsepassing @Nullable parameterwarning on that line is gone, so it would also pass with a non-null type argument. It now dereferencesinferredFromInitializer.get()and expectsdereferenced expression 'inferredFromInitializer.get()' is @Nullable. As a control, avarinitialized withnew Box<>("x")is dereferenced with no diagnostic.A
varinitialized with a conditional expression still gets no@Nullabletype argument, with diamonds or with a generic method; #2038 tracks it. The TODO inConditionalExprTests.varConditionalDoesNotProvideTargetTypeForGenericMethodInferencelinked #1633 for that case and now links #2038.varConditionalDoesNotProvideTargetTypeForDiamondInferencelost its #1633 TODO in #1708 and asserted nothing about the inferred type; it now dereferencesinferredFromInitializer.get()under the same TODO, so a fix for #2038 makes both tests fail at the dereference.On a77c5fc^ (the commit before #1708), the strengthened diamond test fails with
Did not see an error on line 19 matching dereferenced expression 'inferredFromInitializer.get()' is @Nullable.Fixes #1633
🤖 Generated with Claude Code
Summary by CodeRabbit