View | Details | Raw Unified | Return to bug 282141
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java (+1 lines)
Lines 24-29 Link Here
24
public InstanceOfExpression(Expression expression, TypeReference type) {
24
public InstanceOfExpression(Expression expression, TypeReference type) {
25
	this.expression = expression;
25
	this.expression = expression;
26
	this.type = type;
26
	this.type = type;
27
	type.bits |= IgnoreRawTypeCheck; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=282141
27
	this.bits |= INSTANCEOF << OperatorSHIFT;
28
	this.bits |= INSTANCEOF << OperatorSHIFT;
28
	this.sourceStart = expression.sourceStart;
29
	this.sourceStart = expression.sourceStart;
29
	this.sourceEnd = type.sourceEnd;
30
	this.sourceEnd = type.sourceEnd;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-23 / +8 lines)
Lines 5325-5335 Link Here
5325
			"	} else 	if (t instanceof T) {\n" + 
5325
			"	} else 	if (t instanceof T) {\n" + 
5326
			"	       	    ^^^^^^^^^^^^^^\n" + 
5326
			"	       	    ^^^^^^^^^^^^^^\n" + 
5327
			"Cannot perform instanceof check against type parameter T. Use instead its erasure Object instead since further generic type information will be erased at runtime\n" + 
5327
			"Cannot perform instanceof check against type parameter T. Use instead its erasure Object instead since further generic type information will be erased at runtime\n" + 
5328
			"----------\n" + 
5329
			"4. WARNING in X.java (at line 12)\n" + 
5330
			"	} else if (t instanceof X) {\n" + 
5331
			"	                        ^\n" + 
5332
			"X is a raw type. References to generic type X<T> should be parameterized\n" + 
5333
			"----------\n",
5328
			"----------\n",
5334
			null,
5329
			null,
5335
			true,
5330
			true,
Lines 26649-26690 Link Here
26649
			"}\n",
26644
			"}\n",
26650
		},
26645
		},
26651
		"----------\n" + 
26646
		"----------\n" + 
26652
		"1. WARNING in X.java (at line 4)\n" + 
26647
		"1. WARNING in X.java (at line 5)\n" + 
26653
		"	boolean b = o instanceof X;\n" + 
26654
		"	                         ^\n" + 
26655
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
26656
		"----------\n" + 
26657
		"2. WARNING in X.java (at line 5)\n" + 
26658
		"	X x = (X) o;\n" + 
26648
		"	X x = (X) o;\n" + 
26659
		"	^\n" + 
26649
		"	^\n" + 
26660
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
26650
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
26661
		"----------\n" + 
26651
		"----------\n" + 
26662
		"3. WARNING in X.java (at line 5)\n" + 
26652
		"2. WARNING in X.java (at line 5)\n" + 
26663
		"	X x = (X) o;\n" + 
26653
		"	X x = (X) o;\n" + 
26664
		"	       ^\n" + 
26654
		"	       ^\n" + 
26665
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
26655
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
26666
		"----------\n" + 
26656
		"----------\n" + 
26667
		"4. WARNING in X.java (at line 6)\n" + 
26657
		"3. WARNING in X.java (at line 6)\n" + 
26668
		"	X<String> xs = (X<String>)o;\n" + 
26658
		"	X<String> xs = (X<String>)o;\n" + 
26669
		"	               ^^^^^^^^^^^^\n" + 
26659
		"	               ^^^^^^^^^^^^\n" + 
26670
		"Type safety: Unchecked cast from Object to X<String>\n" + 
26660
		"Type safety: Unchecked cast from Object to X<String>\n" + 
26671
		"----------\n" + 
26661
		"----------\n" + 
26672
		"5. ERROR in X.java (at line 7)\n" + 
26662
		"4. ERROR in X.java (at line 7)\n" + 
26673
		"	Zork z;\n" + 
26663
		"	Zork z;\n" + 
26674
		"	^^^^\n" + 
26664
		"	^^^^\n" + 
26675
		"Zork cannot be resolved to a type\n" + 
26665
		"Zork cannot be resolved to a type\n" + 
26676
		"----------\n" + 
26666
		"----------\n" + 
