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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java (+4 lines)
Lines 106-111 Link Here
106
			this.returnType = Scope.substitute(substitution, this.returnType);
106
			this.returnType = Scope.substitute(substitution, this.returnType);
107
			this.parameters = Scope.substitute(substitution, this.parameters);
107
			this.parameters = Scope.substitute(substitution, this.parameters);
108
			this.thrownExceptions = Scope.substitute(substitution, this.thrownExceptions);
108
			this.thrownExceptions = Scope.substitute(substitution, this.thrownExceptions);
109
		    // error case where exception type variable would have been substituted by a non-reference type (207573)
110
		    if (this.thrownExceptions == null) this.thrownExceptions = Binding.NO_EXCEPTIONS;	    			
109
		}
111
		}
110
	}
112
	}
111
	
113
	
Lines 195-200 Link Here
195
			this.returnType = Scope.substitute(substitution, this.returnType);
197
			this.returnType = Scope.substitute(substitution, this.returnType);
196
			this.parameters = Scope.substitute(substitution, this.parameters);
198
			this.parameters = Scope.substitute(substitution, this.parameters);
197
			this.thrownExceptions = Scope.substitute(substitution, this.thrownExceptions);
199
			this.thrownExceptions = Scope.substitute(substitution, this.thrownExceptions);
200
		    // error case where exception type variable would have been substituted by a non-reference type (207573)
201
		    if (this.thrownExceptions == null) this.thrownExceptions = Binding.NO_EXCEPTIONS;	    			
198
		}
202
		}
199
	}
203
	}
200
204
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-3 / +6 lines)
Lines 199-210 Link Here
199
	    ReferenceBinding[] substitutedTypes = originalTypes;
199
	    ReferenceBinding[] substitutedTypes = originalTypes;
200
	    for (int i = 0, length = originalTypes.length; i < length; i++) {
200
	    for (int i = 0, length = originalTypes.length; i < length; i++) {
201
	        ReferenceBinding originalType = originalTypes[i];
201
	        ReferenceBinding originalType = originalTypes[i];
202
	        ReferenceBinding substitutedParameter = (ReferenceBinding)substitute(substitution, originalType);
202
	        TypeBinding substitutedType = substitute(substitution, originalType);
203
	        if (substitutedParameter != originalType) {
203
	        if (!(substitutedType instanceof ReferenceBinding)) {
204
	        	return null; // impossible substitution
205
	        }
206
	        if (substitutedType != originalType) {
204
	            if (substitutedTypes == originalTypes) {
207
	            if (substitutedTypes == originalTypes) {
205
	                System.arraycopy(originalTypes, 0, substitutedTypes = new ReferenceBinding[length], 0, i);
208
	                System.arraycopy(originalTypes, 0, substitutedTypes = new ReferenceBinding[length], 0, i);
206
	            }
209
	            }
207
	            substitutedTypes[i] = substitutedParameter;
210
	            substitutedTypes[i] = (ReferenceBinding)substitutedType;
208
	        } else if (substitutedTypes != originalTypes) {
211
	        } else if (substitutedTypes != originalTypes) {
209
	            substitutedTypes[i] = originalType;
212
	            substitutedTypes[i] = originalType;
210
	        }
213
	        }
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java (+6 lines)
Lines 283-288 Link Here
283
	    this.thrownExceptions = Scope.substitute(this, 	ignoreRawTypeSubstitution 
283
	    this.thrownExceptions = Scope.substitute(this, 	ignoreRawTypeSubstitution 
284
	    									? originalMethod.thrownExceptions // no substitution if original was static
284
	    									? originalMethod.thrownExceptions // no substitution if original was static
285
	    									: Scope.substitute(rawType, originalMethod.thrownExceptions));
285
	    									: Scope.substitute(rawType, originalMethod.thrownExceptions));
286
	    // error case where exception type variable would have been substituted by a non-reference type (207573)
287
	    if (this.thrownExceptions == null) this.thrownExceptions = Binding.NO_EXCEPTIONS;	    	    
286
	    this.returnType = Scope.substitute(this, ignoreRawTypeSubstitution 
288
	    this.returnType = Scope.substitute(this, ignoreRawTypeSubstitution 
287
	    									? originalMethod.returnType // no substitution if original was static
289
	    									? originalMethod.returnType // no substitution if original was static
288
	    									: Scope.substitute(rawType, originalMethod.returnType));
290
	    									: Scope.substitute(rawType, originalMethod.returnType));
Lines 305-310 Link Here
305
	    this.originalMethod = originalMethod;
307
	    this.originalMethod = originalMethod;
306
	    this.parameters = Scope.substitute(this, originalMethod.parameters);
308
	    this.parameters = Scope.substitute(this, originalMethod.parameters);
307
	    this.thrownExceptions = Scope.substitute(this, originalMethod.thrownExceptions);
309
	    this.thrownExceptions = Scope.substitute(this, originalMethod.thrownExceptions);
310
	    // error case where exception type variable would have been substituted by a non-reference type (207573)
311
	    if (this.thrownExceptions == null) this.thrownExceptions = Binding.NO_EXCEPTIONS;	    	    
308
	    this.returnType = Scope.substitute(this, originalMethod.returnType);
312
	    this.returnType = Scope.substitute(this, originalMethod.returnType);
309
	    this.wasInferred = true;// resulting from method invocation inferrence
313
	    this.wasInferred = true;// resulting from method invocation inferrence
310
	}
314
	}
