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;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.annotations.Nullable;
021    import org.jetbrains.kotlin.name.Name;
022    import org.jetbrains.kotlin.types.JetType;
023    
024    import java.util.Set;
025    
026    public interface ValueParameterDescriptor extends VariableDescriptor {
027        /**
028         * Returns the 0-based index of the value parameter in the parameter list of its containing function.
029         *
030         * @return the parameter index
031         */
032        int getIndex();
033    
034        /**
035         * The front-end relies on this property when resolving function calls
036         *
037         * @return {@code true} iff the parameter has a default value, i.e. declares it or inherits
038         *         by overriding a parameter in an overridden function.
039         */
040        boolean hasDefaultValue();
041    
042        /**
043         * The back-end should relies on this property when generating function signatures
044         *
045         * @return {@code true} iff the parameter declares a default value, i.e. explicitly specifies it in the function header
046         */
047        boolean declaresDefaultValue();
048    
049        @Nullable JetType getVarargElementType();
050    
051        @Override
052        @NotNull
053        JetType getType();
054    
055        @NotNull
056        @Override
057        ValueParameterDescriptor getOriginal();
058    
059        @NotNull
060        ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner, @NotNull Name newName);
061    
062        /**
063         * Parameter p1 overrides p2 iff
064         * a) their respective owners (function declarations) f1 override f2
065         * b) p1 and p2 have the same indices in the owners' parameter lists
066         */
067        @NotNull
068        @Override
069        Set<? extends ValueParameterDescriptor> getOverriddenDescriptors();
070    
071        void addOverriddenDescriptor(@NotNull ValueParameterDescriptor overridden);
072    }