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 ) {
063 super.initialize(receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
064 unsubstitutedReturnType, modality, visibility);
065 return this;
066 }
067
068 @NotNull
069 @Override
070 public SimpleFunctionDescriptor getOriginal() {
071 return (SimpleFunctionDescriptor) super.getOriginal();
072 }
073
074 @NotNull
075 @Override
076 protected FunctionDescriptorImpl createSubstitutedCopy(
077 @NotNull DeclarationDescriptor newOwner,
078 @Nullable FunctionDescriptor original,
079 @NotNull Kind kind
080 ) {
081 return new SimpleFunctionDescriptorImpl(
082 newOwner,
083 (SimpleFunctionDescriptor) original,
084 // TODO : safeSubstitute
085 getAnnotations(),
086 getName(),
087 kind,
088 SourceElement.NO_SOURCE
089 );
090 }
091
092 @NotNull
093 @Override
094 public SimpleFunctionDescriptor copy(
095 DeclarationDescriptor newOwner,
096 Modality modality,
097 Visibility visibility,
098 Kind kind,
099 boolean copyOverrides
100 ) {
101 return (SimpleFunctionDescriptorImpl) doSubstitute(
102 TypeSubstitutor.EMPTY, newOwner, modality, visibility, null, copyOverrides, kind
103 );
104 }
105 }