Bug 133918 - [1.5][compiler] Duplicate return; in CastExpression line 258
Summary: [1.5][compiler] Duplicate return; in CastExpression line 258
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-29 15:01 EST by Olivier Thomann CLA
Modified: 2006-04-13 14:24 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.