View | Details | Raw Unified | Return to bug 188103 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-2 / +2 lines)
Lines 31414-31425 Link Here
31414
			"1. WARNING in X.java (at line 4)\n" + 
31414
			"1. WARNING in X.java (at line 4)\n" + 
31415
			"	List<Class<Object>>  lco = Arrays.asList(String.class, Integer.class, Long.class);\n" + 
31415
			"	List<Class<Object>>  lco = Arrays.asList(String.class, Integer.class, Long.class);\n" + 
31416
			"	                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
31416
			"	                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
31417
			"Type safety : A generic array of Class<? extends Object&Comparable<?>&Serializable> is created for a varargs parameter\n" + 
31417
			"Type safety : A generic array of Class<? extends Object&Serializable&Comparable<?>> is created for a varargs parameter\n" + 
31418
			"----------\n" + 
31418
			"----------\n" + 
31419
			"2. ERROR in X.java (at line 4)\n" + 
31419
			"2. ERROR in X.java (at line 4)\n" + 
31420
			"	List<Class<Object>>  lco = Arrays.asList(String.class, Integer.class, Long.class);\n" + 
31420
			"	List<Class<Object>>  lco = Arrays.asList(String.class, Integer.class, Long.class);\n" + 
31421
			"	                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
31421
			"	                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
31422
			"Type mismatch: cannot convert from List<Class<? extends Object&Comparable<?>&Serializable>> to List<Class<Object>>\n" + 
31422
			"Type mismatch: cannot convert from List<Class<? extends Object&Serializable&Comparable<?>>> to List<Class<Object>>\n" + 
31423
			"----------\n");
31423
			"----------\n");
31424
}
31424
}
31425
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=91709
31425
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=91709
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-29 / +53 lines)
Lines 2536-2547 Link Here
2536
			nextCandidate: for (int k = 0, max = mecs.length; k < max; k++) {
2536
			nextCandidate: for (int k = 0, max = mecs.length; k < max; k++) {
2537
				TypeBinding mec = mecs[k];
2537
				TypeBinding mec = mecs[k];
2538
				if (mec == null) continue nextCandidate;
2538
				if (mec == null) continue nextCandidate;
2539
				Set invalidInvocations = (Set) invocations.get(mec);
2539
				Object value = invocations.get(mec);
2540
				int invalidSize = invalidInvocations.size();
2540
				if (value instanceof List) {
2541
				if (invalidSize > 1) {
2541
					List invalidInvocations = (List) value;
2542
					TypeBinding[] collisions;
2542
					TypeBinding firstInvocation = (TypeBinding) invalidInvocations.get(0);
2543
					invalidInvocations.toArray(collisions = new TypeBinding[invalidSize]);
2543
					TypeBinding secondInvocation = (TypeBinding) invalidInvocations.get(1);
2544
					problemReporter().superinterfacesCollide(collisions[0].erasure(), typeRef, collisions[0], collisions[1]);
2544
					problemReporter().superinterfacesCollide(firstInvocation.erasure(), typeRef, firstInvocation, secondInvocation);
2545
					type.tagBits |= TagBits.HierarchyHasProblems;
2545
					type.tagBits |= TagBits.HierarchyHasProblems;
2546
					return true;
2546
					return true;
2547
				}
2547
				}
Lines 2756-2763 Link Here
2756
		return false;
2756
		return false;
2757
	}
2757
	}
