1898 throw new AssertionError(mtype); |
1898 throw new AssertionError(mtype); |
1899 |
1899 |
1900 Type qualifier = (tree.meth.hasTag(SELECT)) |
1900 Type qualifier = (tree.meth.hasTag(SELECT)) |
1901 ? ((JCFieldAccess) tree.meth).selected.type |
1901 ? ((JCFieldAccess) tree.meth).selected.type |
1902 : env.enclClass.sym.type; |
1902 : env.enclClass.sym.type; |
1903 restype = adjustMethodReturnType(qualifier, methName, argtypes, restype); |
1903 Symbol msym = TreeInfo.symbol(tree.meth); |
|
1904 restype = adjustMethodReturnType(msym, qualifier, methName, argtypes, restype); |
1904 |
1905 |
1905 chk.checkRefTypes(tree.typeargs, typeargtypes); |
1906 chk.checkRefTypes(tree.typeargs, typeargtypes); |
1906 |
1907 |
1907 // Check that value of resulting type is admissible in the |
1908 // Check that value of resulting type is admissible in the |
1908 // current context. Also, capture the return type |
1909 // current context. Also, capture the return type |
1910 result = check(tree, capturedRes, KindSelector.VAL, resultInfo); |
1911 result = check(tree, capturedRes, KindSelector.VAL, resultInfo); |
1911 } |
1912 } |
1912 chk.validate(tree.typeargs, localEnv); |
1913 chk.validate(tree.typeargs, localEnv); |
1913 } |
1914 } |
1914 //where |
1915 //where |
1915 Type adjustMethodReturnType(Type qualifierType, Name methodName, List<Type> argtypes, Type restype) { |
1916 Type adjustMethodReturnType(Symbol msym, Type qualifierType, Name methodName, List<Type> argtypes, Type restype) { |
1916 if (methodName == names.clone && types.isArray(qualifierType)) { |
1917 if (msym != null && |
|
1918 msym.owner == syms.objectType.tsym && |
|
1919 methodName == names.getClass && |
|
1920 argtypes.isEmpty()) { |
|
1921 // as a special case, x.getClass() has type Class<? extends |X|> |
|
1922 return new ClassType(restype.getEnclosingType(), |
|
1923 List.<Type>of(new WildcardType(types.erasure(qualifierType), |
|
1924 BoundKind.EXTENDS, |
|
1925 syms.boundClass)), |
|
1926 restype.tsym, |
|
1927 restype.getMetadata()); |
|
1928 } else if (msym != null && |
|
1929 msym.owner == syms.arrayClass && |
|
1930 methodName == names.clone && |
|
1931 types.isArray(qualifierType)) { |
1917 // as a special case, array.clone() has a result that is |
1932 // as a special case, array.clone() has a result that is |
1918 // the same as static type of the array being cloned |
1933 // the same as static type of the array being cloned |
1919 return qualifierType; |
1934 return qualifierType; |
1920 } else if (methodName == names.getClass && argtypes.isEmpty()) { |
|
1921 // as a special case, x.getClass() has type Class<? extends |X|> |
|
1922 return new ClassType(restype.getEnclosingType(), |
|
1923 List.<Type>of(new WildcardType(types.erasure(qualifierType), |
|
1924 BoundKind.EXTENDS, |
|
1925 syms.boundClass)), |
|
1926 restype.tsym, |
|
1927 restype.getMetadata()); |
|
1928 } else { |
1935 } else { |
1929 return restype; |
1936 return restype; |
1930 } |
1937 } |
1931 } |
1938 } |
1932 |
1939 |
2987 } |
2994 } |
2988 } |
2995 } |
2989 |
2996 |
2990 if (!refType.isErroneous()) { |
2997 if (!refType.isErroneous()) { |
2991 refType = types.createMethodTypeWithReturn(refType, |
2998 refType = types.createMethodTypeWithReturn(refType, |
2992 adjustMethodReturnType(lookupHelper.site, that.name, checkInfo.pt.getParameterTypes(), refType.getReturnType())); |
2999 adjustMethodReturnType(refSym, lookupHelper.site, that.name, checkInfo.pt.getParameterTypes(), refType.getReturnType())); |
2993 } |
3000 } |
2994 |
3001 |
2995 //go ahead with standard method reference compatibility check - note that param check |
3002 //go ahead with standard method reference compatibility check - note that param check |
2996 //is a no-op (as this has been taken care during method applicability) |
3003 //is a no-op (as this has been taken care during method applicability) |
2997 boolean isSpeculativeRound = |
3004 boolean isSpeculativeRound = |