RFR: JDK-8193367: Annotated type variable bounds crash javac

B. Blaser bsrbnd at gmail.com
Thu Jan 24 15:49:36 UTC 2019


On Thu, 24 Jan 2019 at 15:30, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
>
> I'm a bit confused (but it could also be because I'm misremembering) - wasn't the whole point of the exercise to have cloned type variables to piggy back on the clonee's getUpperBound?
>
> In the patch I see this:
>
> @Override
> 1640         public TypeVar cloneWithMetadata(TypeMetadata md) {
> 1641             return new TypeVar(tsym, getUpperBound(), lower, md) {
> 1642                 @Override
> 1643                 public Type baseType() { return TypeVar.this.baseType(); }
> 1644             };
> 1645         }
>
>
> Which doesn't seem better than the current code - e.g. the upper bound is fetched when the cloned var is created, so, if the bound is updated after the fact, such changes will not be reflected in the clones var?

The current getUpperBound() sets the clone's bound to the clonee's
bound (tsym.type.getUpperBound()) at every invocation while still
unset (null or tag=NONE):

http://hg.openjdk.java.net/jdk/jdk/file/525f212f1bda/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java#l1659

which is exactly what we need in our issue (see Types::getBounds).
Overriding the accessor in cloneWithMetadata() is then no more
necessary.

This fixes the issue and tests are clean.

Do we agree?

Bernard


More information about the compiler-dev mailing list