Lines 47-52
Link Here
|
47 |
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; |
47 |
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; |
48 |
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; |
48 |
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; |
49 |
import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding; |
49 |
import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding; |
|
|
50 |
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; |
50 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
51 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
51 |
import org.eclipse.jdt.internal.compiler.util.Util; |
52 |
import org.eclipse.jdt.internal.compiler.util.Util; |
52 |
import org.eclipse.jdt.internal.core.ClassFile; |
53 |
import org.eclipse.jdt.internal.core.ClassFile; |
Lines 952-962
Link Here
|
952 |
* @see ITypeBinding#isAssignmentCompatible(ITypeBinding) |
953 |
* @see ITypeBinding#isAssignmentCompatible(ITypeBinding) |
953 |
*/ |
954 |
*/ |
954 |
public boolean isAssignmentCompatible(ITypeBinding type) { |
955 |
public boolean isAssignmentCompatible(ITypeBinding type) { |
955 |
if (this == type) return true; |
956 |
try { |
956 |
TypeBinding other = (TypeBinding) type; |
957 |
if (this == type) return true; |
957 |
Scope scope = this.resolver.scope(); |
958 |
TypeBinding other = (TypeBinding) type; |
958 |
if (scope == null) return false; |
959 |
Scope scope = this.resolver.scope(); |
959 |
return this.binding.isCompatibleWith(other.binding) || scope.isBoxingCompatibleWith(this.binding, other.binding); |
960 |
if (scope == null) return false; |
|
|
961 |
return this.binding.isCompatibleWith(other.binding) || scope.isBoxingCompatibleWith(this.binding, other.binding); |
962 |
} catch (AbortCompilation e) { |
963 |
// don't surface internal exception to clients |
964 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=143013 |
965 |
return false; |
966 |
} |
960 |
} |
967 |
} |
961 |
|
968 |
|
962 |
/* (non-Javadoc) |
969 |
/* (non-Javadoc) |
Lines 970-986
Link Here
|
970 |
* @see ITypeBinding#isCastCompatible(ITypeBinding) |
977 |
* @see ITypeBinding#isCastCompatible(ITypeBinding) |
971 |
*/ |
978 |
*/ |
972 |
public boolean isCastCompatible(ITypeBinding type) { |
979 |
public boolean isCastCompatible(ITypeBinding type) { |
973 |
Expression expression = new Expression() { |
980 |
try { |
974 |
public StringBuffer printExpression(int indent,StringBuffer output) { |
981 |
Expression expression = new Expression() { |
975 |
return null; |
982 |
public StringBuffer printExpression(int indent,StringBuffer output) { |
976 |
} |
983 |
return null; |
977 |
}; |
984 |
} |
978 |
Scope scope = this.resolver.scope(); |
985 |
}; |
979 |
if (scope == null) return false; |
986 |
Scope scope = this.resolver.scope(); |
980 |
org.eclipse.jdt.internal.compiler.lookup.TypeBinding expressionType = ((TypeBinding) type).binding; |
987 |
if (scope == null) return false; |
981 |
// simulate capture in case checked binding did not properly get extracted from a reference |
988 |
org.eclipse.jdt.internal.compiler.lookup.TypeBinding expressionType = ((TypeBinding) type).binding; |
982 |
expressionType = expressionType.capture(scope, 0); |
989 |
// simulate capture in case checked binding did not properly get extracted from a reference |
983 |
return expression.checkCastTypesCompatibility(scope, this.binding, expressionType, null); |
990 |
expressionType = expressionType.capture(scope, 0); |
|
|
991 |
return expression.checkCastTypesCompatibility(scope, this.binding, expressionType, null); |
992 |
} catch (AbortCompilation e) { |
993 |
// don't surface internal exception to clients |
994 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=143013 |
995 |
return false; |
996 |
} |
984 |
} |
997 |
} |
985 |
|
998 |
|
986 |
/* |
999 |
/* |
Lines 1145-1155
Link Here
|
1145 |
* @see ITypeBinding#isSubTypeCompatible(ITypeBinding) |
1158 |
* @see ITypeBinding#isSubTypeCompatible(ITypeBinding) |
1146 |
*/ |
1159 |
*/ |
1147 |
public boolean isSubTypeCompatible(ITypeBinding type) { |
1160 |
public boolean isSubTypeCompatible(ITypeBinding type) { |
1148 |
if (this == type) return true; |
1161 |
try { |
1149 |
if (this.binding.isBaseType()) return false; |
1162 |
if (this == type) return true; |
1150 |
TypeBinding other = (TypeBinding) type; |
1163 |
if (this.binding.isBaseType()) return false; |
1151 |
if (other.binding.isBaseType()) return false; |
1164 |
TypeBinding other = (TypeBinding) type; |
1152 |
return this.binding.isCompatibleWith(other.binding); |
1165 |
if (other.binding.isBaseType()) return false; |
|
|
1166 |
return this.binding.isCompatibleWith(other.binding); |
1167 |
} catch (AbortCompilation e) { |
1168 |
// don't surface internal exception to clients |
1169 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=143013 |
1170 |
return false; |
1171 |
} |
1153 |
} |
1172 |
} |
1154 |
|
1173 |
|
1155 |
/** |
1174 |
/** |