2758
2758
2759
	private TypeBinding leastContainingInvocation(TypeBinding mec, Set invocations, List lubStack) {
2759
	private TypeBinding leastContainingInvocation(TypeBinding mec, Object invocationValue, List lubStack) {
2760
		if (invocations == null) return mec; // no alternate invocation
2760
		if (invocationValue == null) return mec; // no alternate invocation
2761
		if (!(invocationValue instanceof List)) { // only one invocation, simply return it (list only allocated if more than one)
2762
			return (TypeBinding) invocationValue;
2763
		}
2764
		List invocations = (List) invocationValue;
2761
		int length = invocations.size();
2765
		int length = invocations.size();
2762
		Iterator iter = invocations.iterator();
2766
		Iterator iter = invocations.iterator();
2763
		if (length == 1) return (TypeBinding) iter.next();
2767
		if (length == 1) return (TypeBinding) iter.next();
Lines 2928-2934 Link Here
2928
		for (int i = 0; i < length; i++) {
2932
		for (int i = 0; i < length; i++) {
2929
			TypeBinding mec = mecs[i];
2933
			TypeBinding mec = mecs[i];
2930
			if (mec == null) continue;
2934
			if (mec == null) continue;
2931
			mec = leastContainingInvocation(mec, (Set)invocations.get(mec), lubStack);
2935
			mec = leastContainingInvocation(mec, invocations.get(mec), lubStack);
2932
			if (mec == null) return null;
2936
			if (mec == null) return null;
2933
			int dim = mec.dimensions();
2937
			int dim = mec.dimensions();
2934
			if (commonDim == -1) {
2938
			if (commonDim == -1) {
Lines 3001-3009 Link Here
3001
		TypeBinding leafType = firstType.leafComponentType();
3005
		TypeBinding leafType = firstType.leafComponentType();
3002
		TypeBinding firstErasure = (leafType.isTypeVariable() || leafType.isWildcard()/*&& !leafType.isCapture()*/) ? firstType : firstType.erasure();
3006
		TypeBinding firstErasure = (leafType.isTypeVariable() || leafType.isWildcard()/*&& !leafType.isCapture()*/) ? firstType : firstType.erasure();
3003
		if (firstErasure != firstType) {
3007
		if (firstErasure != firstType) {
3004
			Set someInvocations = new HashSet(1);
3008
			allInvocations.put(firstErasure, firstType);
3005
			someInvocations.add(firstType);
3006
			allInvocations.put(firstErasure, someInvocations);
3007
		}						
3009
		}						
3008
		typesToVisit.add(firstType);
3010
		typesToVisit.add(firstType);
3009
		int max = 1;
3011
		int max = 1;
Lines 3063-3071 Link Here
3063
						max++;
3065
						max++;
3064
						TypeBinding superTypeErasure = (firstBound.isTypeVariable() || firstBound.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure();
3066
						TypeBinding superTypeErasure = (firstBound.isTypeVariable() || firstBound.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure();
3065
						if (superTypeErasure != superType) {
3067
						if (superTypeErasure != superType) {
3066
							Set someInvocations = new HashSet(1);
3068
							allInvocations.put(superTypeErasure, superType);
3067
							someInvocations.add(superType);
3068
							allInvocations.put(superTypeErasure, someInvocations);
3069
						}						
3069
						}						
3070
					}
3070
					}
3071
					continue;
3071
					continue;
Lines 3082-3090 Link Here
3082
						max++;
3082
						max++;
3083
						TypeBinding superTypeErasure = (itsInterface.isTypeVariable() || itsInterface.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure();
3083
						TypeBinding superTypeErasure = (itsInterface.isTypeVariable() || itsInterface.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure();
3084
						if (superTypeErasure != superType) {
3084
						if (superTypeErasure != superType) {
3085
							Set someInvocations = new HashSet(1);
3085
							allInvocations.put(superTypeErasure, superType);
3086
							someInvocations.add(superType);
3087
							allInvocations.put(superTypeErasure, someInvocations);
3088
						}						
3086
						}						
3089
					}
3087
					}
3090
				}
3088
				}
Lines 3097-3105 Link Here
3097
					max++;
3095
					max++;
3098
					TypeBinding superTypeErasure = (itsSuperclass.isTypeVariable() || itsSuperclass.isWildcard() /*&& !itsSuperclass.isCapture()*/) ? superType : superType.erasure();
3096
					TypeBinding superTypeErasure = (itsSuperclass.isTypeVariable() || itsSuperclass.isWildcard() /*&& !itsSuperclass.isCapture()*/) ? superType : superType.erasure();
3099
					if (superTypeErasure != superType) {
3097
					if (superTypeErasure != superType) {
3100
						Set someInvocations = new HashSet(1);
3098
						allInvocations.put(superTypeErasure, superType);
3101
						someInvocations.add(superType);
3102
						allInvocations.put(superTypeErasure, someInvocations);
3103
					}
3099
					}
3104
				}
3100
				}
3105
			}
3101
			}
Lines 3128-3137 Link Here
3128
						continue nextSuperType;
3124
						continue nextSuperType;
3129
					}
3125
					}
3130
					// record invocation
3126
					// record invocation
3131
					Set someInvocations = (Set) allInvocations.get(erasedSuperType);
3127
					Object value = allInvocations.get(erasedSuperType);
3132
					if (someInvocations == null) someInvocations = new HashSet(1);
3128
					if (value == null) {
3133
					someInvocations.add(match);
3129
						allInvocations.put(erasedSuperType, match);
3134
					allInvocations.put(erasedSuperType, someInvocations);
3130
					} else if (!(value instanceof List)) {
3131
						if (match != value) {
3132
							// using a list to record invocations in order (188103)
3133
							List someInvocations = new ArrayList(2);
3134
							someInvocations.add(value);
3135
							someInvocations.add(match);
3136
							allInvocations.put(erasedSuperType, someInvocations);
3137
						}
3138
					} else {
3139
						List someInvocations = (List) value;
3140
						if (!someInvocations.contains(match)) {
3141
							someInvocations.add(match);
3142
							allInvocations.put(erasedSuperType, someInvocations);
3143
						}
3144
					}
3135
				}
3145
				}
3136
				continue nextOtherType;
3146
				continue nextOtherType;
3137
			}
3147
			}
Lines 3154-3163 Link Here
3154
					}
3164
					}
3155
				}
3165
				}
3156
				// record invocation
3166
				// record invocation
3157
				Set someInvocations = (Set) allInvocations.get(erasedSuperType);
3167
				Object value = allInvocations.get(erasedSuperType);
3158
				if (someInvocations == null) someInvocations = new HashSet(1);
3168
				if (value == null) {
3159
				someInvocations.add(match);
3169
					allInvocations.put(erasedSuperType, match);
3160
				allInvocations.put(erasedSuperType, someInvocations);
3170
				} else if (!(value instanceof List)) {
3171
					if (match != value) {
3172
						// using a list to record invocations in order (188103)
3173
						List someInvocations = new ArrayList(2);
3174
						someInvocations.add(value);
3175
						someInvocations.add(match);
3176
						allInvocations.put(erasedSuperType, someInvocations);
3177
					}
3178
				} else {
3179
					List someInvocations = (List) value;
3180
					if (!someInvocations.contains(match)) {
3181
						someInvocations.add(match);
3182
						allInvocations.put(erasedSuperType, someInvocations);
3183
					}
3184
				}
3161
			}				
3185
			}				
3162
		}
3186
		}
3163
		// eliminate non minimal super types
3187
		// eliminate non minimal super types

Return to bug 188103