changeset 3517:93beb80dcc65

Summary: Better method name, fold common code into subroutine.
author sadayapalam
date Thu, 01 Sep 2016 05:07:27 +0530
parents 801acf5df528
children 30469b6d88b6
files src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/StringConcat.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java
diffstat 6 files changed, 16 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Fri Aug 26 17:42:46 2016 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Sep 01 05:07:27 2016 +0530
@@ -2650,8 +2650,7 @@
     }
 
     // Returns the generic erasure, as opposed to the erasure of a concrete instatiation if possible.
-    // Fixme: Can use a better name ??
-    public Type erasedType(JCExpression expression) {
+    public Type declarationErasure(JCExpression expression) {
         Symbol symbol;
         switch (expression.getTag()) {
             case APPLY:
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri Aug 26 17:42:46 2016 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu Sep 01 05:07:27 2016 +0530
@@ -967,8 +967,6 @@
             }
             if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) {
                 rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType);
-                ((JCExpression)((JCTypeCast)rcvrExpr).clazz).type = rcvrType;
-                rcvrExpr.type = rcvrType;
             }
             return rcvrExpr;
         }
@@ -996,13 +994,8 @@
             apply = transTypes.coerce(attrEnv, apply,
                     types.erasure(localContext.tree.referentType.getReturnType()));
 
-            if (apply.hasTag(TYPECAST)) {
-                final JCTypeCast cast = (JCTypeCast) apply;
-                cast.setType(normalizedUnerasedReferentType.getReturnType());
-                cast.clazz.setType(normalizedUnerasedReferentType.getReturnType());
-            } else {
-                apply.setType(normalizedUnerasedReferentType.getReturnType());
-            }
+            apply.setType(normalizedUnerasedReferentType.getReturnType());
+
             setVarargsIfNeeded(apply, tree.varargsElement);
             return apply;
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Fri Aug 26 17:42:46 2016 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Sep 01 05:07:27 2016 +0530
@@ -120,7 +120,7 @@
     JCExpression cast(JCExpression tree, Type target) {
         int oldpos = make.pos;
         make.at(tree.pos);
-        if (!types.isSameType(types.erasedType(tree), target)) {
+        if (!types.isSameType(types.declarationErasure(tree), target)) {
             if (!resolve.isAccessible(env, target.tsym))
                 resolve.logAccessErrorInternal(env, tree, target);
             tree = make.TypeCast(make.Type(target), tree).setType(target);
@@ -148,7 +148,7 @@
     JCExpression coerce(JCExpression tree, Type target) {
         Type btarget = target.baseType();
         if (tree.type.isPrimitive() == target.isPrimitive()) {
-            return types.isAssignable(types.erasedType(tree), btarget, types.noWarnings)
+            return types.isAssignable(types.declarationErasure(tree), btarget, types.noWarnings)
                 ? tree
                 : cast(tree, btarget);
         }
@@ -187,9 +187,7 @@
             if (target != null) {
                 JCExpression coercedExpr = coerce(tree, erasure(target));
                 if (coercedExpr != tree) {
-                    final JCTypeCast cast = (JCTypeCast) coercedExpr;
-                    cast.setType(target);
-                    cast.clazz.setType(target);
+                    coercedExpr.setType(target);
                 }
                 return coercedExpr;
             }
@@ -311,9 +309,7 @@
             } else {
                 JCExpression retExpr = coerce(call, types.erasure(bridgeType).getReturnType());
                 if (retExpr.hasTag(Tag.TYPECAST)) {
-                    final JCTypeCast cast = (JCTypeCast)retExpr;
-                    cast.setType(bridgeType.getReturnType());
-                    cast.clazz.setType(bridgeType.getReturnType());
+                    retExpr.setType(bridgeType.getReturnType());
                 }
                 stat = make.Return(retExpr);
             }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Aug 26 17:42:46 2016 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Sep 01 05:07:27 2016 +0530
@@ -2366,8 +2366,8 @@
         if (types.needsMangling(unerasedType) || //do not skip cast to types containing avars
                 (tree.clazz.type.hasTag(CLASS) && types.isAnyfied(tree.clazz.type.tsym)) || //do not skip cast to raw anyfied
                 (!tree.clazz.type.isPrimitive() &&
-                !types.isSameType(types.erasedType(tree.expr), tree.clazz.type) &&
-                types.asSuper(types.erasedType(tree.expr), tree.clazz.type.tsym) == null)) {
+                !types.isSameType(types.declarationErasure(tree.expr), tree.clazz.type) &&
+                types.asSuper(types.declarationErasure(tree.expr), tree.clazz.type.tsym) == null)) {
             code.emitop2(checkcast, makeRef(tree.pos(), unerasedType));
         }
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/StringConcat.java	Fri Aug 26 17:42:46 2016 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/StringConcat.java	Thu Sep 01 05:07:27 2016 +0530
@@ -360,7 +360,7 @@
                     Object constVal = arg.type.constValue();
                     Type unerased = arg.type;
                     Type dynamicArgType = types.isSpecializableTypeVar(unerased) ?
-                            unerased : types.erasedType((JCExpression) arg);
+                            unerased : types.declarationErasure((JCExpression) arg);
                     if ("".equals(constVal)) continue;
                     if (arg.type == syms.botType) {
                         dynamicArgs.add(types.boxedClass(syms.voidType).type);
@@ -441,7 +441,7 @@
                         recipe.append(TAG_ARG);
                         Type unerased = arg.type;
                         Type dynamicArgType = types.isSpecializableTypeVar(unerased) ?
-                                unerased : types.erasedType((JCExpression) arg);
+                                unerased : types.declarationErasure((JCExpression) arg);
                         dynamicArgs.add(dynamicArgType);
                         gen.genExpr(arg, dynamicArgType).load();
                     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Fri Aug 26 17:42:46 2016 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Sep 01 05:07:27 2016 +0530
@@ -2001,6 +2001,11 @@
         public Tag getTag() {
             return TYPECAST;
         }
+        @Override
+        public JCExpression setType(Type type) {
+            this.type = this.clazz.type = type;
+            return this;
+        }
     }
 
     /**