Пример #1
0
 private void resolveAnonymousInitializers(
     JetClassOrObject jetClassOrObject, MutableClassDescriptor classDescriptor) {
   if (!context.completeAnalysisNeeded(jetClassOrObject)) return;
   List<JetClassInitializer> anonymousInitializers = jetClassOrObject.getAnonymousInitializers();
   if (classDescriptor.getUnsubstitutedPrimaryConstructor() != null) {
     ConstructorDescriptor primaryConstructor =
         classDescriptor.getUnsubstitutedPrimaryConstructor();
     assert primaryConstructor != null;
     final JetScope scopeForInitializers = classDescriptor.getScopeForInitializers();
     for (JetClassInitializer anonymousInitializer : anonymousInitializers) {
       expressionTypingServices.getType(
           scopeForInitializers, anonymousInitializer.getBody(), NO_EXPECTED_TYPE, trace);
     }
   } else {
     for (JetClassInitializer anonymousInitializer : anonymousInitializers) {
       trace.report(ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR.on(anonymousInitializer));
     }
   }
 }
Пример #2
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);
   }
 }