#2 Expression.getType() faills to resolve?


We think we have found a bug

Consider the following two classes. We create a class (Tester) which in a
method declares and initializes an new variable called 's' (here String, but
it could be of ANY type - including simple types). Then it calls a method
using 's' as argument.

Our translateDefinition method in class OJTester extracts this method call
and again extracts the argument variable. Then we want to get the type of
the argument (type of 's').

Our problem is that the type of 's' is allways 'null' and not of the
declared type (here String)... ?

Are we wrong in our assumption that this is a bug?

Kind Regards
Kasper & Johannes

---------- class OJTester ----------
public class OJTester instantiates Metaclass extends OJClass
public void translateDefinition() throws MOPException
OJMethod method = getDeclaredMethod("foo", null);
StatementList body = method.getBody();
MethodCall call = (MethodCall) ( (ExpressionStatement)
body.get(1) ).getExpression();
ExpressionList list = call.getArguments();
Variable var = (Variable) list.get(0);
OJClass type = var.getType(method.getEnvironment());
System.out.println("TYPE: " + type); // type is allways be NULL! ???
catch(Exception e) { System.out.println("ERROR!"); }
---------- end ----------

---------- class Tester ----------
public class Tester instantiates OJTester
public void foo()
String s = new String("asdf");
private void bar(String s) {}
---------- end ----------


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks