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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java (-2 / +2 lines)
Lines 153-160 Link Here
153
			return null;
153
			return null;
154
		}
154
		}
155
		if (this.operator == PLUS){
155
		if (this.operator == PLUS){
156
			if(lhsID == T_JavaLangObject) {
156
			if(lhsID == T_JavaLangObject && (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_7)) {
157
				// <Object> += <String> is illegal (39248)
157
				// <Object> += <String> is illegal (39248) for compliance < 1.7
158
				scope.problemReporter().invalidOperator(this, lhsType, expressionType);
158
				scope.problemReporter().invalidOperator(this, lhsType, expressionType);
159
				return null;
159
				return null;
160
			} else {
160
			} else {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java (+1 lines)
Lines 155-160 Link Here
155
		tests_1_7.addAll(since_1_4);
155
		tests_1_7.addAll(since_1_4);
156
		tests_1_7.addAll(since_1_5);
156
		tests_1_7.addAll(since_1_5);
157
		tests_1_7.addAll(since_1_6);
157
		tests_1_7.addAll(since_1_6);
158
		tests_1_7.add(AssignmentTest_1_7.class);
158
		// Reset forgotten subsets tests
159
		// Reset forgotten subsets tests
159
		TestCase.TESTS_PREFIX = null;
160
		TestCase.TESTS_PREFIX = null;
160
		TestCase.TESTS_NAMES = null;
161
		TestCase.TESTS_NAMES = null;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java (+67 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
import java.util.Map;
14
15
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
17
import junit.framework.Test;
18
19
public class AssignmentTest_1_7 extends AbstractRegressionTest {
20
21
public AssignmentTest_1_7(String name) {
22
	super(name);
23
}
24
protected Map getCompilerOptions() {
25
	Map options = super.getCompilerOptions();
26
	options.put(CompilerOptions.OPTION_ReportNullReference, CompilerOptions.ERROR);
27
	options.put(CompilerOptions.OPTION_ReportPotentialNullReference, CompilerOptions.ERROR);
28
	options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.ERROR);
29
	options.put(CompilerOptions.OPTION_ReportNoEffectAssignment, CompilerOptions.ERROR);
30
	return options;
31
}
32
// Static initializer to specify tests subset using TESTS_* static variables
33
// All specified tests which does not belong to the class are skipped...
34
static {
35
//	TESTS_NAMES = new String[] { "test000" };
36
//	TESTS_NUMBERS = new int[] { 61 };
37
//	TESTS_RANGE = new int[] { 11, -1 };
38
}
39
public static Test suite() {
40
	return buildMinimalComplianceTestSuite(testClass(), F_1_7);
41
}
42
/*
43
 * no effect assignment bug
44
 * http://bugs.eclipse.org/bugs/show_bug.cgi?id=27235
45
 */
46
public void test001() {
47
	this.runConformTest(
48
		new String[] {
49
			"X.java",
50
			"public class X {\n" + 
51
			"	public static void main(String[] args) {\n" + 
52
			"		Object o = new X();\n" + 
53
			"		String s = \"ESS\";\n" + 
54
			"		 o += s;\n" + 
55
			"		System.out.println(o);\n" + 
56
			"	}\n" + 
57
			"	public String toString() {\n" + 
58
			"		return \"SUCC\";\n" + 
59
			"	}\n" + 
60
			"}",
61
		},
62
		"SUCCESS");
63
}
64
public static Class testClass() {
65
	return AssignmentTest_1_7.class;
66
}
67
}

Return to bug 232558