private static Collection<DeclarationDescriptor> getAllVariables(LexicalScope scope) {
   Collection<DeclarationDescriptor> result = ContainerUtil.newArrayList();
   result.addAll(
       ScopeUtilsKt.collectDescriptorsFiltered(
           scope, DescriptorKindFilter.VARIABLES, MemberScope.Companion.getALL_NAME_FILTER()));
   for (ReceiverParameterDescriptor implicitReceiver :
       ScopeUtilsKt.getImplicitReceiversHierarchy(scope)) {
     result.addAll(DescriptorUtils.getAllDescriptors(implicitReceiver.getType().getMemberScope()));
   }
   return result;
 }
  private void checkSupertypesForConsistency(@NotNull ClassDescriptor classDescriptor) {
    Multimap<TypeConstructor, TypeProjection> multimap =
        SubstitutionUtils.buildDeepSubstitutionMultimap(classDescriptor.getDefaultType());
    for (Map.Entry<TypeConstructor, Collection<TypeProjection>> entry :
        multimap.asMap().entrySet()) {
      Collection<TypeProjection> projections = entry.getValue();
      if (projections.size() > 1) {
        TypeConstructor typeConstructor = entry.getKey();
        DeclarationDescriptor declarationDescriptor = typeConstructor.getDeclarationDescriptor();
        assert declarationDescriptor instanceof TypeParameterDescriptor : declarationDescriptor;
        TypeParameterDescriptor typeParameterDescriptor =
            (TypeParameterDescriptor) declarationDescriptor;

        // Immediate arguments of supertypes cannot be projected
        Set<JetType> conflictingTypes = Sets.newLinkedHashSet();
        for (TypeProjection projection : projections) {
          conflictingTypes.add(projection.getType());
        }
        removeDuplicateTypes(conflictingTypes);
        if (conflictingTypes.size() > 1) {
          DeclarationDescriptor containingDeclaration =
              typeParameterDescriptor.getContainingDeclaration();
          assert containingDeclaration instanceof ClassDescriptor : containingDeclaration;
          JetClassOrObject psiElement =
              (JetClassOrObject) DescriptorToSourceUtils.getSourceFromDescriptor(classDescriptor);
          assert psiElement != null;
          JetDelegationSpecifierList delegationSpecifierList =
              psiElement.getDelegationSpecifierList();
          assert delegationSpecifierList != null;
          //
          // trace.getErrorHandler().genericError(delegationSpecifierList.getNode(), "Type parameter
          // " + typeParameterDescriptor.getName() + " of " + containingDeclaration.getName() + "
          // has inconsistent values: " + conflictingTypes);
          trace.report(
              INCONSISTENT_TYPE_PARAMETER_VALUES.on(
                  delegationSpecifierList,
                  typeParameterDescriptor,
                  (ClassDescriptor) containingDeclaration,
                  conflictingTypes));
        }
      }
    }
  }
  @NotNull
  @Override
  public LightClassConstructionContext getContextForPackage(@NotNull Collection<JetFile> files) {
    assert !files.isEmpty() : "No files in package";

    List<JetFile> sortedFiles = new ArrayList<JetFile>(files);
    Collections.sort(sortedFiles, scopeFileComparator);

    JetFile file = sortedFiles.get(0);
    ResolveSessionForBodies session =
        KotlinCacheService.getInstance(file.getProject()).getLazyResolveSession(file);
    forceResolvePackageDeclarations(files, session);
    return new LightClassConstructionContext(
        session.getBindingContext(), session.getModuleDescriptor());
  }