1 /*
2  * Copyright 2020 Google LLC
3  * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 package com.google.devtools.ksp.symbol.impl.kotlin
18 
19 import com.google.devtools.ksp.symbol.KSFunction
20 import com.google.devtools.ksp.symbol.KSFunctionDeclaration
21 import com.google.devtools.ksp.symbol.KSType
22 import com.google.devtools.ksp.symbol.KSTypeParameter
23 
24 /**
25  * Used when `ResolverImpl.asMemberOf` is called with an error type or function declaration cannot be found.
26  */
27 class KSFunctionErrorImpl(
28     private val declaration: KSFunctionDeclaration
29 ) : KSFunction {
30     override val isError: Boolean = true
31 
32     override val returnType: KSType = KSErrorType
33 
34     override val parameterTypes: List<KSType?>
<lambda>null35         get() = declaration.parameters.map {
36             KSErrorType
37         }
38     override val typeParameters: List<KSTypeParameter>
39         get() = emptyList()
40 
41     override val extensionReceiverType: KSType?
<lambda>null42         get() = declaration.extensionReceiver?.let {
43             KSErrorType
44         }
45 
equalsnull46     override fun equals(other: Any?): Boolean {
47         if (this === other) return true
48         if (javaClass != other?.javaClass) return false
49 
50         other as KSFunctionErrorImpl
51 
52         if (declaration != other.declaration) return false
53 
54         return true
55     }
56 
hashCodenull57     override fun hashCode(): Int {
58         return declaration.hashCode()
59     }
60 }
61