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
017package org.jetbrains.jet.lang.descriptors.impl;
018
019import org.jetbrains.annotations.NotNull;
020import org.jetbrains.annotations.Nullable;
021import org.jetbrains.jet.lang.descriptors.*;
022import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
023import org.jetbrains.jet.lang.resolve.name.Name;
024import org.jetbrains.jet.lang.types.JetType;
025
026import java.util.Collections;
027import java.util.List;
028import java.util.Set;
029
030public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRootImpl implements VariableDescriptor {
031    private JetType outType;
032
033    public VariableDescriptorImpl(
034            @NotNull DeclarationDescriptor containingDeclaration,
035            @NotNull List<AnnotationDescriptor> annotations,
036            @NotNull Name name,
037            @Nullable JetType outType) {
038        super(containingDeclaration, annotations, name);
039
040        this.outType = outType;
041    }
042
043    protected VariableDescriptorImpl(
044            @NotNull DeclarationDescriptor containingDeclaration,
045            @NotNull List<AnnotationDescriptor> annotations,
046            @NotNull Name name
047    )
048    {
049        this(containingDeclaration, annotations, name, null);
050    }
051
052    @NotNull
053    @Override
054    public JetType getType() {
055        return outType;
056    }
057
058    public void setOutType(JetType outType) {
059        assert this.outType == null;
060        this.outType = outType;
061    }
062
063    @Override
064    @NotNull
065    public VariableDescriptor getOriginal() {
066        return (VariableDescriptor) super.getOriginal();
067    }
068
069    @NotNull
070    @Override
071    public List<ValueParameterDescriptor> getValueParameters() {
072        return Collections.emptyList();
073    }
074
075    @NotNull
076    @Override
077    public Set<? extends CallableDescriptor> getOverriddenDescriptors() {
078        return Collections.emptySet();
079    }
080
081    @NotNull
082    @Override
083    public List<TypeParameterDescriptor> getTypeParameters() {
084        return Collections.emptyList();
085    }
086
087    @Override
088    public ReceiverParameterDescriptor getReceiverParameter() {
089        return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
090    }
091
092    @Override
093    public ReceiverParameterDescriptor getExpectedThisObject() {
094        return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
095    }
096
097    @NotNull
098    @Override
099    public JetType getReturnType() {
100        return getType();
101    }
102}