Ejemplo n.º 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);
    }
  }
Ejemplo n.º 2
0
  private void resolveDelegationSpecifierLists(@NotNull BodiesResolveContext c) {
    // TODO : Make sure the same thing is not initialized twice
    for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry :
        c.getDeclaredClasses().entrySet()) {
      JetClassOrObject classOrObject = entry.getKey();
      ClassDescriptorWithResolutionScopes descriptor = entry.getValue();

      resolveDelegationSpecifierList(
          c.getOuterDataFlowInfo(),
          classOrObject,
          descriptor,
          descriptor.getUnsubstitutedPrimaryConstructor(),
          descriptor.getScopeForClassHeaderResolution(),
          descriptor.getScopeForMemberDeclarationResolution());
    }
  }
Ejemplo n.º 3
0
 public void resolveAnonymousInitializer(
     @NotNull DataFlowInfo outerDataFlowInfo,
     @NotNull JetClassInitializer anonymousInitializer,
     @NotNull ClassDescriptorWithResolutionScopes classDescriptor) {
   LexicalScope scopeForInitializers = classDescriptor.getScopeForInitializerResolution();
   if (!classDescriptor.getConstructors().isEmpty()) {
     JetExpression body = anonymousInitializer.getBody();
     if (body != null) {
       expressionTypingServices.getType(
           scopeForInitializers, body, NO_EXPECTED_TYPE, outerDataFlowInfo, trace);
     }
     processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
   } else {
     trace.report(ANONYMOUS_INITIALIZER_IN_TRAIT.on(anonymousInitializer));
     processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
   }
 }
Ejemplo n.º 4
0
  private void resolvePrimaryConstructorParameters(@NotNull BodiesResolveContext c) {
    for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry :
        c.getDeclaredClasses().entrySet()) {
      JetClassOrObject klass = entry.getKey();
      ClassDescriptorWithResolutionScopes classDescriptor = entry.getValue();
      ConstructorDescriptor unsubstitutedPrimaryConstructor =
          classDescriptor.getUnsubstitutedPrimaryConstructor();
      if (unsubstitutedPrimaryConstructor != null) {
        ForceResolveUtil.forceResolveAllContents(unsubstitutedPrimaryConstructor.getAnnotations());

        LexicalScope parameterScope =
            getPrimaryConstructorParametersScope(
                classDescriptor.getScopeForClassHeaderResolution(),
                unsubstitutedPrimaryConstructor);
        valueParameterResolver.resolveValueParameters(
            klass.getPrimaryConstructorParameters(),
            unsubstitutedPrimaryConstructor.getValueParameters(),
            parameterScope,
            c.getOuterDataFlowInfo(),
            trace);
      }
    }
  }