Exemple #1
0
 private static void recordConstructorDelegationCall(
     @NotNull BindingTrace trace,
     @NotNull ConstructorDescriptor constructor,
     @NotNull ResolvedCall<?> call) {
   //noinspection unchecked
   trace.record(
       CONSTRUCTOR_RESOLVED_DELEGATION_CALL,
       constructor,
       (ResolvedCall<ConstructorDescriptor>) call);
 }
Exemple #2
0
  public void resolveFunctionBody(
      @NotNull DataFlowInfo outerDataFlowInfo,
      @NotNull BindingTrace trace,
      @NotNull JetDeclarationWithBody function,
      @NotNull FunctionDescriptor functionDescriptor,
      @NotNull LexicalScope scope,
      @Nullable Function1<LexicalScope, DataFlowInfo> beforeBlockBody,
      @NotNull CallChecker callChecker) {
    LexicalScope innerScope =
        FunctionDescriptorUtil.getFunctionInnerScope(scope, functionDescriptor, trace);
    List<JetParameter> valueParameters = function.getValueParameters();
    List<ValueParameterDescriptor> valueParameterDescriptors =
        functionDescriptor.getValueParameters();

    valueParameterResolver.resolveValueParameters(
        valueParameters,
        valueParameterDescriptors,
        ExpressionTypingContext.newContext(
            trace, innerScope, outerDataFlowInfo, NO_EXPECTED_TYPE, callChecker));

    // Synthetic "field" creation
    if (functionDescriptor instanceof PropertyAccessorDescriptor) {
      PropertyAccessorDescriptor accessorDescriptor =
          (PropertyAccessorDescriptor) functionDescriptor;
      JetProperty property = (JetProperty) function.getParent();
      final SyntheticFieldDescriptor fieldDescriptor =
          new SyntheticFieldDescriptor(accessorDescriptor, property);
      innerScope =
          new LexicalScopeImpl(
              innerScope,
              functionDescriptor,
              true,
              functionDescriptor.getExtensionReceiverParameter(),
              "Accessor inner scope with synthetic field",
              RedeclarationHandler.DO_NOTHING,
              new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
                @Override
                public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
                  handler.addVariableOrClassDescriptor(fieldDescriptor);
                  return Unit.INSTANCE$;
                }
              });
      // Check parameter name shadowing
      for (JetParameter parameter : function.getValueParameters()) {
        if (SyntheticFieldDescriptor.NAME.equals(parameter.getNameAsName())) {
          trace.report(Errors.ACCESSOR_PARAMETER_NAME_SHADOWING.on(parameter));
        }
      }
    }

    DataFlowInfo dataFlowInfo = null;

    if (beforeBlockBody != null) {
      dataFlowInfo = beforeBlockBody.invoke(innerScope);
    }

    if (function.hasBody()) {
      expressionTypingServices.checkFunctionReturnType(
          innerScope,
          function,
          functionDescriptor,
          dataFlowInfo != null ? dataFlowInfo : outerDataFlowInfo,
          null,
          trace);
    }

    assert functionDescriptor.getReturnType() != null;
  }