Skip to content

Commit

Permalink
Avoid combining a regular type bound with a ClassObject location in VP
Browse files Browse the repository at this point in the history
...as the intersection of the two constraints. If the type is not
already known to be a ClassObject, then bundling it into a VPClass with
a ClassObject location will incorrectly change the meaning of the type
constraint.
  • Loading branch information
jdmpapin committed Oct 15, 2021
1 parent 85d2e95 commit d4ba4d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compiler/optimizer/VPConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2951,6 +2951,15 @@ TR::VPConstraint *TR::VPClassType::typeIntersectLocation(
if (!location) return NULL;
}

if (location->isClassObject() == TR_yes && classObject != TR_yes)
{
// Bundling this (the type constraint) with location into a VPClass would
// change the meaning of the type. Alone, this represents the type of the
// constrained value, but combined with location, it would instead be
// interpreted as the type represented by the constrained value.
return location;
}

return TR::VPClass::create(vp, this, NULL, NULL, NULL, location);
}

Expand Down

0 comments on commit d4ba4d4

Please sign in to comment.