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

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/ITypeParameter.java (-1 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 42-47 Link Here
42
	String[] getBounds() throws JavaModelException;
42
	String[] getBounds() throws JavaModelException;
43
43
44
	/**
44
	/**
45
	 * Returns the signatures for this type parameter's bounds. The type parameter may have 
46
	 * been declared as part of a type or a method. The signatures represent only the individual 
47
	 * bounds and do not include the type variable name or the <code>extends</code> keyword.  
48
	 * <p>
49
	 * The signatures may be either unresolved (for source types) or resolved (for binary types). 
50
	 * See {@link Signature} for details.
51
	 * </p>
52
	 * 
53
	 * @return the signature for this formal type parameter
54
	 * @throws JavaModelException
55
	 *             if this element doesn't exist or if an exception occurs while accessing its corresponding resource.
56
	 * @see Signature
57
	 * @since 3.6
58
	 */
59
	String[] getBoundsSignatures() throws JavaModelException;
60
	
61
	/**
45
	 * Returns the declaring member of this type parameter. This can be either an <code>IType</code>
62
	 * Returns the declaring member of this type parameter. This can be either an <code>IType</code>
46
	 * or an <code>IMethod</code>.
63
	 * or an <code>IMethod</code>.
47
	 * <p>
64
	 * <p>
(-)model/org/eclipse/jdt/internal/core/ClassFileInfo.java (-1 / +2 lines)
Lines 296-311 Link Here
296
	for (int i = 0, typeParameterCount = typeParameterSignatures.length; i < typeParameterCount; i++) {
296
	for (int i = 0, typeParameterCount = typeParameterSignatures.length; i < typeParameterCount; i++) {
297
		char[] typeParameterSignature = typeParameterSignatures[i];
297
		char[] typeParameterSignature = typeParameterSignatures[i];
298
		char[] typeParameterName = Signature.getTypeVariable(typeParameterSignature);
298
		char[] typeParameterName = Signature.getTypeVariable(typeParameterSignature);
299
		CharOperation.replace(typeParameterSignature, '/', '.');
299
		char[][] typeParameterBoundSignatures = Signature.getTypeParameterBounds(typeParameterSignature);
300
		char[][] typeParameterBoundSignatures = Signature.getTypeParameterBounds(typeParameterSignature);
300
		int boundLength = typeParameterBoundSignatures.length;
301
		int boundLength = typeParameterBoundSignatures.length;
301
		char[][] typeParameterBounds = new char[boundLength][];
302
		char[][] typeParameterBounds = new char[boundLength][];
302
		for (int j = 0; j < boundLength; j++) {
303
		for (int j = 0; j < boundLength; j++) {
303
			typeParameterBounds[j] = Signature.toCharArray(typeParameterBoundSignatures[j]);
304
			typeParameterBounds[j] = Signature.toCharArray(typeParameterBoundSignatures[j]);
304
			CharOperation.replace(typeParameterBounds[j], '/', '.');
305
		}
305
		}
306
		TypeParameter typeParameter = new TypeParameter(parent, new String(typeParameterName));
306
		TypeParameter typeParameter = new TypeParameter(parent, new String(typeParameterName));
307
		TypeParameterElementInfo info = new TypeParameterElementInfo();
307
		TypeParameterElementInfo info = new TypeParameterElementInfo();
308
		info.bounds = typeParameterBounds;
308
		info.bounds = typeParameterBounds;
309
		info.boundsSignatures = typeParameterBoundSignatures;
309
		typeParameterHandles.add(typeParameter);
310
		typeParameterHandles.add(typeParameter);
310
311
311
		// ensure that 2 binary methods with the same signature but with different return types have different occurence counts.
312
		// ensure that 2 binary methods with the same signature but with different return types have different occurence counts.
(-)model/org/eclipse/jdt/internal/core/TypeParameter.java (-2 / +30 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
2
 * Copyright (c) 2004, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 33-39 Link Here
33
		TypeParameterElementInfo info = (TypeParameterElementInfo) getElementInfo();
33
		TypeParameterElementInfo info = (TypeParameterElementInfo) getElementInfo();
34
		return CharOperation.toStrings(info.bounds);
34
		return CharOperation.toStrings(info.bounds);
35
	}
35
	}
36
36
	
37
	public String[] getBoundsSignatures() throws JavaModelException {
38
		
39
		String[] boundSignatures = null;
40
		TypeParameterElementInfo info = (TypeParameterElementInfo) this.getElementInfo();
41
		
42
		// For a binary type or method, the signature is already available from the .class file.
43
		// No need to construct again
44
		if (this.parent instanceof BinaryMember) {
45
			char[][] boundsSignatures = info.boundsSignatures;
46
			if (boundsSignatures == null || boundsSignatures.length == 0) {
47
				return CharOperation.NO_STRINGS;	
48
			}
49
			return CharOperation.toStrings(info.boundsSignatures);
50
		}
51
		
52
		char[][] bounds = info.bounds;
53
		if (bounds == null || bounds.length == 0) {
54
			return CharOperation.NO_STRINGS;
55
		}
56
	
57
		int boundsLength = bounds.length;
58
		boundSignatures = new String[boundsLength];
59
		for (int i = 0; i < boundsLength; i++) {
60
			boundSignatures[i] = new String(Signature.createCharArrayTypeSignature(bounds[i], false));
61
		}
62
		return boundSignatures;
63
	}
64
	
37
	public IMember getDeclaringMember() {
65
	public IMember getDeclaringMember() {
38
			return (IMember) getParent();
66
			return (IMember) getParent();
39
	}
67
	}
(-)model/org/eclipse/jdt/internal/core/TypeParameterElementInfo.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
2
 * Copyright (c) 2004, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 28-31 Link Here
28
	 * The bounds names of this type parameter.
28
	 * The bounds names of this type parameter.
29
	 */
29
	 */
30
	public char[][] bounds;
30
	public char[][] bounds;
31
	
32
	/*
33
	 * The bounds' signatures for this type parameter. 
34
	 */
35
	public char[][] boundsSignatures;
31
}
36
}
(-)src/org/eclipse/jdt/core/tests/model/ClassFileTests.java (-3 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 60-66 Link Here
60
		"  <U extends Exception> X<T> foo(X<T> x) throws RuntimeException, U {\n" +
60
		"  <U extends Exception> X<T> foo(X<T> x) throws RuntimeException, U {\n" +
61
		"    return null;\n" +
61
		"    return null;\n" +
62
		"  }\n" +
62
		"  }\n" +
63
		"  <K, V> V foo(K key, V value) throws Exception {\n" +
63
		"  <K, V extends T> V foo(K key, V value) throws Exception {\n" +
64
		"    return value;\n" +
64
		"    return value;\n" +
65
		"  }\n" +
65
		"  }\n" +
66
		"}",
66
		"}",
Lines 1094-1100 Link Here
1094
	assertStringsEqual(
1094
	assertStringsEqual(
1095
		"Unexpected type parameters",
1095
		"Unexpected type parameters",
1096
		"K:Ljava.lang.Object;\n" +
1096
		"K:Ljava.lang.Object;\n" +
1097
		"V:Ljava.lang.Object;\n",
1097
		"V:TT;\n",
1098
		method.getTypeParameterSignatures());
1098
		method.getTypeParameterSignatures());
1099
}
1099
}
1100
1100
Lines 1523-1526 Link Here
1523
		"Ljava.util.Collection<Ljava.lang.String;>;",
