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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-2 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-29 Link Here
24
import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
24
import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
25
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
26
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
27
import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
28
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
28
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
Lines 541-547 Link Here
541
			// problem already got signaled on receiver, do not report secondary problem
542
			// problem already got signaled on receiver, do not report secondary problem
542
			return null;
543
			return null;
543
		}
544
		}
544
		scope.problemReporter().invalidField(this, this.actualReceiverType);
545
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=245007 avoid secondary errors in case of
546
		// missing super type for anonymous classes ... 
547
		ReferenceBinding declaringClass = fieldBinding.declaringClass;
548
		boolean avoidSecondary = declaringClass != null &&
549
								 declaringClass.isAnonymousType() &&
550
								 declaringClass.superclass() instanceof MissingTypeBinding;
551
		if (!avoidSecondary) {
552
			scope.problemReporter().invalidField(this, this.actualReceiverType);
553
		}
545
		return null;
554
		return null;
546
	}
555
	}
547
	// handle indirect inheritance thru variable secondary bound
556
	// handle indirect inheritance thru variable secondary bound
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-2 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 26-31 Link Here
26
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
26
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
27
import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
27
import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
28
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
31
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
31
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
32
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
Lines 409-415 Link Here
409
				return null;
410
				return null;
410
			}
411
			}
411
		}
412
		}
412
		scope.problemReporter().invalidMethod(this, this.binding);
413
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=245007 avoid secondary errors in case of
414
		// missing super type for anonymous classes ... 
415
		ReferenceBinding declaringClass = this.binding.declaringClass;
416
		boolean avoidSecondary = declaringClass != null &&
417
								 declaringClass.isAnonymousType() &&
418
								 declaringClass.superclass() instanceof MissingTypeBinding;
419
		if (!avoidSecondary)
420
			scope.problemReporter().invalidMethod(this, this.binding);
413
		MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
421
		MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
414
		switch (this.binding.problemId()) {
422
		switch (this.binding.problemId()) {
415
			case ProblemReasons.Ambiguous :
423
			case ProblemReasons.Ambiguous :
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-2 lines)
Lines 352-359 Link Here
352
							}
352
							}
353
						}
353
						}
354
					}
354
					}
355
				} else {
356
					return null;
357
				}
355
				}
358
				if (this.anonymousType != null) {
356
				if (this.anonymousType != null) {
359
					// insert anonymous type in scope (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=210070)
357
					// insert anonymous type in scope (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=210070)
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java (+28 lines)
Lines 5306-5309 Link Here
5306
		},
5306
		},
5307
		"");
5307
		"");
5308
}
5308
}
5309
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=245007
5310
public void test106() {
5311
	this.runNegativeTest(
5312
		new String[] {
5313
			"X.java",
5314
			"public class X {\n" +
5315
			"	public static void main(String[] args) {\n" +
5316
			"		new Listener() {\n" +
5317
			"			  void foo(int a) { }\n" +
5318
			"		}.bar();\n" +
5319
			"       new Listener() {\n" +
5320
			"			  void foo(int a) { }\n" +
5321
			"		}.field = 10;\n" +
5322
			"	}\n" +
5323
			"}\n"
5324
		},
5325
		"----------\n" + 
5326
		"1. ERROR in X.java (at line 3)\n" + 
5327
		"	new Listener() {\n" + 
5328
		"	    ^^^^^^^^\n" + 
5329
		"Listener cannot be resolved to a type\n" + 
5330
		"----------\n" + 
5331
		"2. ERROR in X.java (at line 6)\n" + 
5332
		"	new Listener() {\n" + 
5333
		"	    ^^^^^^^^\n" + 
5334
		"Listener cannot be resolved to a type\n" + 
5335
		"----------\n");
5336
}
5309
}
5337
}
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7409-7415 Link Here
7409
		checkSourceRange(name, "j", source); //$NON-NLS-1$
7409
		checkSourceRange(name, "j", source); //$NON-NLS-1$
7410
		IBinding binding = name.resolveBinding();
7410
		IBinding binding = name.resolveBinding();
7411
		ASTNode declaringNode = compilationUnit.findDeclaringNode(binding);
