001 /*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.jet.lang.descriptors.impl;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
021 import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
022 import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
023 import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
024 import org.jetbrains.jet.lang.resolve.name.Name;
025 import org.jetbrains.jet.lang.types.JetType;
026 import org.jetbrains.jet.lang.types.TypeConstructor;
027 import org.jetbrains.jet.lang.types.Variance;
028 import org.jetbrains.jet.storage.StorageManager;
029
030 import java.util.Collection;
031 import java.util.Collections;
032 import java.util.List;
033
034 public abstract class AbstractLazyTypeParameterDescriptor extends AbstractTypeParameterDescriptor {
035 public AbstractLazyTypeParameterDescriptor(
036 @NotNull StorageManager storageManager,
037 @NotNull DeclarationDescriptor containingDeclaration,
038 @NotNull Name name,
039 @NotNull Variance variance,
040 boolean isReified,
041 int index
042 ) {
043 super(storageManager, containingDeclaration, Annotations.EMPTY /* TODO */, name, variance, isReified, index);
044 }
045
046 @NotNull
047 @Override
048 protected TypeConstructor createTypeConstructor() {
049 return new TypeConstructor() {
050 @NotNull
051 @Override
052 public Collection<JetType> getSupertypes() {
053 return AbstractLazyTypeParameterDescriptor.this.getUpperBounds();
054 }
055
056 @NotNull
057 @Override
058 public List<TypeParameterDescriptor> getParameters() {
059 return Collections.emptyList();
060 }
061
062 @Override
063 public boolean isFinal() {
064 return false;
065 }
066
067 @Override
068 public boolean isDenotable() {
069 return true;
070 }
071
072 @Override
073 public ClassifierDescriptor getDeclarationDescriptor() {
074 return AbstractLazyTypeParameterDescriptor.this;
075 }
076
077 @NotNull
078 @Override
079 public Annotations getAnnotations() {
080 return AbstractLazyTypeParameterDescriptor.this.getAnnotations();
081 }
082
083 @Override
084 public String toString() {
085 return getName().toString();
086 }
087 };
088 }
089 }