langtools/src/share/classes/com/sun/tools/javac/code/Type.java
changeset 14949 45f43822bbde
parent 14725 65836e833f59
child 15385 ee1eebe7e210
equal deleted inserted replaced
14948:6a2008d8e9ba 14949:45f43822bbde
   300     /**
   300     /**
   301      * This method is analogous to isSameType, but weaker, since we
   301      * This method is analogous to isSameType, but weaker, since we
   302      * never complete classes. Where isSameType would complete a
   302      * never complete classes. Where isSameType would complete a
   303      * class, equals assumes that the two types are different.
   303      * class, equals assumes that the two types are different.
   304      */
   304      */
       
   305     @Override
   305     public boolean equals(Object t) {
   306     public boolean equals(Object t) {
   306         return super.equals(t);
   307         return super.equals(t);
   307     }
   308     }
   308 
   309 
       
   310     @Override
   309     public int hashCode() {
   311     public int hashCode() {
   310         return super.hashCode();
   312         return super.hashCode();
   311     }
   313     }
   312 
   314 
   313     /** Is this a constant type whose value is false?
   315     /** Is this a constant type whose value is false?
   994          */
   996          */
   995         public String toString() {
   997         public String toString() {
   996             return "(" + argtypes + ")" + restype;
   998             return "(" + argtypes + ")" + restype;
   997         }
   999         }
   998 
  1000 
   999         public boolean equals(Object obj) {
       
  1000             if (this == obj)
       
  1001                 return true;
       
  1002             if (!(obj instanceof MethodType))
       
  1003                 return false;
       
  1004             MethodType m = (MethodType)obj;
       
  1005             List<Type> args1 = argtypes;
       
  1006             List<Type> args2 = m.argtypes;
       
  1007             while (!args1.isEmpty() && !args2.isEmpty()) {
       
  1008                 if (!args1.head.equals(args2.head))
       
  1009                     return false;
       
  1010                 args1 = args1.tail;
       
  1011                 args2 = args2.tail;
       
  1012             }
       
  1013             if (!args1.isEmpty() || !args2.isEmpty())
       
  1014                 return false;
       
  1015             return restype.equals(m.restype);
       
  1016         }
       
  1017 
       
  1018         public int hashCode() {
       
  1019             int h = METHOD.ordinal();
       
  1020             for (List<Type> thisargs = this.argtypes;
       
  1021                  thisargs.tail != null; /*inlined: thisargs.nonEmpty()*/
       
  1022                  thisargs = thisargs.tail)
       
  1023                 h = (h << 5) + thisargs.head.hashCode();
       
  1024             return (h << 5) + this.restype.hashCode();
       
  1025         }
       
  1026 
       
  1027         public List<Type>        getParameterTypes() { return argtypes; }
  1001         public List<Type>        getParameterTypes() { return argtypes; }
  1028         public Type              getReturnType()     { return restype; }
  1002         public Type              getReturnType()     { return restype; }
  1029         public List<Type>        getThrownTypes()    { return thrown; }
  1003         public List<Type>        getThrownTypes()    { return thrown; }
  1030 
  1004 
  1031         public boolean isErroneous() {
  1005         public boolean isErroneous() {