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