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 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 public SimpleFunctionDescriptorImpl(
036 @NotNull DeclarationDescriptor containingDeclaration,
037 @NotNull List<AnnotationDescriptor> annotations,
038 @NotNull Name name,
039 @NotNull Kind kind
040 ) {
041 super(containingDeclaration, annotations, name, kind);
042 }
043
044 protected SimpleFunctionDescriptorImpl(
045 @NotNull DeclarationDescriptor containingDeclaration,
046 @NotNull SimpleFunctionDescriptor original,
047 @NotNull List<AnnotationDescriptor> annotations,
048 @NotNull Name name,
049 @NotNull Kind kind) {
050 super(containingDeclaration, original, annotations, name, kind);
051 }
052
053
054 @NotNull
055 @Override
056 public SimpleFunctionDescriptorImpl initialize(
057 @Nullable JetType receiverParameterType,
058 @Nullable ReceiverParameterDescriptor expectedThisObject,
059 @NotNull List<? extends TypeParameterDescriptor> typeParameters,
060 @NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
061 @Nullable JetType unsubstitutedReturnType,
062 @Nullable Modality modality,
063 @NotNull Visibility visibility
064 ) {
065 super.initialize(receiverParameterType, expectedThisObject, typeParameters, unsubstitutedValueParameters, unsubstitutedReturnType,
066 modality, visibility);
067 this.inlineStrategy = InlineUtil.getInlineType(getAnnotations());
068 return this;
069 }
070
071 @NotNull
072 @Override
073 public SimpleFunctionDescriptor getOriginal() {
074 return (SimpleFunctionDescriptor) super.getOriginal();
075 }
076
077 @Override
078 protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
079 if (preserveOriginal) {
080 return new SimpleFunctionDescriptorImpl(
081 newOwner,
082 getOriginal(),
083 // TODO : safeSubstitute
084 getAnnotations(),
085 getName(),
086 kind);
087 }
088 else {
089 return new SimpleFunctionDescriptorImpl(
090 newOwner,
091 // TODO : safeSubstitute
092 getAnnotations(),
093 getName(),
094 kind);
095 }
096 }
097
098 @NotNull
099 @Override
100 public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
101 SimpleFunctionDescriptorImpl copy = (SimpleFunctionDescriptorImpl)doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, visibility, false, copyOverrides, kind);
102 return copy;
103 }
104
105 @Override
106 public boolean isInline() {
107 return getInlineStrategy() != InlineStrategy.NOT_INLINE;
108 }
109
110 @NotNull
111 public InlineStrategy getInlineStrategy() {
112 return inlineStrategy;
113 }
114 }