Bug 22951

Summary: Type binding "null" for super method invocations in VariableDeclarationFragment initializer
Product: [Eclipse Project] JDT Reporter: Timothy Halloran <hallorant>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: akiezun, Olivier_Thomann
Version: 2.0   
Target Milestone: 2.1 M1   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Timothy Halloran CLA 2002-08-28 13:20:26 EDT
I'm getting type binding problems for super method invocations within the
initializer expression of a VariableDeclarationFragment, I am unsure if this
occurs in general expressions.  Below are some examples:

[PVAVariableDeclarationAndUse] null rhs type in Initializer
"ds=super.getDirectoryScanner(srcDir)" in file
/home/thallora/src/jakarta-ant-1.5/src/main/org/apache/tools/ant/taskdefs/Copydir.java
[PVAVariableDeclarationAndUse] null rhs type in Initializer
"ds=super.getDirectoryScanner(dir)" in file
/home/thallora/src/jakarta-ant-1.5/src/main/org/apache/tools/ant/taskdefs/Delete.java
[PVAVariableDeclarationAndUse] null rhs type in Initializer
"ds=super.getDirectoryScanner(srcDir)" in file
/home/thallora/src/jakarta-ant-1.5/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java

Here's the code snippit:

  void saveVariable(VariableDeclarationFragment node) {
    if (isNull(node,
      "null VariableDeclarationFragment passed to saveVariable()")) {
      return;
    }
    IVariableBinding variable = node.resolveBinding();
    if (isNull(variable,
      "null variable in VariableDeclarationFragment \"" + node + "\"")) {
      return;
    }
    ITypeBinding type = variable.getType();
    if (isNull(type,
      "null type in VariableDeclarationFragment \"" + node + "\"")) {
      return;
    }
    // declare the variable (it may already have been encountered)
    f_db.declareVariable(variable, type, toJEM(node));

*   // since we are interested in this variable check the initializer
*   Expression initializer = node.getInitializer();
*   if (initializer == null) {
*     return; // no initializer
*   }
*   ITypeBinding rhsType = initializer.resolveTypeBinding();
*   if (isNull(rhsType, "null rhs type in Initializer \"" + node + "\"")) {
*     return;
*   }
    IVariableBinding rhsVar = expressionToVariable(initializer);
    if (rhsVar == null) {
      // some kind of expression we are not interested in
      return;
    }
    f_db.addToAssignmentSignature(type, rhsVar, rhsType, toJEM(node));
  }

I'm expected the expression type to be returned, hence it looks like a but in
the type binder code.

Thoughts?

Take Care,
Tim Halloran
Carnegie Mellon University
Comment 1 Timothy Halloran CLA 2002-08-28 13:23:40 EDT
I am spotting them in Assigments as well, hence this appears to be a general
expression issue:

[PVAVariableDeclarationAndUse] null rhs type in Assignment
"e=super.getAnnotationIterator()" in file
/home/thallora/src/eclipse20/plugins/org.eclipse.ui/Eclipse JFace
Text/org/eclipse/jface/text/source/VisualAnnotationModel.java
Comment 2 Adam Kiezun CLA 2002-08-29 03:47:46 EDT
dup of bug 22054 ?
Comment 3 Timothy Halloran CLA 2002-08-29 13:18:56 EDT
Yes, looks like a duplicate, I missed it because it doesn't refer to the API, it
is a more abstract report of the same problem (e.g., as seen through the
refactoring user interface).  Good catch Adam!

Take Care,
Tim Halloran
Carnegie Mellon University



*** This bug has been marked as a duplicate of 22054 ***