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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-14 / +35 lines)
Lines 587-615 Link Here
587
					case Binding.FIELD :
587
					case Binding.FIELD :
588
						FieldBinding field = (FieldBinding) recipient;
588
						FieldBinding field = (FieldBinding) recipient;
589
						field.tagBits = ((FieldBinding) annotationRecipient).tagBits;
589
						field.tagBits = ((FieldBinding) annotationRecipient).tagBits;
590
						if (annotations != null) {
591
							// need to fill the instances array
592
							for (int j = 0; j < length; j++) {
593
								Annotation annot = sourceAnnotations[j];
594
								annotations[j] = annot.getCompilerAnnotation();
595
							}
596
						}
590
						break;
597
						break;
591
					case Binding.LOCAL :
598
					case Binding.LOCAL :
592
						LocalVariableBinding local = (LocalVariableBinding) recipient;
599
						LocalVariableBinding local = (LocalVariableBinding) recipient;
593
						long otherLocalTagBits = ((LocalVariableBinding) annotationRecipient).tagBits;
600
						long otherLocalTagBits = ((LocalVariableBinding) annotationRecipient).tagBits;
594
						local.tagBits = otherLocalTagBits;
601
						local.tagBits = otherLocalTagBits;
595
						/*
602
						if ((otherLocalTagBits & TagBits.AnnotationSuppressWarnings) == 0) {
596
						 * Annotations are shared between two locals, but we still need to record
603
							// None of the annotations is a SuppressWarnings annotation
597
						 * the suppress annotation range for the second local
604
							// need to fill the instances array
598
						 */
605
							if (annotations != null) {
599
						if ((otherLocalTagBits & TagBits.AnnotationSuppressWarnings) != 0) {
606
								for (int j = 0; j < length; j++) {
607
									Annotation annot = sourceAnnotations[j];
608
									annotations[j] = annot.getCompilerAnnotation();
609
								}
610
							}
611
						} else if (annotations != null) {
612
							// One of the annotations at least is a SuppressWarnings annotation
600
							LocalDeclaration localDeclaration = local.declaration;
613
							LocalDeclaration localDeclaration = local.declaration;
601
							annotation.recordSuppressWarnings(scope, localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings);
614
							int declarationSourceEnd = localDeclaration.declarationSourceEnd;
615
							int declarationSourceStart = localDeclaration.declarationSourceStart;
616
							for (int j = 0; j < length; j++) {
617
								Annotation annot = sourceAnnotations[j];
618
								/*
619
								 * Annotations are shared between two locals, but we still need to record
620
								 * the suppress annotation range for the second local
621
								 */
622
								AnnotationBinding annotationBinding = annot.getCompilerAnnotation();
623
								annotations[j] = annotationBinding;
624
								if (annotationBinding != null) {
625
									final ReferenceBinding annotationType = annotationBinding.getAnnotationType();
626
									if (annotationType != null && annotationType.id == TypeIds.T_JavaLangSuppressWarnings) {
627
										annot.recordSuppressWarnings(scope, declarationSourceStart, declarationSourceEnd, scope.compilerOptions().suppressWarnings);
628
									}
629
								}
630
							}
602
						}
631
						}
603
						break;
632
						break;
604
				}
633
				}
605
				if (annotations != null) {
606
					// need to fill the instances array
607
					annotations[0] = annotation.getCompilerAnnotation();
608
					for (int j = 1; j < length; j++) {
609
						Annotation annot = sourceAnnotations[j];
610
						annotations[j] = annot.getCompilerAnnotation();
611
					}
612
				}
613
				return;
634
				return;
614
			} else {
635
			} else {
615
				annotation.recipient = recipient;
636
				annotation.recipient = recipient;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (-3 / +37 lines)
Lines 45-51 Link Here
45
	// All specified tests which do not belong to the class are skipped...
45
	// All specified tests which do not belong to the class are skipped...
46
	static {
46
	static {
47
//		TESTS_NAMES = new String[] { "test127" };
47
//		TESTS_NAMES = new String[] { "test127" };
48
//		TESTS_NUMBERS = new int[] { 287, 288 };
48
//		TESTS_NUMBERS = new int[] { 289 };
49
//		TESTS_RANGE = new int[] { 249, -1 };
49
//		TESTS_RANGE = new int[] { 249, -1 };
50
	}
50
	}
51
51
Lines 9518-9524 Link Here
9518
		raiseDeprecationReduceInvalidJavadocSeverity,
9518
		raiseDeprecationReduceInvalidJavadocSeverity,
9519
		null);
9519
		null);
9520
}
9520
}
9521
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031
9521
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849
9522
public void test287() {
9522
public void test287() {
9523
	Map options = getCompilerOptions();
9523
	Map options = getCompilerOptions();
9524
	options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR);
9524
	options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR);
Lines 9548-9554 Link Here
9548
		options,
9548
		options,
9549
		null);
9549
		null);
9550
}
9550
}
9551
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031
9551
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849
9552
public void test288() {
9552
public void test288() {
9553
	Map options = getCompilerOptions();
9553
	Map options = getCompilerOptions();
9554
	options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR);
9554
	options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR);
Lines 9572-9575 Link Here
9572
		options,
9572
		options,
9573
		null);
9573
		null);
9574
}
9574
}
9575
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849
9576
public void test289() {
9577
	Map options = getCompilerOptions();
9578
	options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR);
9579
	options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
9580
	options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
9581
	this.runConformTest(
9582
		new String[] {
9583
				"X.java",
9584
				"import java.util.ArrayList;\n" + 
9585
				"\n" + 
9586
				"public class X {\n" + 
9587
				"	void foo(ArrayList arg) {\n" + 
9588
				"		for (\n" + 
9589
				"			@Deprecated\n" + 
9590
				"			@Other\n" + 
9591
				"			@SuppressWarnings(\"unchecked\")\n" +
9592
				"			boolean a= arg.add(1), b= arg.add(1);\n" + 
9593
				"			Boolean.FALSE;\n" + 
9594
				"		) {\n" + 
9595
				"			System.out.println(a && b);\n" + 
9596
				"		}\n" + 
9597
				"	}\n" + 
9598
				"}",
9599
				"Other.java",
9600
				"@interface Other {}"
9601
		},
9602
		"",
9603
		null,
9604
		true,
9605
		null,
9606
		options,
9607
		null);
9608
}
9575
}
9609
}

Return to bug 311849