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.types.error;
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.descriptors.impl.FunctionDescriptorImpl;
024    import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
025    import org.jetbrains.kotlin.name.Name;
026    import org.jetbrains.kotlin.types.ErrorUtils;
027    
028    import java.util.Collection;
029    import java.util.List;
030    
031    public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorImpl {
032        // used for diagnostic only
033        @SuppressWarnings({"UnusedDeclaration", "FieldCanBeLocal"})
034        private final ErrorUtils.ErrorScope ownerScope;
035    
036        public ErrorSimpleFunctionDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull ErrorUtils.ErrorScope ownerScope) {
037            super(containingDeclaration, null, Annotations.Companion.getEMPTY(), Name.special("<ERROR FUNCTION>"), Kind.DECLARATION, SourceElement.NO_SOURCE);
038            this.ownerScope = ownerScope;
039        }
040    
041        @NotNull
042        @Override
043        protected FunctionDescriptorImpl createSubstitutedCopy(
044                @NotNull DeclarationDescriptor newOwner,
045                @Nullable FunctionDescriptor original,
046                @NotNull Kind kind,
047                @Nullable Name newName,
048                boolean preserveSource
049        ) {
050            return this;
051        }
052    
053        @NotNull
054        @Override
055        public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
056            return this;
057        }
058    
059        @NotNull
060        @Override
061        public SimpleFunctionDescriptor createRenamedCopy(@NotNull Name name) {
062            return this;
063        }
064    
065        @NotNull
066        @Override
067        public SimpleFunctionDescriptor createCopyWithNewValueParameters(@NotNull List<ValueParameterDescriptor> valueParameters) {
068            return this;
069        }
070    
071        @NotNull
072        @Override
073        public SimpleFunctionDescriptor createCopyWithNewTypeParameters(@NotNull List<TypeParameterDescriptor> typeParameters) {
074            return this;
075        }
076    
077        @NotNull
078        @Override
079        public SimpleFunctionDescriptor createHiddenCopyToOvercomeSignatureClash() {
080            return this;
081        }
082    
083        @Override
084        public void setOverriddenDescriptors(@NotNull Collection<? extends CallableMemberDescriptor> overriddenDescriptors) {
085            // nop
086        }
087    }