Bug 133918

Summary: [1.5][compiler] Duplicate return; in CastExpression line 258
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Olivier Thomann CLA 2006-03-29 15:01:57 EST
This code:
if (!lastArgType.isCompatibleWith(varargsType.elementsType()))
	return;
	return;
looks suspicious.

Removing the second return; breaks some existing tests in org.eclipse.jdt.core.tests.compiler.regression.VarargsTest. See test029, 038, 043, 028 and 045.
Comment 1 Philipe Mulet CLA 2006-03-31 11:12:02 EST
Note that the released code is missing unnecessary cast diagnostic for:

public class X {
	void foo(Throwable... exceptions) {
	}
	void bar(Exception[] exceptions) {
		foo((Throwable[])exceptions); // unnecessary cast
	}
}

fix is to write instead: (note need to reverse condition)

if (lastArgType.isCompatibleWith(varargsType.elementsType()))
        return;
Comment 2 Philipe Mulet CLA 2006-03-31 11:13:26 EST
Added VarargsTest#test046.
Fixed
Comment 3 Frederic Fusier CLA 2006-04-13 14:24:26 EDT
Verified for 3.2 RC1 using build I20060413-0010.