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 import org.jetbrains.kotlin.types.KotlinType;
028
029 import java.util.Collection;
030 import java.util.List;
031
032 public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorImpl {
033 // used for diagnostic only
034 @SuppressWarnings({"UnusedDeclaration", "FieldCanBeLocal"})
035 private final ErrorUtils.ErrorScope ownerScope;
036
037 public ErrorSimpleFunctionDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull ErrorUtils.ErrorScope ownerScope) {
038 super(containingDeclaration, null, Annotations.Companion.getEMPTY(), Name.special("<ERROR FUNCTION>"), Kind.DECLARATION, SourceElement.NO_SOURCE);
039 this.ownerScope = ownerScope;
040 }
041
042 @NotNull
043 @Override
044 protected FunctionDescriptorImpl createSubstitutedCopy(
045 @NotNull DeclarationDescriptor newOwner,
046 @Nullable FunctionDescriptor original,
047 @NotNull Kind kind,
048 @Nullable Name newName,
049 boolean preserveSource
050 ) {
051 return this;
052 }
053
054 @NotNull
055 @Override
056 public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
057 return this;
058 }
059
060 @NotNull
061 @Override
062 public CopyBuilder<? extends SimpleFunctionDescriptor> newCopyBuilder() {
063 return new CopyBuilder<SimpleFunctionDescriptor>() {
064 @NotNull
065 @Override
066 public CopyBuilder<SimpleFunctionDescriptor> setOwner(@NotNull DeclarationDescriptor owner) {
067 return this;
068 }
069
070 @NotNull
071 @Override
072 public CopyBuilder<SimpleFunctionDescriptor> setModality(@NotNull Modality modality) {
073 return this;
074 }
075
076 @NotNull
077 @Override
078 public CopyBuilder<SimpleFunctionDescriptor> setVisibility(@NotNull Visibility visibility) {
079 return this;
080 }
081
082 @NotNull
083 @Override
084 public CopyBuilder<SimpleFunctionDescriptor> setKind(@NotNull Kind kind) {
085 return this;
086 }
087
088 @NotNull
089 @Override
090 public CopyBuilder<SimpleFunctionDescriptor> setCopyOverrides(boolean copyOverrides) {
091 return this;
092 }
093
094 @NotNull
095 @Override
096 public CopyBuilder<SimpleFunctionDescriptor> setName(@NotNull Name name) {
097 return this;
098 }
099
100 @NotNull
101 @Override
102 public CopyBuilder<SimpleFunctionDescriptor> setValueParameters(@NotNull List<ValueParameterDescriptor> parameters) {
103 return this;
104 }
105
106 @NotNull
107 @Override
108 public CopyBuilder<SimpleFunctionDescriptor> setTypeParameters(@NotNull List<TypeParameterDescriptor> parameters) {
109 return this;
110 }
111
112 @NotNull
113 @Override
114 public CopyBuilder<SimpleFunctionDescriptor> setReturnType(@NotNull KotlinType type) {
115 return this;
116 }
117
118 @NotNull
119 @Override
120 public CopyBuilder<SimpleFunctionDescriptor> setExtensionReceiverType(@Nullable KotlinType type) {
121 return this;
122 }
123
124 @NotNull
125 @Override
126 public CopyBuilder<SimpleFunctionDescriptor> setOriginal(@NotNull FunctionDescriptor original) {
127 return this;
128 }
129
130 @NotNull
131 @Override
132 public CopyBuilder<SimpleFunctionDescriptor> setSignatureChange() {
133 return this;
134 }
135
136 @NotNull
137 @Override
138 public CopyBuilder<SimpleFunctionDescriptor> setPreserveSourceElement() {
139 return this;
140 }
141
142 @NotNull
143 @Override
144 public CopyBuilder<SimpleFunctionDescriptor> setDropOriginalInContainingParts() {
145 return this;
146 }
147
148 @NotNull
149 @Override
150 public CopyBuilder<SimpleFunctionDescriptor> setHiddenToOvercomeSignatureClash() {
151 return this;
152 }
153
154 @Nullable
155 @Override
156 public SimpleFunctionDescriptor build() {
157 return ErrorSimpleFunctionDescriptorImpl.this;
158 }
159 };
160 }
161
162 @Override
163 public void setOverriddenDescriptors(@NotNull Collection<? extends CallableMemberDescriptor> overriddenDescriptors) {
164 // nop
165 }
166 }