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