Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8274161: Cleanup redundant casts in jdk.compiler #5283

Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -3946,14 +3946,14 @@ public void visitUnary(JCUnary tree) {
: chk.checkNonVoid(tree.arg.pos(), attribExpr(tree.arg, env));

// 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);
if (operator != operators.noOpSymbol &&
!argtype.isErroneous()) {
owntype = (tree.getTag().isIncOrDecUnaryOp())
? tree.arg.type
: operator.type.getReturnType();
int opc = ((OperatorSymbol)operator).opcode;
int opc = operator.opcode;

// If the argument is constant, fold it.
if (argtype.constValue() != null) {
@@ -4000,13 +4000,13 @@ public void visitBinary(JCBinary tree) {
matchBindings = matchBindingsComputer.binary(tree, lhsBindings, matchBindings);

// 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);
if (operator != operators.noOpSymbol &&
!left.isErroneous() &&
!right.isErroneous()) {
owntype = operator.type.getReturnType();
int opc = ((OperatorSymbol)operator).opcode;
int opc = operator.opcode;
// If both arguments are constants, fold them.
if (left.constValue() != null && right.constValue() != null) {
Type ctype = cfolder.fold2(opc, left, right);
@@ -5483,11 +5483,11 @@ private void attribClassBody(Env<AttrContext> env, ClassSymbol c) {
c.owner.kind != PCK &&
((c.flags() & STATIC) == 0 || c.name == names.empty) &&
(TreeInfo.flags(l.head) & (STATIC | INTERFACE)) != 0) {
Symbol sym = null;
VarSymbol sym = null;
if (l.head.hasTag(VARDEF)) sym = ((JCVariableDecl) l.head).sym;
if (sym == null ||
sym.kind != VAR ||
((VarSymbol) sym).getConstValue() == null)
sym.getConstValue() == null)
log.error(l.head.pos(), Errors.IclsCantHaveStaticDecl(c));
}
}
@@ -424,14 +424,14 @@ public void visitLambda(JCLambda tree) {
//add captured locals
for (Symbol fv : localContext.getSymbolMap(CAPTURED_VAR).keySet()) {
if (fv != localContext.self) {
JCTree captured_local = make.Ident(fv).setType(fv.type);
syntheticInits.append((JCExpression) captured_local);
JCExpression captured_local = make.Ident(fv).setType(fv.type);
syntheticInits.append(captured_local);
}
}
// add captured outer this instances (used only when `this' capture itself is illegal)
for (Symbol fv : localContext.getSymbolMap(CAPTURED_OUTER_THIS).keySet()) {
JCTree captured_local = make.QualThis(fv.type);
syntheticInits.append((JCExpression) captured_local);
JCExpression captured_local = make.QualThis(fv.type);
syntheticInits.append(captured_local);
}

//then, determine the arguments to the indy call
@@ -1184,13 +1184,13 @@ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmNam
syms.stringType,
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());

DynamicMethodSymbol dynSym =
new DynamicMethodSymbol(methName,
syms.noSymbol,
((MethodSymbol)bsm).asHandle(),
bsm.asHandle(),
indyType,
staticArgs.toArray(new LoadableConstant[staticArgs.length()]));
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
@@ -2315,7 +2315,7 @@ private void visitEnumDef(JCClassDecl tree) {
enumDefs.append(make.VarDef(valuesVar, make.App(make.QualIdent(valuesMethod))));
tree.sym.members().enter(valuesVar);

Symbol valuesSym = lookupMethod(tree.pos(), names.values,
MethodSymbol valuesSym = lookupMethod(tree.pos(), names.values,
tree.type, List.nil());
List<JCStatement> valuesBody;
if (useClone()) {
@@ -2366,7 +2366,7 @@ private void visitEnumDef(JCClassDecl tree) {
}

JCMethodDecl valuesDef =
make.MethodDef((MethodSymbol)valuesSym, make.Block(0, valuesBody));
make.MethodDef(valuesSym, make.Block(0, valuesBody));

enumDefs.append(valuesDef);

@@ -2581,7 +2581,7 @@ JCFieldAccess makeIndyQualifier(
Name bootstrapName,
Name argName,
boolean isStatic) {
Symbol bsm = rs.resolveInternalMethod(tree.pos(), attrEnv, site,
MethodSymbol bsm = rs.resolveInternalMethod(tree.pos(), attrEnv, site,
bootstrapName, staticArgTypes, List.nil());

MethodType indyType = msym.type.asMethodType();
@@ -2593,7 +2593,7 @@ JCFieldAccess makeIndyQualifier(
);
DynamicMethodSymbol dynSym = new DynamicMethodSymbol(argName,
syms.noSymbol,
((MethodSymbol)bsm).asHandle(),
bsm.asHandle(),
indyType,
staticArgValues);
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), argName);
@@ -371,7 +371,7 @@ private void handleSwitch(JCTree tree,

boolean enumSelector = seltype.tsym.isEnum();
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());

MethodType indyType = new MethodType(
@@ -382,7 +382,7 @@ private void handleSwitch(JCTree tree,
);
DynamicMethodSymbol dynSym = new DynamicMethodSymbol(bootstrapName,
syms.noSymbol,
((MethodSymbol)bsm).asHandle(),
bsm.asHandle(),
indyType,
staticArgValues);

@@ -371,7 +371,7 @@ private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, List<Type> d
syms.stringType,
syms.methodTypeType);

Symbol bsm = rs.resolveInternalMethod(pos,
MethodSymbol bsm = rs.resolveInternalMethod(pos,
gen.getAttrEnv(),
syms.stringConcatFactory,
names.makeConcat,
@@ -380,7 +380,7 @@ private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, List<Type> d

Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcat,
syms.noSymbol,
((MethodSymbol)bsm).asHandle(),
bsm.asHandle(),
indyType,
List.nil().toArray(new LoadableConstant[0]));

@@ -487,7 +487,7 @@ private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, String recip
.append(syms.stringType)
.appendList(constTypes);

Symbol bsm = rs.resolveInternalMethod(pos,
MethodSymbol bsm = rs.resolveInternalMethod(pos,
gen.getAttrEnv(),
syms.stringConcatFactory,
names.makeConcatWithConstants,
@@ -496,7 +496,7 @@ private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, String recip

Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcatWithConstants,
syms.noSymbol,
((MethodSymbol)bsm).asHandle(),
bsm.asHandle(),
indyType,
List.of(LoadableConstant.String(recipe))
.appendList(constants).toArray(new LoadableConstant[constants.size()]));