26677
		"6. WARNING in X.java (at line 10)\n" + 
26667
		"5. WARNING in X.java (at line 10)\n" + 
26678
		"	List l = (List) al;\n" + 
26668
		"	List l = (List) al;\n" + 
26679
		"	^^^^\n" + 
26669
		"	^^^^\n" + 
26680
		"List is a raw type. References to generic type List<E> should be parameterized\n" + 
26670
		"List is a raw type. References to generic type List<E> should be parameterized\n" + 
26681
		"----------\n" + 
26671
		"----------\n" + 
26682
		"7. WARNING in X.java (at line 10)\n" + 
26672
		"6. WARNING in X.java (at line 10)\n" + 
26683
		"	List l = (List) al;\n" + 
26673
		"	List l = (List) al;\n" + 
26684
		"	         ^^^^^^^^^\n" + 
26674
		"	         ^^^^^^^^^\n" + 
26685
		"Unnecessary cast from ArrayList<String> to List\n" + 
26675
		"Unnecessary cast from ArrayList<String> to List\n" + 
26686
		"----------\n" + 
26676
		"----------\n" + 
26687
		"8. WARNING in X.java (at line 10)\n" + 
26677
		"7. WARNING in X.java (at line 10)\n" + 
26688
		"	List l = (List) al;\n" + 
26678
		"	List l = (List) al;\n" + 
26689
		"	          ^^^^\n" + 
26679
		"	          ^^^^\n" + 
26690
		"List is a raw type. References to generic type List<E> should be parameterized\n" + 
26680
		"List is a raw type. References to generic type List<E> should be parameterized\n" + 
Lines 47867-47878 Link Here
47867
			"}\n",
47857
			"}\n",
47868
		},
47858
		},
47869
		"----------\n" + 
47859
		"----------\n" + 
47870
		"1. WARNING in A.java (at line 3)\n" + 
47860
		"1. ERROR in A.java (at line 4)\n" + 
47871
		"	boolean b=null instanceof A; \n" + 
47872
		"	                          ^\n" + 
47873
		"A is a raw type. References to generic type A<T> should be parameterized\n" + 
47874
		"----------\n" + 
47875
		"2. ERROR in A.java (at line 4)\n" + 
47876
		"	Zork z;\n" + 
47861
		"	Zork z;\n" + 
47877
		"	^^^^\n" + 
47862
		"	^^^^\n" + 
47878
		"Zork cannot be resolved to a type\n" + 
47863
		"Zork cannot be resolved to a type\n" + 
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-4 / +2 lines)
Lines 662-670 Link Here
662
		CompilationUnit compilationUnit = (CompilationUnit) result;
662
		CompilationUnit compilationUnit = (CompilationUnit) result;
663
		String expectedProblems =
663
		String expectedProblems =
664
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized\n" + 
664
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized\n" + 
665
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized\n" + 
666
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized";
665
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized";
667
		assertProblemsSize(compilationUnit, 3, expectedProblems);
666
		assertProblemsSize(compilationUnit, 2, expectedProblems);
668
		ASTNode node = getASTNode(compilationUnit, 0, 5);
667
		ASTNode node = getASTNode(compilationUnit, 0, 5);
669
		assertEquals("Wrong first character", '<', source[node.getStartPosition()]);
668
		assertEquals("Wrong first character", '<', source[node.getStartPosition()]);
670
	}
669
	}
Lines 890-898 Link Here
890
		CompilationUnit compilationUnit = (CompilationUnit) result;
889
		CompilationUnit compilationUnit = (CompilationUnit) result;
891
		String expectedProblems =
890
		String expectedProblems =
892
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized\n" + 
891
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized\n" + 
893
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized\n" + 
894
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized";
892
			"Pair is a raw type. References to generic type Pair<A,B> should be parameterized";
895
		assertProblemsSize(compilationUnit, 3, expectedProblems);
893
		assertProblemsSize(compilationUnit, 2, expectedProblems);
896
		ASTNode node = getASTNode(compilationUnit, 0, 5);
894
		ASTNode node = getASTNode(compilationUnit, 0, 5);
897
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
895
		assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType());
898
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
896
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;

Return to bug 282141