Skip to content

Unboxing crash tests; move unboxing helpers to TypesUtils - #79

Merged
msridhar merged 2 commits into
msridhar:fix-8328-unboxingfrom
mernst:fix-8328-unboxing-crash-tests
Oct 8, 2026
Merged

msridhar merged 2 commits into
msridhar:fix-8328-unboxingfrom
mernst:fix-8328-unboxing-crash-tests

Conversation

@mernst

@mernst mernst commented Oct 8, 2026

Copy link
Copy Markdown

This PR is for typetools#8329.

  • Adds two regression tests that crash on this branch (and on master):

    • framework/tests/all-systems/TypeVarPrimitives.java: compound boolean assignment (x &= t, x |= t, x ^= t) where T extends Boolean. CFGTranslationPhaseOne.visitCompoundAssignment throws "Both arguments to logical operation must be numeric or boolean".
    • framework/tests/all-systems/TypeVarArrayDimension.java: new int[t] where T extends Integer. ValueTreeAnnotator.handleDimensions throws "Unexpected null argument: compareByName(null, @BottomVal)". This test is in its own file so that the crash above does not mask it.

    These tests fail until those two crashes are fixed.

  • Moves the unboxing helpers out of CFGTranslationPhaseOne into TypesUtils (boxedPrimitiveForUnboxing, isUnboxable, unboxedTypeOrSelf), and uses them in TreeBuilder.buildPrimValueMethodAccess, TypesUtils.canBeNarrowingPrimitiveConversion, narrowAndBox, conversionRequiresNarrowing, and conditionalExprPromotion.

  • Removes duplicated isUnboxable(t) ? unboxedTypeOf(t) : t logic, and renames TreeInfo.isBoxed and local variables named isBoxedPrimitive/isRightBoxed to reflect that they are also true for type variables.

  • Erases a type only if it is a type variable or intersection type, and at most once per query, rather than on every assignment and argument conversion.

mernst added 2 commits October 8, 2026 09:21
Erase only type variables and intersection types, and erase at most once
per query.
@msridhar
msridhar merged commit 2111b3b into msridhar:fix-8328-unboxing Oct 8, 2026
20 of 25 checks passed
@msridhar

msridhar commented Oct 8, 2026

Copy link
Copy Markdown
Owner

@mernst I've invited you as a collaborator on this repo, so you can just push directly to the branch if you like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants