[lworld] RFR: Make "PrimitiveParameterizedClass.default" a poly expression. [v5]
Srikanth Adayapalam
sadayapalam at openjdk.java.net
Mon Aug 2 11:44:50 UTC 2021
On Mon, 2 Aug 2021 11:07:20 GMT, Srikanth Adayapalam <sadayapalam at openjdk.org> wrote:
>> Jesper Steen Møller has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Whitespace
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java line 295:
>
>> 293: case TYPEAPPLY: return (JCTypeApply)tree;
>> 294: case NEWCLASS: return getTypeApplication(((JCNewClass)tree).clazz);
>> 295: case ANNOTATED_TYPE: return getTypeApplication(((JCAnnotatedType)tree).underlyingType);
>
> I think there is a copy + paste problem. We can never see a NEWCLASS here. The LHS of .default is just a type node and cannot be an rvalue expression ==> new X().default is illegal.
I think perhaps what we really need to do here is to attribute the clazz node of JCDefaultValue first - perhaps by first making a copy of the node and then see if it is a generic class but lacks type arguments. Such as this:
@Override
public void visitDefaultValue(JCDefaultValue that) {
JCExpression copy = new TreeCopier<Void>(attr.make).copy(that.clazz);
attr.attribType(copy, env);
if (copy.type.getTypeArguments().isEmpty() && copy.type.tsym.type.isParameterized()) {
processArg(that, speculativeTree -> new ResolvedDefaultType(that, env, speculativeTree));
} else {
//not a poly expression, just call Attr
setResult(that, attr.attribTree(that, env, attr.unknownExprInfo));
}
}
-------------
PR: https://git.openjdk.java.net/valhalla/pull/369
More information about the valhalla-dev
mailing list