@Override public void caseAReturnStmIR(AReturnStmIR node) throws AnalysisException { if (node.getExp() == null) { return; // When the return type of the method is 'void' } if (node.getExp() instanceof ANullExpIR) { return; } node.getExp().apply(this); AMethodDeclIR methodDecl = node.getAncestor(AMethodDeclIR.class); STypeIR expectedType = methodDecl.getMethodType().getResult(); if (expectedType instanceof AUnknownTypeIR) { return; } if (!(expectedType instanceof AUnionTypeIR)) { correctTypes(node.getExp(), expectedType); } }
@Override public void inAReturnStmIR(AReturnStmIR node) throws AnalysisException { SExpIR exp = node.getExp(); if (exp != null) { exp.apply(this); } else { return; } AMethodDeclIR method = node.getAncestor(AMethodDeclIR.class); AMethodTypeIR methodType = method.getMethodType(); if (methodType.getResult() instanceof AStringTypeIR) { if (!(exp.getType() instanceof SSeqTypeIR)) { return; } correctExpToString(exp); ; } else if (methodType.getResult() instanceof SSeqTypeIR) { if (!(exp.getType() instanceof AStringTypeIR)) { return; } correctExpToSeq(exp, exp.getType()); } }
AMethodDeclIR method = node.getAncestor(AMethodDeclIR.class);