public static Collection<JetReturnExpression> collectReturns(@NotNull JetExpression expression) {
   Collection<JetReturnExpression> result = Lists.newArrayList();
   expression.accept(
       new JetTreeVisitor<Collection<JetReturnExpression>>() {
         @Override
         public Void visitReturnExpression(
             @NotNull JetReturnExpression expression, Collection<JetReturnExpression> data) {
           data.add(expression);
           return null;
         }
       },
       result);
   return result;
 }
Ejemplo n.º 2
0
 @NotNull
 private JetTypeInfo getSelectorReturnTypeInfo(
     @NotNull ReceiverValue receiver,
     @Nullable ASTNode callOperationNode,
     @NotNull JetExpression selectorExpression,
     @NotNull ResolutionContext context,
     @NotNull ResolveMode resolveMode,
     @NotNull ResolutionResultsCache resolutionResultsCache) {
   if (selectorExpression instanceof JetCallExpression) {
     return getCallExpressionTypeInfoWithoutFinalTypeCheck(
         (JetCallExpression) selectorExpression,
         receiver,
         callOperationNode,
         context,
         resolveMode,
         resolutionResultsCache);
   } else if (selectorExpression instanceof JetSimpleNameExpression) {
     return getSimpleNameExpressionTypeInfo(
         (JetSimpleNameExpression) selectorExpression, receiver, callOperationNode, context);
   } else if (selectorExpression instanceof JetQualifiedExpression) {
     JetQualifiedExpression qualifiedExpression = (JetQualifiedExpression) selectorExpression;
     JetExpression newReceiverExpression = qualifiedExpression.getReceiverExpression();
     JetTypeInfo newReceiverTypeInfo =
         getSelectorReturnTypeInfo(
             receiver,
             callOperationNode,
             newReceiverExpression,
             context.replaceExpectedType(NO_EXPECTED_TYPE),
             resolveMode,
             resolutionResultsCache);
     JetType newReceiverType = newReceiverTypeInfo.getType();
     DataFlowInfo newReceiverDataFlowInfo = newReceiverTypeInfo.getDataFlowInfo();
     JetExpression newSelectorExpression = qualifiedExpression.getSelectorExpression();
     if (newReceiverType != null && newSelectorExpression != null) {
       ExpressionReceiver expressionReceiver =
           new ExpressionReceiver(newReceiverExpression, newReceiverType);
       return getSelectorReturnTypeInfo(
           expressionReceiver,
           qualifiedExpression.getOperationTokenNode(),
           newSelectorExpression,
           context.replaceDataFlowInfo(newReceiverDataFlowInfo),
           resolveMode,
           resolutionResultsCache);
     }
   } else {
     context.trace.report(ILLEGAL_SELECTOR.on(selectorExpression, selectorExpression.getText()));
   }
   return JetTypeInfo.create(null, context.dataFlowInfo);
 }