protected AbstractTypeParameterDescriptor(
      @NotNull final StorageManager storageManager,
      @NotNull DeclarationDescriptor containingDeclaration,
      @NotNull Annotations annotations,
      @NotNull Name name,
      @NotNull Variance variance,
      boolean isReified,
      int index) {
    super(containingDeclaration, annotations, name);
    this.variance = variance;
    this.reified = isReified;
    this.index = index;

    this.typeConstructor =
        storageManager.createLazyValue(
            new Function0<TypeConstructor>() {
              @Override
              public TypeConstructor invoke() {
                return createTypeConstructor();
              }
            });
    this.defaultType =
        storageManager.createLazyValue(
            new Function0<JetType>() {
              @Override
              public JetType invoke() {
                return new JetTypeImpl(
                    Annotations.EMPTY,
                    getTypeConstructor(),
                    false,
                    Collections.<TypeProjection>emptyList(),
                    new LazyScopeAdapter(
                        storageManager.createLazyValue(
                            new Function0<JetScope>() {
                              @Override
                              public JetScope invoke() {
                                return getUpperBoundsAsType().getMemberScope();
                              }
                            })));
              }
            });
    this.upperBounds =
        storageManager.createLazyValue(
            new Function0<Set<JetType>>() {
              @Override
              public Set<JetType> invoke() {
                return resolveUpperBounds();
              }
            });
    this.upperBoundsAsType =
        storageManager.createLazyValue(
            new Function0<JetType>() {
              @Override
              public JetType invoke() {
                return computeUpperBoundsAsType();
              }
            });
  }
    public BuiltInsDescriptorFinder(@NotNull StorageManager storageManager) {
      // TODO: support annotations
      super(storageManager, Deserializers.UNSUPPORTED, packageFragmentProvider);

      classNames =
          storageManager.createLazyValue(
              new Function0<Collection<Name>>() {
                @Override
                @NotNull
                public Collection<Name> invoke() {
                  InputStream in =
                      getStream(BuiltInsSerializationUtil.getClassNamesFilePath(getFqName()));

                  try {
                    DataInputStream data = new DataInputStream(in);
                    try {
                      int size = data.readInt();
                      List<Name> result = new ArrayList<Name>(size);
                      for (int i = 0; i < size; i++) {
                        result.add(nameResolver.getName(data.readInt()));
                      }
                      return result;
                    } finally {
                      data.close();
                    }
                  } catch (IOException e) {
                    throw new IllegalStateException(e);
                  }
                }
              });
    }
Example #3
0
 @NotNull
 public static DeferredType create(
     @NotNull StorageManager storageManager,
     @NotNull BindingTrace trace,
     @NotNull Function0<JetType> compute) {
   DeferredType deferredType = new DeferredType(storageManager.createLazyValue(compute));
   trace.record(DEFERRED_TYPE, new Box<DeferredType>(deferredType));
   return deferredType;
 }
Example #4
0
 @NotNull
 public static DeferredType createRecursionIntolerant(
     @NotNull StorageManager storageManager,
     @NotNull BindingTrace trace,
     @NotNull Function0<JetType> compute) {
   //noinspection unchecked
   DeferredType deferredType =
       new DeferredType(
           storageManager.createLazyValueWithPostCompute(
               compute, RECURSION_PREVENTER, EMPTY_CONSUMER));
   trace.record(DEFERRED_TYPE, new Box<DeferredType>(deferredType));
   return deferredType;
 }
  public LazyClassDescriptor(
      @NotNull ResolveSession resolveSession,
      @NotNull DeclarationDescriptor containingDeclaration,
      @NotNull Name name,
      @NotNull JetClassLikeInfo classLikeInfo) {
    super(containingDeclaration, name);
    this.resolveSession = resolveSession;

    if (classLikeInfo.getCorrespondingClassOrObject() != null) {
      this.resolveSession
          .getTrace()
          .record(BindingContext.CLASS, classLikeInfo.getCorrespondingClassOrObject(), this);
    }

    this.originalClassInfo = classLikeInfo;
    JetClassLikeInfo classLikeInfoForMembers =
        classLikeInfo.getClassKind() != ClassKind.ENUM_CLASS
            ? classLikeInfo
            : noEnumEntries(classLikeInfo);
    this.declarationProvider =
        resolveSession
            .getDeclarationProviderFactory()
            .getClassMemberDeclarationProvider(classLikeInfoForMembers);

    this.unsubstitutedMemberScope =
        new LazyClassMemberScope(resolveSession, declarationProvider, this);
    this.unsubstitutedInnerClassesScope = new InnerClassesScopeWrapper(unsubstitutedMemberScope);

    this.typeConstructor = new LazyClassTypeConstructor();

    JetModifierList modifierList = classLikeInfo.getModifierList();
    this.kind = classLikeInfo.getClassKind();
    if (kind.isObject()) {
      this.modality = Modality.FINAL;
    } else {
      Modality defaultModality = kind == ClassKind.TRAIT ? Modality.ABSTRACT : Modality.FINAL;
      this.modality = resolveModalityFromModifiers(modifierList, defaultModality);
    }
    this.visibility = resolveVisibilityFromModifiers(modifierList, getDefaultClassVisibility(this));
    this.isInner = isInnerClass(modifierList);

    StorageManager storageManager = resolveSession.getStorageManager();
    this.thisAsReceiverParameter =
        storageManager.createLazyValue(
            new Function0<ReceiverParameterDescriptor>() {
              @Override
              public ReceiverParameterDescriptor invoke() {
                return DescriptorFactory.createLazyReceiverParameterDescriptor(
                    LazyClassDescriptor.this);
              }
            });
    this.annotations =
        storageManager.createLazyValue(
            new Function0<List<AnnotationDescriptor>>() {
              @Override
              public List<AnnotationDescriptor> invoke() {
                return resolveAnnotations();
              }
            });
    this.classObjectDescriptor =
        storageManager.createNullableLazyValue(
            new Function0<ClassDescriptor>() {
              @Override
              public ClassDescriptor invoke() {
                return computeClassObjectDescriptor();
              }
            });
    this.scopeForClassHeaderResolution =
        storageManager.createLazyValue(
            new Function0<JetScope>() {
              @Override
              public JetScope invoke() {
                return computeScopeForClassHeaderResolution();
              }
            });
    this.scopeForMemberDeclarationResolution =
        storageManager.createLazyValue(
            new Function0<JetScope>() {
              @Override
              public JetScope invoke() {
                return computeScopeForMemberDeclarationResolution();
              }
            });
    this.scopeForPropertyInitializerResolution =
        storageManager.createLazyValue(
            new Function0<JetScope>() {
              @Override
              public JetScope invoke() {
                return computeScopeForPropertyInitializerResolution();
              }
            });
  }