8274161: Cleanup redundant casts in jdk.compiler
Reviewed-by: vromero
This commit is contained in:
parent
951247c8cb
commit
077b2de088
@ -3954,14 +3954,14 @@ public class Attr extends JCTree.Visitor {
|
|||||||
: chk.checkNonVoid(tree.arg.pos(), attribExpr(tree.arg, env));
|
: chk.checkNonVoid(tree.arg.pos(), attribExpr(tree.arg, env));
|
||||||
|
|
||||||
// Find operator.
|
// Find operator.
|
||||||
Symbol operator = tree.operator = operators.resolveUnary(tree, tree.getTag(), argtype);
|
OperatorSymbol operator = tree.operator = operators.resolveUnary(tree, tree.getTag(), argtype);
|
||||||
Type owntype = types.createErrorType(tree.type);
|
Type owntype = types.createErrorType(tree.type);
|
||||||
if (operator != operators.noOpSymbol &&
|
if (operator != operators.noOpSymbol &&
|
||||||
!argtype.isErroneous()) {
|
!argtype.isErroneous()) {
|
||||||
owntype = (tree.getTag().isIncOrDecUnaryOp())
|
owntype = (tree.getTag().isIncOrDecUnaryOp())
|
||||||
? tree.arg.type
|
? tree.arg.type
|
||||||
: operator.type.getReturnType();
|
: operator.type.getReturnType();
|
||||||
int opc = ((OperatorSymbol)operator).opcode;
|
int opc = operator.opcode;
|
||||||
|
|
||||||
// If the argument is constant, fold it.
|
// If the argument is constant, fold it.
|
||||||
if (argtype.constValue() != null) {
|
if (argtype.constValue() != null) {
|
||||||
@ -4008,13 +4008,13 @@ public class Attr extends JCTree.Visitor {
|
|||||||
matchBindings = matchBindingsComputer.binary(tree, lhsBindings, matchBindings);
|
matchBindings = matchBindingsComputer.binary(tree, lhsBindings, matchBindings);
|
||||||
|
|
||||||
// Find operator.
|
// Find operator.
|
||||||
Symbol operator = tree.operator = operators.resolveBinary(tree, tree.getTag(), left, right);
|
OperatorSymbol operator = tree.operator = operators.resolveBinary(tree, tree.getTag(), left, right);
|
||||||
Type owntype = types.createErrorType(tree.type);
|
Type owntype = types.createErrorType(tree.type);
|
||||||
if (operator != operators.noOpSymbol &&
|
if (operator != operators.noOpSymbol &&
|
||||||
!left.isErroneous() &&
|
!left.isErroneous() &&
|
||||||
!right.isErroneous()) {
|
!right.isErroneous()) {
|
||||||
owntype = operator.type.getReturnType();
|
owntype = operator.type.getReturnType();
|
||||||
int opc = ((OperatorSymbol)operator).opcode;
|
int opc = operator.opcode;
|
||||||
// If both arguments are constants, fold them.
|
// If both arguments are constants, fold them.
|
||||||
if (left.constValue() != null && right.constValue() != null) {
|
if (left.constValue() != null && right.constValue() != null) {
|
||||||
Type ctype = cfolder.fold2(opc, left, right);
|
Type ctype = cfolder.fold2(opc, left, right);
|
||||||
@ -5498,11 +5498,11 @@ public class Attr extends JCTree.Visitor {
|
|||||||
c.owner.kind != PCK &&
|
c.owner.kind != PCK &&
|
||||||
((c.flags() & STATIC) == 0 || c.name == names.empty) &&
|
((c.flags() & STATIC) == 0 || c.name == names.empty) &&
|
||||||
(TreeInfo.flags(l.head) & (STATIC | INTERFACE)) != 0) {
|
(TreeInfo.flags(l.head) & (STATIC | INTERFACE)) != 0) {
|
||||||
Symbol sym = null;
|
VarSymbol sym = null;
|
||||||
if (l.head.hasTag(VARDEF)) sym = ((JCVariableDecl) l.head).sym;
|
if (l.head.hasTag(VARDEF)) sym = ((JCVariableDecl) l.head).sym;
|
||||||
if (sym == null ||
|
if (sym == null ||
|
||||||
sym.kind != VAR ||
|
sym.kind != VAR ||
|
||||||
((VarSymbol) sym).getConstValue() == null)
|
sym.getConstValue() == null)
|
||||||
log.error(l.head.pos(), Errors.IclsCantHaveStaticDecl(c));
|
log.error(l.head.pos(), Errors.IclsCantHaveStaticDecl(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,14 +424,14 @@ public class LambdaToMethod extends TreeTranslator {
|
|||||||
//add captured locals
|
//add captured locals
|
||||||
for (Symbol fv : localContext.getSymbolMap(CAPTURED_VAR).keySet()) {
|
for (Symbol fv : localContext.getSymbolMap(CAPTURED_VAR).keySet()) {
|
||||||
if (fv != localContext.self) {
|
if (fv != localContext.self) {
|
||||||
JCTree captured_local = make.Ident(fv).setType(fv.type);
|
JCExpression captured_local = make.Ident(fv).setType(fv.type);
|
||||||
syntheticInits.append((JCExpression) captured_local);
|
syntheticInits.append(captured_local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add captured outer this instances (used only when `this' capture itself is illegal)
|
// add captured outer this instances (used only when `this' capture itself is illegal)
|
||||||
for (Symbol fv : localContext.getSymbolMap(CAPTURED_OUTER_THIS).keySet()) {
|
for (Symbol fv : localContext.getSymbolMap(CAPTURED_OUTER_THIS).keySet()) {
|
||||||
JCTree captured_local = make.QualThis(fv.type);
|
JCExpression captured_local = make.QualThis(fv.type);
|
||||||
syntheticInits.append((JCExpression) captured_local);
|
syntheticInits.append(captured_local);
|
||||||
}
|
}
|
||||||
|
|
||||||
//then, determine the arguments to the indy call
|
//then, determine the arguments to the indy call
|
||||||
@ -1184,13 +1184,13 @@ public class LambdaToMethod extends TreeTranslator {
|
|||||||
syms.stringType,
|
syms.stringType,
|
||||||
syms.methodTypeType).appendList(staticArgs.map(types::constantType));
|
syms.methodTypeType).appendList(staticArgs.map(types::constantType));
|
||||||
|
|
||||||
Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
|
MethodSymbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
|
||||||
bsmName, bsm_staticArgs, List.nil());
|
bsmName, bsm_staticArgs, List.nil());
|
||||||
|
|
||||||
DynamicMethodSymbol dynSym =
|
DynamicMethodSymbol dynSym =
|
||||||
new DynamicMethodSymbol(methName,
|
new DynamicMethodSymbol(methName,
|
||||||
syms.noSymbol,
|
syms.noSymbol,
|
||||||
((MethodSymbol)bsm).asHandle(),
|
bsm.asHandle(),
|
||||||
indyType,
|
indyType,
|
||||||
staticArgs.toArray(new LoadableConstant[staticArgs.length()]));
|
staticArgs.toArray(new LoadableConstant[staticArgs.length()]));
|
||||||
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
|
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
|
||||||
|
@ -2369,7 +2369,7 @@ public class Lower extends TreeTranslator {
|
|||||||
enumDefs.append(make.VarDef(valuesVar, make.App(make.QualIdent(valuesMethod))));
|
enumDefs.append(make.VarDef(valuesVar, make.App(make.QualIdent(valuesMethod))));
|
||||||
tree.sym.members().enter(valuesVar);
|
tree.sym.members().enter(valuesVar);
|
||||||
|
|
||||||
Symbol valuesSym = lookupMethod(tree.pos(), names.values,
|
MethodSymbol valuesSym = lookupMethod(tree.pos(), names.values,
|
||||||
tree.type, List.nil());
|
tree.type, List.nil());
|
||||||
List<JCStatement> valuesBody;
|
List<JCStatement> valuesBody;
|
||||||
if (useClone()) {
|
if (useClone()) {
|
||||||
@ -2420,7 +2420,7 @@ public class Lower extends TreeTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JCMethodDecl valuesDef =
|
JCMethodDecl valuesDef =
|
||||||
make.MethodDef((MethodSymbol)valuesSym, make.Block(0, valuesBody));
|
make.MethodDef(valuesSym, make.Block(0, valuesBody));
|
||||||
|
|
||||||
enumDefs.append(valuesDef);
|
enumDefs.append(valuesDef);
|
||||||
|
|
||||||
@ -2635,7 +2635,7 @@ public class Lower extends TreeTranslator {
|
|||||||
Name bootstrapName,
|
Name bootstrapName,
|
||||||
Name argName,
|
Name argName,
|
||||||
boolean isStatic) {
|
boolean isStatic) {
|
||||||
Symbol bsm = rs.resolveInternalMethod(tree.pos(), attrEnv, site,
|
MethodSymbol bsm = rs.resolveInternalMethod(tree.pos(), attrEnv, site,
|
||||||
bootstrapName, staticArgTypes, List.nil());
|
bootstrapName, staticArgTypes, List.nil());
|
||||||
|
|
||||||
MethodType indyType = msym.type.asMethodType();
|
MethodType indyType = msym.type.asMethodType();
|
||||||
@ -2647,7 +2647,7 @@ public class Lower extends TreeTranslator {
|
|||||||
);
|
);
|
||||||
DynamicMethodSymbol dynSym = new DynamicMethodSymbol(argName,
|
DynamicMethodSymbol dynSym = new DynamicMethodSymbol(argName,
|
||||||
syms.noSymbol,
|
syms.noSymbol,
|
||||||
((MethodSymbol)bsm).asHandle(),
|
bsm.asHandle(),
|
||||||
indyType,
|
indyType,
|
||||||
staticArgValues);
|
staticArgValues);
|
||||||
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), argName);
|
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), argName);
|
||||||
|
@ -371,7 +371,7 @@ public class TransPatterns extends TreeTranslator {
|
|||||||
|
|
||||||
boolean enumSelector = seltype.tsym.isEnum();
|
boolean enumSelector = seltype.tsym.isEnum();
|
||||||
Name bootstrapName = enumSelector ? names.enumSwitch : names.typeSwitch;
|
Name bootstrapName = enumSelector ? names.enumSwitch : names.typeSwitch;
|
||||||
Symbol bsm = rs.resolveInternalMethod(tree.pos(), env, syms.switchBootstrapsType,
|
MethodSymbol bsm = rs.resolveInternalMethod(tree.pos(), env, syms.switchBootstrapsType,
|
||||||
bootstrapName, staticArgTypes, List.nil());
|
bootstrapName, staticArgTypes, List.nil());
|
||||||
|
|
||||||
MethodType indyType = new MethodType(
|
MethodType indyType = new MethodType(
|
||||||
@ -382,7 +382,7 @@ public class TransPatterns extends TreeTranslator {
|
|||||||
);
|
);
|
||||||
DynamicMethodSymbol dynSym = new DynamicMethodSymbol(bootstrapName,
|
DynamicMethodSymbol dynSym = new DynamicMethodSymbol(bootstrapName,
|
||||||
syms.noSymbol,
|
syms.noSymbol,
|
||||||
((MethodSymbol)bsm).asHandle(),
|
bsm.asHandle(),
|
||||||
indyType,
|
indyType,
|
||||||
staticArgValues);
|
staticArgValues);
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ public abstract class StringConcat {
|
|||||||
syms.stringType,
|
syms.stringType,
|
||||||
syms.methodTypeType);
|
syms.methodTypeType);
|
||||||
|
|
||||||
Symbol bsm = rs.resolveInternalMethod(pos,
|
MethodSymbol bsm = rs.resolveInternalMethod(pos,
|
||||||
gen.getAttrEnv(),
|
gen.getAttrEnv(),
|
||||||
syms.stringConcatFactory,
|
syms.stringConcatFactory,
|
||||||
names.makeConcat,
|
names.makeConcat,
|
||||||
@ -380,7 +380,7 @@ public abstract class StringConcat {
|
|||||||
|
|
||||||
Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcat,
|
Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcat,
|
||||||
syms.noSymbol,
|
syms.noSymbol,
|
||||||
((MethodSymbol)bsm).asHandle(),
|
bsm.asHandle(),
|
||||||
indyType,
|
indyType,
|
||||||
List.nil().toArray(new LoadableConstant[0]));
|
List.nil().toArray(new LoadableConstant[0]));
|
||||||
|
|
||||||
@ -487,7 +487,7 @@ public abstract class StringConcat {
|
|||||||
.append(syms.stringType)
|
.append(syms.stringType)
|
||||||
.appendList(constTypes);
|
.appendList(constTypes);
|
||||||
|
|
||||||
Symbol bsm = rs.resolveInternalMethod(pos,
|
MethodSymbol bsm = rs.resolveInternalMethod(pos,
|
||||||
gen.getAttrEnv(),
|
gen.getAttrEnv(),
|
||||||
syms.stringConcatFactory,
|
syms.stringConcatFactory,
|
||||||
names.makeConcatWithConstants,
|
names.makeConcatWithConstants,
|
||||||
@ -496,7 +496,7 @@ public abstract class StringConcat {
|
|||||||
|
|
||||||
Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcatWithConstants,
|
Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcatWithConstants,
|
||||||
syms.noSymbol,
|
syms.noSymbol,
|
||||||
((MethodSymbol)bsm).asHandle(),
|
bsm.asHandle(),
|
||||||
indyType,
|
indyType,
|
||||||
List.of(LoadableConstant.String(recipe))
|
List.of(LoadableConstant.String(recipe))
|
||||||
.appendList(constants).toArray(new LoadableConstant[constants.size()]));
|
.appendList(constants).toArray(new LoadableConstant[constants.size()]));
|
||||||
|
Loading…
Reference in New Issue
Block a user