Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 83977 Details for
Bug 208013
ClassCastException: Initializer cannot be cast to IType when resolving binding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed workaround and regression test
208013.txt (text/plain), 2.74 KB, created by
Jerome Lanneluc
on 2007-11-28 09:23:24 EST
(
hide
)
Description:
Proposed workaround and regression test
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2007-11-28 09:23:24 EST
Size:
2.74 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/TypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java,v >retrieving revision 1.132.2.1 >diff -u -r1.132.2.1 TypeBinding.java >--- dom/org/eclipse/jdt/core/dom/TypeBinding.java 24 Aug 2007 02:13:58 -0000 1.132.2.1 >+++ dom/org/eclipse/jdt/core/dom/TypeBinding.java 28 Nov 2007 14:20:40 -0000 >@@ -554,7 +554,9 @@ > // must use getElementAt(...) as there is no back pointer to the defining method (scope is null after resolution has ended) > try { > int sourceStart = ((LocalTypeBinding) referenceBinding).sourceStart; >- return (JavaElement) cu.getElementAt(sourceStart); >+ IJavaElement element =cu.getElementAt(sourceStart); >+ // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=208013 >+ return (JavaElement) element.getAncestor(IJavaElement.TYPE); > } catch (JavaModelException e) { > // does not exist > return null; >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java,v >retrieving revision 1.49.2.1 >diff -u -r1.49.2.1 ASTModelBridgeTests.java >--- src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 17 Oct 2007 15:53:14 -0000 1.49.2.1 >+++ src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 28 Nov 2007 14:20:41 -0000 >@@ -1225,6 +1225,35 @@ > } > > /* >+ * Ensures that no ClassCastException is thrown if the method is in an anonymous >+ * which is inside the initializer of another anonymous. >+ * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=208013) >+ */ >+ public void testMethod11() throws JavaModelException { >+ ASTNode node = buildAST( >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " new Object() {\n" + >+ " Object o;\n" + >+ " {\n"+ >+ " new Object() {\n" + >+ " /*start*/void bar() {\n" + >+ " }/*end*/\n" + >+ " };\n" + >+ " }\n" + >+ " };\n"+ >+ " }\n" + >+ "}" >+ ); >+ IBinding binding = ((MethodDeclaration) node).resolveBinding(); >+ IJavaElement element = binding.getJavaElement(); >+ assertElementEquals( >+ "Unexpected Java element", >+ "bar() [in <anonymous #1> [in foo() [in X [in [Working copy] X.java [in <default> [in src [in P]]]]]]]", >+ element >+ ); >+ } >+ /* > * Ensures that the IJavaElement of an IBinding representing a package is correct. > */ > public void testPackage1() throws CoreException {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 208013
: 83977