Exemplo n.º 1
0
  private void detectAndDisconnectLoops(@NotNull TopDownAnalysisContext c) {
    // Loop detection and disconnection
    List<Runnable> tasks = new ArrayList<Runnable>();
    for (final MutableClassDescriptorLite klass : c.getClassesTopologicalOrder()) {
      for (final JetType supertype : klass.getSupertypes()) {
        ClassifierDescriptor supertypeDescriptor =
            supertype.getConstructor().getDeclarationDescriptor();
        if (supertypeDescriptor instanceof MutableClassDescriptorLite) {
          MutableClassDescriptorLite superclass = (MutableClassDescriptorLite) supertypeDescriptor;
          if (isReachable(superclass, klass, new HashSet<ClassDescriptor>())) {
            tasks.add(
                new Runnable() {
                  @Override
                  public void run() {
                    klass.getSupertypes().remove(supertype);
                  }
                });
            reportCyclicInheritanceHierarchyError(trace, klass, superclass);
          }
        }
      }
    }

    for (Runnable task : tasks) {
      task.run();
    }
  }
Exemplo n.º 2
0
 private static List<ValueParameterDescriptor> getValueParameters(
     FunctionDescriptor functionDescriptor, List<JetType> argumentTypes) {
   List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>();
   for (int i = 0, argumentTypesSize = argumentTypes.size(); i < argumentTypesSize; i++) {
     result.add(
         new ValueParameterDescriptorImpl(
             functionDescriptor,
             i,
             Collections.<AnnotationDescriptor>emptyList(),
             Name.special("<ERROR VALUE_PARAMETER>"),
             ERROR_PARAMETER_TYPE,
             false,
             null));
   }
   return result;
 }