use of org.checkerframework.dataflow.cfg.node.ObjectCreationNode in project checker-framework by typetools.
the class WholeProgramInferenceScenes method updateInferredConstructorParameterTypes.
/**
* Updates the parameter types of the constructor created by objectCreationNode based on
* arguments to the constructor.
*
* <p>For each parameter in constructorElt:
*
* <ul>
* <li>If the Scene does not contain an annotated type for that parameter, then the type of
* the respective value passed as argument in the object creation call objectCreationNode
* will be added to the parameter in the Scene.
* <li>If the Scene previously contained an annotated type for that parameter, then its new
* type will be the LUB between the previous type and the type of the respective value
* passed as argument in the object creation call.
* </ul>
*
* <p>
*
* @param objectCreationNode the new Object() node
* @param atf the annotated type factory of a given type system, whose type hierarchy will be
* used to update the constructor's parameters' types
*/
@Override
public void updateInferredConstructorParameterTypes(ObjectCreationNode objectCreationNode, ExecutableElement constructorElt, AnnotatedTypeFactory atf) {
ClassSymbol classSymbol = getEnclosingClassSymbol(objectCreationNode.getTree());
if (classSymbol == null) {
// https://github.com/typetools/checker-framework/issues/682
return;
}
String className = classSymbol.flatname.toString();
String jaifPath = helper.getJaifPath(className);
AClass clazz = helper.getAClass(className, jaifPath);
String methodName = JVMNames.getJVMMethodName(constructorElt);
AMethod method = clazz.methods.vivify(methodName);
List<Node> arguments = objectCreationNode.getArguments();
updateInferredExecutableParameterTypes(constructorElt, atf, jaifPath, method, arguments);
}
use of org.checkerframework.dataflow.cfg.node.ObjectCreationNode in project checker-framework by typetools.
the class AliasingTransfer method visitAssignment.
/**
* Case 1: For every assignment, the LHS is refined if the RHS has type {@literal @}Unique and
* is a method invocation or a new class instance.
*/
@Override
public TransferResult<CFValue, CFStore> visitAssignment(AssignmentNode n, TransferInput<CFValue, CFStore> in) {
Node rhs = n.getExpression();
Tree treeRhs = rhs.getTree();
AnnotatedTypeMirror rhsType = factory.getAnnotatedType(treeRhs);
if (rhsType.hasAnnotation(Unique.class) && (rhs instanceof MethodInvocationNode || rhs instanceof ObjectCreationNode)) {
// Do normal refinement.
return super.visitAssignment(n, in);
}
// Widen the type of the rhs if the RHS's declared type wasn't @Unique.
Receiver r = FlowExpressions.internalReprOf(factory, rhs);
in.getRegularStore().clearValue(r);
return new RegularTransferResult<>(null, in.getRegularStore());
}
Aggregations