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.annotations.Nullable;
021    import org.jetbrains.jet.lang.descriptors.*;
022    import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
023    import org.jetbrains.jet.lang.resolve.name.Name;
024    import org.jetbrains.jet.lang.types.JetType;
025    import org.jetbrains.jet.lang.types.TypeSubstitutor;
026    
027    import java.util.List;
028    
029    public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl implements SimpleFunctionDescriptor {
030    
031        private boolean isInline = false;
032    
033        public SimpleFunctionDescriptorImpl(
034                @NotNull DeclarationDescriptor containingDeclaration,
035                @NotNull List<AnnotationDescriptor> annotations,
036                @NotNull Name name,
037                @NotNull Kind kind
038        ) {
039            super(containingDeclaration, annotations, name, kind);
040        }
041    
042        private SimpleFunctionDescriptorImpl(
043                @NotNull DeclarationDescriptor containingDeclaration,
044                @NotNull SimpleFunctionDescriptor original,
045                @NotNull List<AnnotationDescriptor> annotations,
046                @NotNull Name name,
047                @NotNull Kind kind) {
048            super(containingDeclaration, original, annotations, name, kind);
049        }
050    
051        public SimpleFunctionDescriptorImpl initialize(
052                @Nullable JetType receiverParameterType,
053                @Nullable ReceiverParameterDescriptor expectedThisObject,
054                @NotNull List<? extends TypeParameterDescriptor> typeParameters,
055                @NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
056                @Nullable JetType unsubstitutedReturnType,
057                @Nullable Modality modality,
058                @NotNull Visibility visibility,
059                boolean isInline) {
060            super.initialize(receiverParameterType, expectedThisObject, typeParameters, unsubstitutedValueParameters, unsubstitutedReturnType, modality, visibility);
061            this.isInline = isInline;
062            return this;
063        }
064    
065        @NotNull
066        @Override
067        public SimpleFunctionDescriptor getOriginal() {
068            return (SimpleFunctionDescriptor) super.getOriginal();
069        }
070    
071        @Override
072        protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
073            if (preserveOriginal) {
074                return new SimpleFunctionDescriptorImpl(
075                        newOwner,
076                        getOriginal(),
077                        // TODO : safeSubstitute
078                        getAnnotations(),
079                        getName(),
080                        kind);
081            }
082            else {
083                return new SimpleFunctionDescriptorImpl(
084                        newOwner,
085                        // TODO : safeSubstitute
086                        getAnnotations(),
087                        getName(),
088                        kind);
089            }
090        }
091    
092        @NotNull
093        @Override
094        public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
095            SimpleFunctionDescriptorImpl copy = (SimpleFunctionDescriptorImpl)doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, visibility, false, copyOverrides, kind);
096            copy.isInline = isInline;
097            return copy;
098        }
099    
100        @Override
101        public boolean isInline() {
102            return isInline;
103        }
104    }