[Analysis API] add KDocs to the substitution-related functionality
This commit is contained in:
+9
@@ -5,10 +5,19 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.impl.base
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtSubstitutor
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
|
||||
/**
|
||||
* A [KtSubstitutor] which substitution logic can be represented as a [Map] from a [KtTypeParameterSymbol] to corresponding [KtType]
|
||||
* This is an implementation details and Analysis API clients should not depend on the fact if some [KtSubstitutor] is [KtMapBackedSubstitutor] or not.
|
||||
*/
|
||||
@KtAnalysisApiInternals
|
||||
interface KtMapBackedSubstitutor : KtSubstitutor {
|
||||
/**
|
||||
* Substitution rules in a form of a `Map<KtTypeParameterSymbol, KtType>`
|
||||
*/
|
||||
fun getAsMap(): Map<KtTypeParameterSymbol, KtType>
|
||||
}
|
||||
+8
-8
@@ -33,8 +33,8 @@ abstract class AbstractKtSignatureSubstitutorImpl : KtSignatureSubstitutor() {
|
||||
if (substitutor is KtSubstitutor.Empty) return signature
|
||||
return KtVariableLikeSignature(
|
||||
signature.symbol,
|
||||
substitutor.substituteOrSelf(signature.returnType),
|
||||
signature.receiverType?.let { substitutor.substituteOrSelf(it) },
|
||||
substitutor.substitute(signature.returnType),
|
||||
signature.receiverType?.let { substitutor.substitute(it) },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ abstract class AbstractKtSignatureSubstitutorImpl : KtSignatureSubstitutor() {
|
||||
if (substitutor is KtSubstitutor.Empty) return signature
|
||||
return KtFunctionLikeSignature(
|
||||
signature.symbol,
|
||||
substitutor.substituteOrSelf(signature.returnType),
|
||||
signature.receiverType?.let { substitutor.substituteOrSelf(it) },
|
||||
substitutor.substitute(signature.returnType),
|
||||
signature.receiverType?.let { substitutor.substitute(it) },
|
||||
signature.valueParameters.map { substitute(it, substitutor) }
|
||||
)
|
||||
}
|
||||
@@ -65,8 +65,8 @@ abstract class AbstractKtSignatureSubstitutorImpl : KtSignatureSubstitutor() {
|
||||
if (substitutor is KtSubstitutor.Empty) return asSignature(symbol)
|
||||
return KtFunctionLikeSignature(
|
||||
symbol,
|
||||
substitutor.substituteOrSelf(symbol.returnType),
|
||||
symbol.receiverType?.let { substitutor.substituteOrSelf(it) },
|
||||
substitutor.substitute(symbol.returnType),
|
||||
symbol.receiverType?.let { substitutor.substitute(it) },
|
||||
symbol.valueParameters.map { substitute(it, substitutor) }
|
||||
)
|
||||
}
|
||||
@@ -75,8 +75,8 @@ abstract class AbstractKtSignatureSubstitutorImpl : KtSignatureSubstitutor() {
|
||||
if (substitutor is KtSubstitutor.Empty) return asSignature(symbol)
|
||||
return KtVariableLikeSignature(
|
||||
symbol,
|
||||
substitutor.substituteOrSelf(symbol.returnType),
|
||||
symbol.receiverType?.let { substitutor.substituteOrSelf(it) },
|
||||
substitutor.substitute(symbol.returnType),
|
||||
symbol.receiverType?.let { substitutor.substitute(it) },
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -102,13 +102,13 @@ abstract class AbstractAnalysisApiSignatureContractsTest : AbstractAnalysisApiSi
|
||||
substitutor: KtSubstitutor,
|
||||
testServices: TestServices
|
||||
) {
|
||||
testServices.assertions.assertEquals(symbol.receiverType?.let(substitutor::substituteOrSelf), signature.receiverType)
|
||||
testServices.assertions.assertEquals(symbol.returnType.let(substitutor::substituteOrSelf), signature.returnType)
|
||||
testServices.assertions.assertEquals(symbol.receiverType?.let(substitutor::substitute), signature.receiverType)
|
||||
testServices.assertions.assertEquals(symbol.returnType.let(substitutor::substitute), signature.returnType)
|
||||
|
||||
testServices.assertions.assertEquals(symbol.valueParameters.size, signature.valueParameters.size)
|
||||
|
||||
for ((unsubstituted, substituted) in symbol.valueParameters.zip(signature.valueParameters)) {
|
||||
testServices.assertions.assertEquals(substituted.returnType, unsubstituted.returnType.let(substitutor::substituteOrSelf))
|
||||
testServices.assertions.assertEquals(substituted.returnType, unsubstituted.returnType.let(substitutor::substitute))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ abstract class AbstractAnalysisApiSignatureContractsTest : AbstractAnalysisApiSi
|
||||
substitutor: KtSubstitutor,
|
||||
testServices: TestServices
|
||||
) {
|
||||
testServices.assertions.assertEquals(symbol.receiverType?.let(substitutor::substituteOrSelf), signature.receiverType)
|
||||
testServices.assertions.assertEquals(symbol.returnType.let(substitutor::substituteOrSelf), signature.returnType)
|
||||
testServices.assertions.assertEquals(symbol.receiverType?.let(substitutor::substitute), signature.receiverType)
|
||||
testServices.assertions.assertEquals(symbol.returnType.let(substitutor::substitute), signature.returnType)
|
||||
}
|
||||
|
||||
private fun <L> MutableList<List<L>>.combinations(list: List<L>, state: PersistentList<L>, size: Int) {
|
||||
|
||||
Reference in New Issue
Block a user