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