1523
		"Ljava.util.Collection<Ljava.lang.String;>;",
1524
		field.getTypeSignature());
1524
		field.getTypeSignature());
1525
}
1525
}
1526
1527
	public void testBug246594() throws JavaModelException {
1528
		IType type = this.jarRoot.getPackageFragment("generic").getClassFile(
1529
				"Z.class").getType();
1530
		ITypeParameter typeParam = type.getTypeParameter("T");
1531
		assertNotNull(typeParam);
1532
		assertStringsEqual("type parameter bound signatures",
1533
				"Ljava.lang.Object;\n" +
1534
				"Lgeneric.I<-TT;>;\n", 
1535
				typeParam.getBoundsSignatures());
1536
	}
1537
1538
	public void testBug246594a() throws JavaModelException {
1539
		IType type = this.jarRoot.getPackageFragment("generic").getClassFile(
1540
				"X.class").getType();
1541
		IMethod method = type.getMethod("foo", new String[] { "TK;", "TV;" });
1542
		ITypeParameter typeParam = method.getTypeParameter("V");
1543
		assertStringsEqual("type parameter bound signatures", 
1544
							"TT;\n", typeParam.getBoundsSignatures());
1545
	}
1546
1526
}
1547
}
(-)src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java (-1 / +34 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 2436-2439 Link Here
2436
	annotations);
2436
	annotations);
2437
}
2437
}
2438
2438
2439
public void testBug246594() throws CoreException {
2440
	createWorkingCopy(
2441
		"package p;\n" +
2442
		"public class Z<T extends Object & I<? super T>> {\n" +
2443
		"}\n" +
2444
		"public interface I<T> {}"
2445
	);
2446
	IType type = this.workingCopy.getType("Z");
2447
	ITypeParameter[] typeParameters = type.getTypeParameters();
2448
	assertStringsEqual("Type parameter signature", "T:QObject;:QI<-QT;>;\n", type.getTypeParameterSignatures());
2449
	assertStringsEqual("Type parameter signature", 
2450
					"QObject;\n" +
2451
					"QI<-QT;>;\n", 
2452
					typeParameters[0].getBoundsSignatures());
2453
}
2454
public void testBug246594a() throws CoreException {
2455
	createWorkingCopy(
2456
		"package p;\n" +
2457
		"interface Collection<E> {\n" +
2458
		"public <T> boolean containsAll(Collection<T> c);\n" +
2459
		"public <T extends E & I<? super String>> boolean addAll(Collection<T> c);\n" +
2460
		"}" +
2461
		"public interface I<T> {}");
2462
	IMethod[] methods = this.workingCopy.getType("Collection").getMethods();//<T:TE;>
2463
	ITypeParameter[] typeParameters = methods[1].getTypeParameters();
2464
	assertStringsEqual("Type parameter signature", 
2465
			"QE;\n" +
2466
			"QI<-QString;>;\n", 
2467
			typeParameters[0].getBoundsSignatures());
2468
	
2469
}
2470
2471
2439
}
2472
}

Return to bug 246594