langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 8032 e1aa25ccdabb
parent 8031 d5fe2c1cecfc
child 8036 17b976649c61
equal deleted inserted replaced
8031:d5fe2c1cecfc 8032:e1aa25ccdabb
   561         for (JCTypeParameter typaram : typarams) {
   561         for (JCTypeParameter typaram : typarams) {
   562             Type bound = typaram.type.getUpperBound();
   562             Type bound = typaram.type.getUpperBound();
   563             if (bound != null && bound.tsym instanceof ClassSymbol) {
   563             if (bound != null && bound.tsym instanceof ClassSymbol) {
   564                 ClassSymbol c = (ClassSymbol)bound.tsym;
   564                 ClassSymbol c = (ClassSymbol)bound.tsym;
   565                 if ((c.flags_field & COMPOUND) != 0) {
   565                 if ((c.flags_field & COMPOUND) != 0) {
   566                     assert (c.flags_field & UNATTRIBUTED) != 0 : c;
   566                     Assert.check((c.flags_field & UNATTRIBUTED) != 0, c);
   567                     attribClass(typaram.pos(), c);
   567                     attribClass(typaram.pos(), c);
   568                 }
   568                 }
   569             }
   569             }
   570         }
   570         }
   571     }
   571     }
  1432             // arguments (this will also set the method symbol).
  1432             // arguments (this will also set the method symbol).
  1433             Type mpt = newMethTemplate(argtypes, typeargtypes);
  1433             Type mpt = newMethTemplate(argtypes, typeargtypes);
  1434             localEnv.info.varArgs = false;
  1434             localEnv.info.varArgs = false;
  1435             Type mtype = attribExpr(tree.meth, localEnv, mpt);
  1435             Type mtype = attribExpr(tree.meth, localEnv, mpt);
  1436             if (localEnv.info.varArgs)
  1436             if (localEnv.info.varArgs)
  1437                 assert mtype.isErroneous() || tree.varargsElement != null;
  1437                 Assert.check(mtype.isErroneous() || tree.varargsElement != null);
  1438 
  1438 
  1439             // Compute the result type.
  1439             // Compute the result type.
  1440             Type restype = mtype.getReturnType();
  1440             Type restype = mtype.getReturnType();
  1441             if (restype.tag == WILDCARD)
  1441             if (restype.tag == WILDCARD)
  1442                 throw new AssertionError(mtype);
  1442                 throw new AssertionError(mtype);
  1665                         tree.args,
  1665                         tree.args,
  1666                         argtypes,
  1666                         argtypes,
  1667                         typeargtypes,
  1667                         typeargtypes,
  1668                         localEnv.info.varArgs);
  1668                         localEnv.info.varArgs);
  1669                 if (localEnv.info.varArgs)
  1669                 if (localEnv.info.varArgs)
  1670                     assert tree.constructorType.isErroneous() || tree.varargsElement != null;
  1670                     Assert.check(tree.constructorType.isErroneous() || tree.varargsElement != null);
  1671             }
  1671             }
  1672 
  1672 
  1673             if (cdef != null) {
  1673             if (cdef != null) {
  1674                 // We are seeing an anonymous class instance creation.
  1674                 // We are seeing an anonymous class instance creation.
  1675                 // In this case, the class instance creation
  1675                 // In this case, the class instance creation
  1725                 // Reassign clazztype and recompute constructor.
  1725                 // Reassign clazztype and recompute constructor.
  1726                 clazztype = cdef.sym.type;
  1726                 clazztype = cdef.sym.type;
  1727                 Symbol sym = rs.resolveConstructor(
  1727                 Symbol sym = rs.resolveConstructor(
  1728                     tree.pos(), localEnv, clazztype, argtypes,
  1728                     tree.pos(), localEnv, clazztype, argtypes,
  1729                     typeargtypes, true, tree.varargsElement != null);
  1729                     typeargtypes, true, tree.varargsElement != null);
  1730                 assert sym.kind < AMBIGUOUS || tree.constructor.type.isErroneous();
  1730                 Assert.check(sym.kind < AMBIGUOUS || tree.constructor.type.isErroneous());
  1731                 tree.constructor = sym;
  1731                 tree.constructor = sym;
  1732                 if (tree.constructor.kind > ERRONEOUS) {
  1732                 if (tree.constructor.kind > ERRONEOUS) {
  1733                     tree.constructorType =  syms.errType;
  1733                     tree.constructorType =  syms.errType;
  1734                 }
  1734                 }
  1735                 else {
  1735                 else {
  2959                 make.Modifiers(PUBLIC | ABSTRACT),
  2959                 make.Modifiers(PUBLIC | ABSTRACT),
  2960                 tree.name, List.<JCTypeParameter>nil(),
  2960                 tree.name, List.<JCTypeParameter>nil(),
  2961                 extending, implementing, List.<JCTree>nil());
  2961                 extending, implementing, List.<JCTree>nil());
  2962 
  2962 
  2963             ClassSymbol c = (ClassSymbol)a.getUpperBound().tsym;
  2963             ClassSymbol c = (ClassSymbol)a.getUpperBound().tsym;
  2964             assert (c.flags() & COMPOUND) != 0;
  2964             Assert.check((c.flags() & COMPOUND) != 0);
  2965             cd.sym = c;
  2965             cd.sym = c;
  2966             c.sourcefile = env.toplevel.sourcefile;
  2966             c.sourcefile = env.toplevel.sourcefile;
  2967 
  2967 
  2968             // ... and attribute the bound class
  2968             // ... and attribute the bound class
  2969             c.flags_field |= UNATTRIBUTED;
  2969             c.flags_field |= UNATTRIBUTED;
  3091     }
  3091     }
  3092 
  3092 
  3093     /** Finish the attribution of a class. */
  3093     /** Finish the attribution of a class. */
  3094     private void attribClassBody(Env<AttrContext> env, ClassSymbol c) {
  3094     private void attribClassBody(Env<AttrContext> env, ClassSymbol c) {
  3095         JCClassDecl tree = (JCClassDecl)env.tree;
  3095         JCClassDecl tree = (JCClassDecl)env.tree;
  3096         assert c == tree.sym;
  3096         Assert.check(c == tree.sym);
  3097 
  3097 
  3098         // Validate annotations
  3098         // Validate annotations
  3099         chk.validateAnnotations(tree.mods.annotations, c);
  3099         chk.validateAnnotations(tree.mods.annotations, c);
  3100 
  3100 
  3101         // Validate type parameters, supertype and interfaces.
  3101         // Validate type parameters, supertype and interfaces.
  3132         // with two different argument lists.
  3132         // with two different argument lists.
  3133         chk.checkClassBounds(tree.pos(), c.type);
  3133         chk.checkClassBounds(tree.pos(), c.type);
  3134 
  3134 
  3135         tree.type = c.type;
  3135         tree.type = c.type;
  3136 
  3136 
  3137         boolean assertsEnabled = false;
  3137         for (List<JCTypeParameter> l = tree.typarams;
  3138         assert assertsEnabled = true;
  3138              l.nonEmpty(); l = l.tail) {
  3139         if (assertsEnabled) {
  3139              Assert.checkNonNull(env.info.scope.lookup(l.head.name).scope);
  3140             for (List<JCTypeParameter> l = tree.typarams;
       
  3141                  l.nonEmpty(); l = l.tail)
       
  3142                 assert env.info.scope.lookup(l.head.name).scope != null;
       
  3143         }
  3140         }
  3144 
  3141 
  3145         // Check that a generic class doesn't extend Throwable
  3142         // Check that a generic class doesn't extend Throwable
  3146         if (!c.type.allparams().isEmpty() && types.isSubtype(c.type, syms.throwableType))
  3143         if (!c.type.allparams().isEmpty() && types.isSubtype(c.type, syms.throwableType))
  3147             log.error(tree.extending.pos(), "generic.throwable");
  3144             log.error(tree.extending.pos(), "generic.throwable");