bugfix nullpointer if no receiver
This commit is contained in:
parent
77a6dae94f
commit
ed2f64eff9
@ -1,11 +1,9 @@
|
||||
class Example1 {
|
||||
int i;
|
||||
int a = 12345;
|
||||
Example e;
|
||||
public Example1(){i = 3456;}
|
||||
public Example1(){}
|
||||
int meth(int n){
|
||||
Example e = new Example();
|
||||
int abc = e.example1.m1(2).m2().m3();
|
||||
int i = m1(2).m2().m3();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -15,9 +13,6 @@ class Example1 {
|
||||
}
|
||||
|
||||
class Example {
|
||||
int i;
|
||||
boolean b;
|
||||
char c;
|
||||
Example1 example1;
|
||||
Example1 m(int a){
|
||||
return new Example1();
|
||||
|
@ -35,24 +35,30 @@ public class MethodCallStatementExpression extends AbstractType implements IExpr
|
||||
String classToSearchMethodIn = thisClass;
|
||||
|
||||
//method is called on something that is not this ???
|
||||
if(!receiver.thisExpression){
|
||||
classToSearchMethodIn = localVars.get(receiver.identifier);
|
||||
if(classToSearchMethodIn == null)
|
||||
classToSearchMethodIn = thisClass;
|
||||
if(this.receiver != null) {
|
||||
if (!receiver.thisExpression) {
|
||||
classToSearchMethodIn = localVars.get(receiver.identifier);
|
||||
if (classToSearchMethodIn == null)
|
||||
classToSearchMethodIn = thisClass;
|
||||
}
|
||||
}
|
||||
|
||||
String currentType = "";
|
||||
|
||||
// receiver is instvar
|
||||
if(receiver.instVarExpression != null){
|
||||
String Subreceiver = receiver.instVarExpression.receivers.get(0).identifier; // e
|
||||
String mostLeftField = receiver.instVarExpression.fieldName; // example1
|
||||
if(receiver != null) {
|
||||
if (receiver.instVarExpression != null) {
|
||||
String Subreceiver = receiver.instVarExpression.receivers.get(0).identifier; // e
|
||||
String mostLeftField = receiver.instVarExpression.fieldName; // example1
|
||||
|
||||
String typeOfSubreceiver = typeContext.get(thisClass).get(Subreceiver);
|
||||
String typeOfSubreceiver = typeContext.get(thisClass).get(Subreceiver);
|
||||
|
||||
receiver.instVarExpression.thisClass = typeOfSubreceiver;
|
||||
receiver.instVarExpression.typeCheck(methodContext, typeContext, localVars);
|
||||
currentType = typeContext.get(typeOfSubreceiver).get(mostLeftField);
|
||||
receiver.instVarExpression.thisClass = typeOfSubreceiver;
|
||||
receiver.instVarExpression.typeCheck(methodContext, typeContext, localVars);
|
||||
currentType = typeContext.get(typeOfSubreceiver).get(mostLeftField);
|
||||
}
|
||||
}else{
|
||||
currentType = thisClass;
|
||||
}
|
||||
|
||||
//if classToSearchMethodIn does not conatin method, throw exception. go through list and check each
|
||||
|
Loading…
Reference in New Issue
Block a user