View | Details | Raw Unified | Return to bug 143013
Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/TypeBinding.java (-21 / +40 lines)
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
	/**
(-)dom/org/eclipse/jdt/core/dom/MethodBinding.java (-22 / +35 lines)
Lines 28-33 Link Here
28
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
31
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
31
import org.eclipse.jdt.internal.core.JavaElement;
32
import org.eclipse.jdt.internal.core.JavaElement;
32
import org.eclipse.jdt.internal.core.Member;
33
import org.eclipse.jdt.internal.core.Member;
33
import org.eclipse.jdt.internal.core.util.Util;
34
import org.eclipse.jdt.internal.core.util.Util;
Lines 411-420 Link Here
411
	}
412
	}
412
	
413
	
413
	public boolean isSubsignature(IMethodBinding otherMethod) {
414
	public boolean isSubsignature(IMethodBinding otherMethod) {
414
		org.eclipse.jdt.internal.compiler.lookup.MethodBinding other = ((MethodBinding) otherMethod).binding;
415
		try {
415
		if (!CharOperation.equals(this.binding.selector, other.selector))
416
			org.eclipse.jdt.internal.compiler.lookup.MethodBinding other = ((MethodBinding) otherMethod).binding;
417
			if (!CharOperation.equals(this.binding.selector, other.selector))
418
				return false;
419
			return this.binding.areParameterErasuresEqual(other) && this.binding.areTypeVariableErasuresEqual(other);
420
		} catch (AbortCompilation e) {
421
			// don't surface internal exception to clients
422
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=143013
416
			return false;
423
			return false;
417
		return this.binding.areParameterErasuresEqual(other) && this.binding.areTypeVariableErasuresEqual(other);
424
		}
418
	}
425
	}
419
426
420
	/**
427
	/**
Lines 428-455 Link Here
428
	 * @see IMethodBinding#overrides(IMethodBinding)
435
	 * @see IMethodBinding#overrides(IMethodBinding)
429
	 */
436
	 */
430
	public boolean overrides(IMethodBinding overridenMethod) {
437
	public boolean overrides(IMethodBinding overridenMethod) {
431
		org.eclipse.jdt.internal.compiler.lookup.MethodBinding overridenCompilerBinding = ((MethodBinding) overridenMethod).binding;
438
		try {
432
		if (this.binding == overridenCompilerBinding) 
439
			org.eclipse.jdt.internal.compiler.lookup.MethodBinding overridenCompilerBinding = ((MethodBinding) overridenMethod).binding;
440
			if (this.binding == overridenCompilerBinding) 
441
				return false;
442
			char[] selector = this.binding.selector;
443
			if (!CharOperation.equals(selector, overridenCompilerBinding.selector))
444
				return false;
445
			TypeBinding match = this.binding.declaringClass.findSuperTypeWithSameErasure(overridenCompilerBinding.declaringClass);
446
			if (!(match instanceof ReferenceBinding)) return false;
447
			
448
			org.eclipse.jdt.internal.compiler.lookup.MethodBinding[] superMethods = ((ReferenceBinding)match).getMethods(selector);
449
			for (int i = 0, length = superMethods.length; i < length; i++) {
450
				if (superMethods[i].original() == overridenCompilerBinding) {
451
					LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment();
452
					if (lookupEnvironment == null) return false;
453
					MethodVerifier methodVerifier = lookupEnvironment.methodVerifier();
454
					org.eclipse.jdt.internal.compiler.lookup.MethodBinding superMethod = superMethods[i];
455
					return !superMethod.isPrivate() 
456
						&& !(superMethod.isDefault() && (superMethod.declaringClass.getPackage()) != this.binding.declaringClass.getPackage())
457
						&& methodVerifier.doesMethodOverride(this.binding, superMethod);
458
				}
459
			}
433
			return false;
460
			return false;
434
		char[] selector = this.binding.selector;
461
		} catch (AbortCompilation e) {
435
		if (!CharOperation.equals(selector, overridenCompilerBinding.selector))
462
			// don't surface internal exception to clients
463
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=143013
436
			return false;
464
			return false;
437
		TypeBinding match = this.binding.declaringClass.findSuperTypeWithSameErasure(overridenCompilerBinding.declaringClass);
438
		if (!(match instanceof ReferenceBinding)) return false;
439
		
440
		org.eclipse.jdt.internal.compiler.lookup.MethodBinding[] superMethods = ((ReferenceBinding)match).getMethods(selector);
441
		for (int i = 0, length = superMethods.length; i < length; i++) {
442
			if (superMethods[i].original() == overridenCompilerBinding) {
443
				LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment();
444
				if (lookupEnvironment == null) return false;
445
				MethodVerifier methodVerifier = lookupEnvironment.methodVerifier();
446
				org.eclipse.jdt.internal.compiler.lookup.MethodBinding superMethod = superMethods[i];
447
				return !superMethod.isPrivate() 
448
					&& !(superMethod.isDefault() && (superMethod.declaringClass.getPackage()) != this.binding.declaringClass.getPackage())
449
					&& methodVerifier.doesMethodOverride(this.binding, superMethod);
450
			}
451
		}
465
		}
452
		return false;
453
	}
466
	}
454
467
455
	/**
468
	/**

Return to bug 143013