Ejemplo n.º 1
0
  private void checkOpenMembers(ClassDescriptorWithResolutionScopes classDescriptor) {
    if (classCanHaveOpenMembers(classDescriptor)) return;

    for (CallableMemberDescriptor memberDescriptor : classDescriptor.getDeclaredCallableMembers()) {
      if (memberDescriptor.getKind() != CallableMemberDescriptor.Kind.DECLARATION) continue;
      JetNamedDeclaration member =
          (JetNamedDeclaration) DescriptorToSourceUtils.descriptorToDeclaration(memberDescriptor);
      if (member != null && member.hasModifier(JetTokens.OPEN_KEYWORD)) {
        trace.report(NON_FINAL_MEMBER_IN_FINAL_CLASS.on(member));
      }
    }
  }
Ejemplo n.º 2
0
 public static void reportAmbiguousLabel(
     @NotNull BindingTrace trace,
     @NotNull JetSimpleNameExpression targetLabel,
     @NotNull Collection<DeclarationDescriptor> declarationsByLabel) {
   Collection<PsiElement> targets = Lists.newArrayList();
   for (DeclarationDescriptor descriptor : declarationsByLabel) {
     PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
     assert element != null : "Label can only point to something in the same lexical scope";
     targets.add(element);
   }
   if (!targets.isEmpty()) {
     trace.record(AMBIGUOUS_LABEL_TARGET, targetLabel, targets);
   }
   trace.report(AMBIGUOUS_LABEL.on(targetLabel));
 }
Ejemplo n.º 3
0
  private void reportEachConstructorOnCycle(@NotNull ConstructorDescriptor startConstructor) {
    ConstructorDescriptor currentConstructor = startConstructor;
    do {
      PsiElement constructorToReport =
          DescriptorToSourceUtils.descriptorToDeclaration(currentConstructor);
      if (constructorToReport != null) {
        JetConstructorDelegationCall call =
            ((JetSecondaryConstructor) constructorToReport).getDelegationCall();
        assert call.getCalleeExpression() != null
            : "Callee expression of delegation call should not be null on cycle as there should be explicit 'this' calls";
        trace.report(CYCLIC_CONSTRUCTOR_DELEGATION_CALL.on(call.getCalleeExpression()));
      }

      currentConstructor = getDelegatedConstructor(currentConstructor);
      assert currentConstructor != null : "Delegated constructor should not be null in cycle";
    } while (startConstructor != currentConstructor);
  }