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