Skip to content

Commit 4dd2a96

Browse files
committed
Consider ctors in return type considerations.
1 parent 452e2ca commit 4dd2a96

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/wala/nCFAContextWithReceiversSelector.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.ibm.wala.ipa.callgraph.propagation.cfa.CallString;
1515
import com.ibm.wala.ipa.callgraph.propagation.cfa.CallStringContext;
1616
import com.ibm.wala.ipa.callgraph.propagation.cfa.nCFAContextSelector;
17+
import com.ibm.wala.types.TypeReference;
1718

1819
import edu.cuny.hunter.streamrefactoring.core.analysis.Util;
1920

@@ -126,7 +127,17 @@ protected Map<CallStringTriple, CallStringWithReceivers> getCallStringWithReceiv
126127
*/
127128
@Override
128129
protected int getLength(CGNode caller, CallSiteReference site, IMethod target) {
129-
boolean implementsBaseStream = Util.implementsBaseStream(target.getReturnType(), target.getClassHierarchy());
130+
TypeReference typeToCheck;
131+
132+
// if it's a ctor.
133+
if (target.isInit())
134+
// then, use the declaring type.
135+
typeToCheck = target.getDeclaringClass().getReference();
136+
else // otherwise.
137+
// use the return type.
138+
typeToCheck = target.getReturnType();
139+
140+
boolean implementsBaseStream = Util.implementsBaseStream(typeToCheck, target.getClassHierarchy());
130141

131142
if (implementsBaseStream)
132143
return CONTEXT_LENGTH_FOR_STREAMS;

0 commit comments

Comments
 (0)