Exemple #1
0
  private void resolvePropertyDeclarationBodies(@NotNull BodiesResolveContext c) {

    // Member properties
    Set<JetProperty> processed = Sets.newHashSet();
    for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry :
        c.getDeclaredClasses().entrySet()) {
      if (!(entry.getKey() instanceof JetClass)) continue;
      JetClass jetClass = (JetClass) entry.getKey();
      ClassDescriptorWithResolutionScopes classDescriptor = entry.getValue();

      for (JetProperty property : jetClass.getProperties()) {
        PropertyDescriptor propertyDescriptor = c.getProperties().get(property);
        assert propertyDescriptor != null;

        resolveProperty(
            c,
            classDescriptor.getScopeForMemberDeclarationResolution(),
            property,
            propertyDescriptor);
        processed.add(property);
      }
    }

    // Top-level properties & properties of objects
    for (Map.Entry<JetProperty, PropertyDescriptor> entry : c.getProperties().entrySet()) {
      JetProperty property = entry.getKey();
      if (processed.contains(property)) continue;

      PropertyDescriptor propertyDescriptor = entry.getValue();

      resolveProperty(c, null, property, propertyDescriptor);
    }
  }
Exemple #2
0
  private void resolvePropertyDeclarationBodies() {

    // Member properties
    Set<JetProperty> processed = Sets.newHashSet();
    for (Map.Entry<JetClass, MutableClassDescriptor> entry : context.getClasses().entrySet()) {
      JetClass jetClass = entry.getKey();
      if (!context.completeAnalysisNeeded(jetClass)) continue;
      MutableClassDescriptor classDescriptor = entry.getValue();

      for (JetProperty property : jetClass.getProperties()) {
        final PropertyDescriptor propertyDescriptor = this.context.getProperties().get(property);
        assert propertyDescriptor != null;

        computeDeferredType(propertyDescriptor.getReturnType());

        JetExpression initializer = property.getInitializer();
        if (initializer != null) {
          ConstructorDescriptor primaryConstructor =
              classDescriptor.getUnsubstitutedPrimaryConstructor();
          if (primaryConstructor != null) {
            JetScope declaringScopeForPropertyInitializer =
                this.context.getDeclaringScopes().get(property);
            resolvePropertyInitializer(
                property, propertyDescriptor, initializer, declaringScopeForPropertyInitializer);
          }
        }

        resolvePropertyAccessors(property, propertyDescriptor);
        processed.add(property);
      }
    }

    // Top-level properties & properties of objects
    for (Map.Entry<JetProperty, PropertyDescriptor> entry :
        this.context.getProperties().entrySet()) {
      JetProperty property = entry.getKey();
      if (!context.completeAnalysisNeeded(property)) continue;
      if (processed.contains(property)) continue;

      final PropertyDescriptor propertyDescriptor = entry.getValue();

      computeDeferredType(propertyDescriptor.getReturnType());

      JetScope declaringScope = this.context.getDeclaringScopes().get(property);

      JetExpression initializer = property.getInitializer();
      if (initializer != null) {
        resolvePropertyInitializer(property, propertyDescriptor, initializer, declaringScope);
      }

      resolvePropertyAccessors(property, propertyDescriptor);
    }
  }