Пример #1
0
 private void checkFinalUpperBounds(@Nullable JetTypeReference typeReference) {
   if (typeReference != null) {
     JetType type = trace.getBindingContext().get(TYPE, typeReference);
     if (type != null) {
       DescriptorResolver.checkUpperBoundType(typeReference, type, trace);
     }
   }
 }
Пример #2
0
 private void checkBoundsForTypeInClassHeader(@Nullable JetTypeReference typeReference) {
   if (typeReference != null) {
     JetType type = trace.getBindingContext().get(TYPE, typeReference);
     if (type != null) {
       DescriptorResolver.checkBounds(typeReference, type, trace);
     }
   }
 }
Пример #3
0
  public void process(@NotNull BodiesResolveContext bodiesResolveContext) {
    for (JetFile file : bodiesResolveContext.getFiles()) {
      checkModifiersAndAnnotationsInPackageDirective(file);
      AnnotationTargetChecker.INSTANCE$.check(file, trace);
    }

    Map<JetClassOrObject, ClassDescriptorWithResolutionScopes> classes =
        bodiesResolveContext.getDeclaredClasses();
    for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry :
        classes.entrySet()) {
      JetClassOrObject classOrObject = entry.getKey();
      ClassDescriptorWithResolutionScopes classDescriptor = entry.getValue();

      checkSupertypesForConsistency(classDescriptor);
      checkTypesInClassHeader(classOrObject);

      if (classOrObject instanceof JetClass) {
        JetClass jetClass = (JetClass) classOrObject;
        checkClass(bodiesResolveContext, jetClass, classDescriptor);
        descriptorResolver.checkNamesInConstraints(
            jetClass, classDescriptor, classDescriptor.getScopeForClassHeaderResolution(), trace);
      } else if (classOrObject instanceof JetObjectDeclaration) {
        checkObject((JetObjectDeclaration) classOrObject, classDescriptor);
      }

      checkPrimaryConstructor(classOrObject, classDescriptor);

      modifiersChecker.checkModifiersForDeclaration(classOrObject, classDescriptor);
    }

    Map<JetNamedFunction, SimpleFunctionDescriptor> functions = bodiesResolveContext.getFunctions();
    for (Map.Entry<JetNamedFunction, SimpleFunctionDescriptor> entry : functions.entrySet()) {
      JetNamedFunction function = entry.getKey();
      SimpleFunctionDescriptor functionDescriptor = entry.getValue();

      checkFunction(function, functionDescriptor);
      modifiersChecker.checkModifiersForDeclaration(function, functionDescriptor);
    }

    Map<JetProperty, PropertyDescriptor> properties = bodiesResolveContext.getProperties();
    for (Map.Entry<JetProperty, PropertyDescriptor> entry : properties.entrySet()) {
      JetProperty property = entry.getKey();
      PropertyDescriptor propertyDescriptor = entry.getValue();

      checkProperty(property, propertyDescriptor);
      modifiersChecker.checkModifiersForDeclaration(property, propertyDescriptor);
    }

    for (Map.Entry<JetSecondaryConstructor, ConstructorDescriptor> entry :
        bodiesResolveContext.getSecondaryConstructors().entrySet()) {
      ConstructorDescriptor constructorDescriptor = entry.getValue();
      JetSecondaryConstructor declaration = entry.getKey();
      checkConstructorDeclaration(constructorDescriptor, declaration);
    }
  }
Пример #4
0
  private void checkTypeParameters(JetTypeParameterListOwner typeParameterListOwner) {
    // TODO: Support annotation for type parameters
    for (JetTypeParameter jetTypeParameter : typeParameterListOwner.getTypeParameters()) {
      AnnotationResolver.reportUnsupportedAnnotationForTypeParameter(jetTypeParameter, trace);

      TypeParameterDescriptor typeParameter = trace.get(TYPE_PARAMETER, jetTypeParameter);
      if (typeParameter != null) {
        DescriptorResolver.checkConflictingUpperBounds(trace, typeParameter, jetTypeParameter);
      }
      AnnotationTargetChecker.INSTANCE$.check(jetTypeParameter, trace);
    }
  }
Пример #5
0
 private void checkDeclaredTypeInPublicMember(
     JetNamedDeclaration member, CallableMemberDescriptor memberDescriptor) {
   boolean hasDeferredType;
   if (member instanceof JetProperty) {
     hasDeferredType =
         ((JetProperty) member).getTypeReference() == null
             && DescriptorResolver.hasBody((JetProperty) member);
   } else {
     assert member instanceof JetFunction;
     JetFunction function = (JetFunction) member;
     hasDeferredType =
         function.getTypeReference() == null && function.hasBody() && !function.hasBlockBody();
   }
   if ((memberDescriptor.getVisibility().isPublicAPI())
       && memberDescriptor.getOverriddenDescriptors().size() == 0
       && hasDeferredType) {
     trace.report(PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE.on(member));
   }
 }