Lines 431-436 Link Here
431
		this.inferredReturnType = inferenceContext.hasExplicitExpectedType && this.returnType != oldReturnType;
435
		this.inferredReturnType = inferenceContext.hasExplicitExpectedType && this.returnType != oldReturnType;
432
	    this.parameters = Scope.substitute(this, this.parameters);
436
	    this.parameters = Scope.substitute(this, this.parameters);
433
	    this.thrownExceptions = Scope.substitute(this, this.thrownExceptions);
437
	    this.thrownExceptions = Scope.substitute(this, this.thrownExceptions);
438
	    // error case where exception type variable would have been substituted by a non-reference type (207573)
439
	    if (this.thrownExceptions == null) this.thrownExceptions = Binding.NO_EXCEPTIONS;	    
434
	    return this;
440
	    return this;
435
	}
441
	}
436
442
(-)buildnotes_jdt-core.html (-1 / +3 lines)
Lines 54-60 Link Here
54
<h2>What's new in this drop</h2>
54
<h2>What's new in this drop</h2>
55
55
56
<h3>Problem Reports Fixed</h3>
56
<h3>Problem Reports Fixed</h3>
57
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=208263">208263</a>
57
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=207573">207573</a>
58
[1.5][compiler] Internal compiler error: ClassCastException / ArrayBinding
59
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=208263">208263</a>
58
[ast rewrite] performance problems with lots of changes
60
[ast rewrite] performance problems with lots of changes
59
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=207441">207441</a>
61
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=207441">207441</a>
60
Wrong delta for files created in folders that are on a java project as classes folder
62
Wrong delta for files created in folders that are on a java project as classes folder
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+100 lines)
Lines 38785-38788 Link Here
38785
		},
38785
		},
38786
		"");
38786
		"");