7411
		ASTNode declaringNode = compilationUnit.findDeclaringNode(binding);
7412
		assertNull("No declaring node is available", declaringNode); //$NON-NLS-1$
7412
		assertNotNull("No declaring node is available", declaringNode); //$NON-NLS-1$
7413
	}
7413
	}
7414
7414
7415
	/**
7415
	/**
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 859-865 Link Here
859
			"8. ERROR in /Converter15/src/a/X.java (at line 16)\n" +
859
			"8. ERROR in /Converter15/src/a/X.java (at line 16)\n" +
860
			"	}takeParam((int) c);\n" +
860
			"	}takeParam((int) c);\n" +
861
			"	^\n" +
861
			"	^\n" +
862
			"Syntax error, insert \";\" to complete Statement\n",
862
			"Syntax error, insert \";\" to complete Statement\n" + 
863
			"9. ERROR in /Converter15/src/a/X.java (at line 16)\n" + 
864
			"	}takeParam((int) c);\n" + 
865
			"	 ^^^^^^^^^^\n" + 
866
			"Return type for the method is missing\n",
863
			result);
867
			result);
864
}
868
}
865
/**
869
/**
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7581-7587 Link Here
7581
		checkSourceRange(name, "j", source); //$NON-NLS-1$
7581
		checkSourceRange(name, "j", source); //$NON-NLS-1$
7582
		IBinding binding = name.resolveBinding();
7582
		IBinding binding = name.resolveBinding();
7583
		ASTNode declaringNode = compilationUnit.findDeclaringNode(binding);
7583
		ASTNode declaringNode = compilationUnit.findDeclaringNode(binding);
7584
		assertNull("No declaring node is available", declaringNode); //$NON-NLS-1$
7584
		assertNotNull("No declaring node is available", declaringNode); //$NON-NLS-1$
7585
	}
7585
	}
7586
7586
7587
	/**
7587
	/**
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-2 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8021-8027 Link Here
8021
				"	CharsetDecoder(CharSet\n" +
8021
				"	CharsetDecoder(CharSet\n" +
8022
				"	^^^^^^^^^^^^^^^^^^^^^^\n" +
8022
				"	^^^^^^^^^^^^^^^^^^^^^^\n" +
8023
				"Syntax error on token(s), misplaced construct(s)\n" +
8023
				"Syntax error on token(s), misplaced construct(s)\n" +
8024
				"11. ERROR in /Converter/src/TestCharset.java (at line 17)\n" +
8024
				"11. ERROR in /Converter/src/TestCharset.java (at line 10)\n" +
8025
				"	CharsetDecoder(CharSet\n" +
8026
				"	^^^^^^^^^^^^^^^\n" +
8027
				"Return type for the method is missing\n" +
8028
				"12. ERROR in /Converter/src/TestCharset.java (at line 11)\n" +
8029
				"	protected CoderResult decodeLoop(ByteBuffer in,\n" +
8030
				"	          ^^^^^^^^^^^\n" +
8031
				"CoderResult cannot be resolved to a type\n" +
8032
				"13. ERROR in /Converter/src/TestCharset.java (at line 11)\n" +
8033
				"	protected CoderResult decodeLoop(ByteBuffer in,\n" +
8034
				"	                                 ^^^^^^^^^^\n" +
8035
				"ByteBuffer cannot be resolved to a type\n" +
8036
				"14. ERROR in /Converter/src/TestCharset.java (at line 12)\n" +
8037
				"	CharBuffer out) {\n" +
8038
				"	^^^^^^^^^^\n" +
8039
				"CharBuffer cannot be resolved to a type\n" +
8040
				"15. ERROR in /Converter/src/TestCharset.java (at line 17)\n" +
8025
				"	public CharsetEncoder newEncoder() {\n" +
8041
				"	public CharsetEncoder newEncoder() {\n" +
8026
				"	       ^^^^^^^^^^^^^^\n" +
8042
				"	       ^^^^^^^^^^^^^^\n" +
8027
				"CharsetEncoder cannot be resolved to a type\n",
8043
				"CharsetEncoder cannot be resolved to a type\n",

Return to bug 245007