38787
}
38787
}
38788
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=207573
38789
public void test1206() {
38790
	this.runConformTest(
38791
		new String[] {
38792
			"X.java",
38793
			"public class X {\n" + 
38794
			"	public final <E extends Exception> E throwE(E ex, Object... args) throws E {\n" + 
38795
			"		Object[] oar = new Object[0];\n" + 
38796
			"		return throwE(oar, ex, args);\n" + 
38797
			"	}\n" + 
38798
			"\n" + 
38799
			"	public final <E extends Exception> E throwE(Object[] oar, E ex, Object... args) throws E {\n" + 
38800
			"		throw ex;\n" + 
38801
			"	}\n" + 
38802
			"}", // =================
38803
		},
38804
		"");
38805
}
38806
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=207573 - variation
38807
public void test1207() {
38808
	this.runNegativeTest(
38809
		new String[] {
38810
			"X.java",
38811
			"public class X {\n" + 
38812
			"    public final <E extends Exception> E throwE (E ex) throws E {\n" + 
38813
			"    	throw ex;\n" + 
38814
			"    }\n" + 
38815
			"    void foo(Object[] objs) {\n" + 
38816
			"    	throwE(objs);\n" + 
38817
			"    }\n" + 
38818
			"}\n", // =================
38819
		},
38820
		"----------\n" + 
38821
		"1. ERROR in X.java (at line 6)\r\n" + 
38822
		"	throwE(objs);\r\n" + 
38823
		"	^^^^^^\n" + 
38824
		"Bound mismatch: The generic method throwE(E) of type X is not applicable for the arguments (Object[]). The inferred type Object[] is not a valid substitute for the bounded parameter <E extends Exception>\n" + 
38825
		"----------\n");
38826
}
38827
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=207573 - variation
38828
public void test1208() {
38829
	this.runConformTest(
38830
		new String[] {
38831
			"X.java",
38832
			"public class X {\n" + 
38833
			"	public final <E extends Exception> E throwE2(E ex, Object... args) throws E {\n" + 
38834
			"		Object[] oar = new Object[0];\n" + 
38835
			"		return throwE(oar, ex, args);\n" + 
38836
			"	}\n" + 
38837
			"\n" + 
38838
			"	public final <E extends Exception> E throwE(Object[] oar, E ex, Object... args) throws E {\n" + 
38839
			"		throw ex;\n" + 
38840
			"	}\n" + 
38841
			"}", // =================
38842
		},
38843
		"");
38844
}
38845
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=207573 - variation
38846
public void test1209() {
38847
	this.runNegativeTest(
38848
		new String[] {
38849
			"X.java",
38850
			"public class X {\n" + 
38851
			"    public final <E extends Exception> E throwE (E ex, Object ... args) throws E {\n" + 
38852
			"    	throw ex;\n" + 
38853
			"    }\n" + 
38854
			"    void foo(Object[] objs) {\n" + 
38855
			"    	throwE(objs);\n" + 
38856
			"    }\n" + 
38857
			"}", // =================
38858
		},
38859
		"----------\n" + 
38860
		"1. ERROR in X.java (at line 6)\r\n" + 
38861
		"	throwE(objs);\r\n" + 
38862
		"	^^^^^^\n" + 
38863
		"Bound mismatch: The generic method throwE(E, Object...) of type X is not applicable for the arguments (Object[]). The inferred type Object[] is not a valid substitute for the bounded parameter <E extends Exception>\n" + 
38864
		"----------\n");
38865
}
38866
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=207573 - variation
38867
public void test1210() {
38868
	this.runNegativeTest(
38869
		new String[] {
38870
			"X.java",
38871
			"public class X {\n" + 
38872
			"    public final <E extends Exception> E throwE (Object ... args) throws E {\n" + 
38873
			"    	return null;\n" + 
38874
			"    }\n" + 
38875
			"    void foo(Object[] objs) {\n" + 
38876
			"    	Object[] o  = throwE(objs);\n" + 
38877
			"    }\n" + 
38878
			"}\n", // =================
38879
		},
38880
		"----------\n" + 
38881
		"1. ERROR in X.java (at line 6)\n" + 
38882
		"	Object[] o  = throwE(objs);\n" + 
38883
		"	              ^^^^^^\n" + 
38884
		"Bound mismatch: The generic method throwE(Object...) of type X is not applicable for the arguments (Object[]). The inferred type Object[] is not a valid substitute for the bounded parameter <E extends Exception>\n" + 
38885
		"----------\n");
38886
}
38887
38788
}
38888
}

Return to bug 207573