KT-11588 Type aliases
Make type alias expansion PSI-independent
This commit is contained in:
@@ -1169,22 +1169,15 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void checkBoundsInTypeAlias(
|
public static void checkBoundsInTypeAlias(
|
||||||
@NotNull KtUserType typeAliasElement,
|
@NotNull TypeAliasExpansionReportStrategy reportStrategy,
|
||||||
@NotNull KotlinType typeArgument,
|
@NotNull KotlinType typeArgument,
|
||||||
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
||||||
@NotNull TypeSubstitutor substitutor,
|
@NotNull TypeSubstitutor substitutor
|
||||||
@NotNull BindingTrace trace
|
|
||||||
) {
|
) {
|
||||||
DeclarationDescriptor containingDeclaration = typeParameterDescriptor.getContainingDeclaration();
|
|
||||||
assert containingDeclaration instanceof ClassifierDescriptor :
|
|
||||||
"Containing declaration of a type parameter should be a classifier, got " + containingDeclaration;
|
|
||||||
ClassifierDescriptor containingClassifier = (ClassifierDescriptor) containingDeclaration;
|
|
||||||
|
|
||||||
for (KotlinType bound : typeParameterDescriptor.getUpperBounds()) {
|
for (KotlinType bound : typeParameterDescriptor.getUpperBounds()) {
|
||||||
KotlinType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT);
|
KotlinType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT);
|
||||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) {
|
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) {
|
||||||
trace.report(UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION.on(
|
reportStrategy.boundsViolationInSubstitution(substitutedBound, typeArgument, typeParameterDescriptor);
|
||||||
typeAliasElement, substitutedBound, typeArgument, containingClassifier));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
|
interface TypeAliasExpansionReportStrategy {
|
||||||
|
fun wrongNumberOfTypeArguments(typeAlias: TypeAliasDescriptor, numberOfParameters: Int)
|
||||||
|
fun conflictingProjection(typeAlias: TypeAliasDescriptor, typeParameter: TypeParameterDescriptor?, expandingType: KotlinType)
|
||||||
|
fun recursiveTypeAlias(typeAlias: TypeAliasDescriptor)
|
||||||
|
fun boundsViolationInSubstitution(bound: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor)
|
||||||
|
|
||||||
|
object DEFAULT : TypeAliasExpansionReportStrategy {
|
||||||
|
override fun wrongNumberOfTypeArguments(typeAlias: TypeAliasDescriptor, numberOfParameters: Int) {}
|
||||||
|
override fun conflictingProjection(typeAlias: TypeAliasDescriptor, typeParameter: TypeParameterDescriptor?, expandingType: KotlinType) {}
|
||||||
|
override fun recursiveTypeAlias(typeAlias: TypeAliasDescriptor) {}
|
||||||
|
override fun boundsViolationInSubstitution(bound: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -428,9 +428,13 @@ class TypeResolver(
|
|||||||
// TODO appendDefaultArgumentsForInnerScope
|
// TODO appendDefaultArgumentsForInnerScope
|
||||||
val typeAliasArguments = typeAliasQualifierPart.typeArguments?.arguments.orEmpty()
|
val typeAliasArguments = typeAliasQualifierPart.typeArguments?.arguments.orEmpty()
|
||||||
|
|
||||||
|
val reportStrategy = TracingTypeAliasExpansionReportStrategy(
|
||||||
|
c.trace,
|
||||||
|
type, typeAliasQualifierPart.typeArguments ?: typeAliasQualifierPart.expression,
|
||||||
|
typeAliasDescriptor, typeAliasDescriptor.declaredTypeParameters, typeAliasArguments)
|
||||||
|
|
||||||
if (typeAliasParameters.size != typeAliasArguments.size) {
|
if (typeAliasParameters.size != typeAliasArguments.size) {
|
||||||
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(typeAliasQualifierPart.typeArguments ?: typeAliasQualifierPart.expression,
|
reportStrategy.wrongNumberOfTypeArguments(typeAliasDescriptor, typeAliasParameters.size)
|
||||||
typeAliasParameters.size, typeAliasDescriptor))
|
|
||||||
return createErrorTypeForTypeConstructor(c, projectionFromAllQualifierParts, typeAliasConstructor)
|
return createErrorTypeForTypeConstructor(c, projectionFromAllQualifierParts, typeAliasConstructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,24 +444,56 @@ class TypeResolver(
|
|||||||
type(abbreviatedType)
|
type(abbreviatedType)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val typeAliasExpansion = createTypeAliasExpansionFromSource(c, type, typeAliasDescriptor, typeAliasArguments)
|
val arguments = resolveTypeProjections(c, typeAliasDescriptor.typeConstructor, typeAliasArguments)
|
||||||
val expandedType = expandTypeAlias(c, typeAliasExpansion, annotations)
|
val typeAliasExpansion = createTypeAliasExpansion(null, typeAliasDescriptor, arguments)
|
||||||
|
val expandedType = expandTypeAlias(c, typeAliasExpansion, reportStrategy, annotations, 0)
|
||||||
type(expandedType)
|
type(expandedType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TracingTypeAliasExpansionReportStrategy(
|
||||||
|
val trace: BindingTrace,
|
||||||
|
val type: KtUserType,
|
||||||
|
val typeArgumentsOrTypeName: KtElement,
|
||||||
|
val typeAliasDescriptor: TypeAliasDescriptor,
|
||||||
|
val typeParameters: List<TypeParameterDescriptor>,
|
||||||
|
val typeArguments: List<KtTypeProjection>
|
||||||
|
) : TypeAliasExpansionReportStrategy {
|
||||||
|
private val mappedArguments = typeParameters.zip(typeArguments).toMap()
|
||||||
|
|
||||||
|
override fun wrongNumberOfTypeArguments(typeAlias: TypeAliasDescriptor, numberOfParameters: Int) {
|
||||||
|
trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(typeArgumentsOrTypeName, numberOfParameters, typeAliasDescriptor))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun conflictingProjection(typeAlias: TypeAliasDescriptor, typeParameter: TypeParameterDescriptor?, expandingType: KotlinType) {
|
||||||
|
val argumentElement = typeParameter?.let { mappedArguments[it] }
|
||||||
|
if (argumentElement != null && typeParameter != null) {
|
||||||
|
trace.report(CONFLICTING_PROJECTION.on(argumentElement, typeParameter))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
trace.report(CONFLICTING_PROJECTION_IN_TYPEALIAS_EXPANSION.on(type, typeAliasDescriptor.underlyingType))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun recursiveTypeAlias(typeAlias: TypeAliasDescriptor) {
|
||||||
|
trace.report(RECURSIVE_TYPEALIAS_EXPANSION.on(type, typeAlias))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun boundsViolationInSubstitution(bound: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor) {
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class AbbreviatedTypeImpl(override val abbreviatedType: KotlinType): AbbreviatedType
|
private class AbbreviatedTypeImpl(override val abbreviatedType: KotlinType): AbbreviatedType
|
||||||
|
|
||||||
private fun withAbbreviatedType(abbreviatedType: KotlinType): TypeCapabilities =
|
private fun KotlinType.withAbbreviatedType(abbreviatedType: KotlinType): KotlinType =
|
||||||
SingletonTypeCapabilities(AbbreviatedType::class.java, AbbreviatedTypeImpl(abbreviatedType))
|
if (isError)
|
||||||
|
this
|
||||||
private class TypeAliasExpansionContext(
|
else
|
||||||
val element: KtUserType,
|
replace(newCapabilities = capabilities.overrideCapability(AbbreviatedType::class.java,
|
||||||
val argumentElements: Map<TypeParameterDescriptor, KtTypeProjection>
|
AbbreviatedTypeImpl(abbreviatedType)))
|
||||||
)
|
|
||||||
|
|
||||||
private class TypeAliasExpansion(
|
private class TypeAliasExpansion(
|
||||||
val context: TypeAliasExpansionContext,
|
|
||||||
val parent: TypeAliasExpansion?,
|
val parent: TypeAliasExpansion?,
|
||||||
val descriptor: TypeAliasDescriptor,
|
val descriptor: TypeAliasDescriptor,
|
||||||
val arguments: List<TypeProjection>,
|
val arguments: List<TypeProjection>,
|
||||||
@@ -475,57 +511,28 @@ class TypeResolver(
|
|||||||
this.descriptor == descriptor || (parent?.isRecursion(descriptor) ?: false)
|
this.descriptor == descriptor || (parent?.isRecursion(descriptor) ?: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTypeAliasExpansionFromSource(
|
private fun createTypeAliasExpansion(
|
||||||
c: TypeResolutionContext,
|
parent: TypeAliasExpansion?,
|
||||||
element: KtUserType,
|
|
||||||
descriptor: TypeAliasDescriptor,
|
|
||||||
argumentElements: List<KtTypeProjection>
|
|
||||||
): TypeAliasExpansion {
|
|
||||||
val typeAliasParameters = descriptor.typeConstructor.parameters
|
|
||||||
val arguments = resolveTypeProjections(c, descriptor.typeConstructor, argumentElements)
|
|
||||||
|
|
||||||
val mappedArguments: Map<TypeParameterDescriptor, TypeProjection>
|
|
||||||
val mappedElements: Map<TypeParameterDescriptor, KtTypeProjection>
|
|
||||||
if (typeAliasParameters.isNotEmpty()) {
|
|
||||||
val resultingArguments = HashMap<TypeParameterDescriptor, TypeProjection>()
|
|
||||||
val resultingElements = HashMap<TypeParameterDescriptor, KtTypeProjection>()
|
|
||||||
typeAliasParameters.forEachIndexed { i, typeParameterDescriptor ->
|
|
||||||
resultingArguments[typeParameterDescriptor] = arguments[i]
|
|
||||||
resultingElements[typeParameterDescriptor] = argumentElements[i]
|
|
||||||
}
|
|
||||||
mappedArguments = resultingArguments
|
|
||||||
mappedElements = resultingElements
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mappedArguments = emptyMap()
|
|
||||||
mappedElements = emptyMap()
|
|
||||||
}
|
|
||||||
|
|
||||||
return TypeAliasExpansion(TypeAliasExpansionContext(element, mappedElements), null, descriptor, arguments, mappedArguments)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createNestedTypeAliasExpansion(
|
|
||||||
parent: TypeAliasExpansion,
|
|
||||||
typeAliasDescriptor: TypeAliasDescriptor,
|
typeAliasDescriptor: TypeAliasDescriptor,
|
||||||
expandedArguments: List<TypeProjection>
|
arguments: List<TypeProjection>
|
||||||
): TypeAliasExpansion {
|
): TypeAliasExpansion {
|
||||||
val mappedArguments = HashMap<TypeParameterDescriptor, TypeProjection>()
|
val typeParameters = typeAliasDescriptor.declaredTypeParameters // TODO inner type aliases
|
||||||
typeAliasDescriptor.typeConstructor.parameters.forEachIndexed { i, typeParameterDescriptor ->
|
val mappedArguments = typeParameters.zip(arguments).toMap()
|
||||||
mappedArguments[typeParameterDescriptor] = expandedArguments[i]
|
return TypeAliasExpansion(parent, typeAliasDescriptor, arguments, mappedArguments)
|
||||||
}
|
|
||||||
|
|
||||||
return TypeAliasExpansion(parent.context, parent, typeAliasDescriptor, expandedArguments, mappedArguments)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun expandTypeAlias(
|
private fun expandTypeAlias(
|
||||||
c: TypeResolutionContext,
|
c: TypeResolutionContext,
|
||||||
typeAliasExpansion: TypeAliasExpansion,
|
typeAliasExpansion: TypeAliasExpansion,
|
||||||
annotations: Annotations
|
reportStrategy: TypeAliasExpansionReportStrategy,
|
||||||
|
annotations: Annotations,
|
||||||
|
recursionDepth: Int
|
||||||
): KotlinType {
|
): KotlinType {
|
||||||
val originalProjection = TypeProjectionImpl(Variance.INVARIANT, typeAliasExpansion.descriptor.underlyingType)
|
val originalProjection = TypeProjectionImpl(Variance.INVARIANT, typeAliasExpansion.descriptor.underlyingType)
|
||||||
val expandedProjection = expandTypeProjectionForTypeAlias(c, originalProjection, typeAliasExpansion, null, 1)
|
val expandedProjection = expandTypeProjectionForTypeAlias(c, originalProjection, typeAliasExpansion, null, reportStrategy, recursionDepth)
|
||||||
|
val expandedType = expandedProjection.type
|
||||||
|
|
||||||
if (expandedProjection.type.isError) return expandedProjection.type
|
if (expandedType.isError) return expandedType
|
||||||
|
|
||||||
assert(expandedProjection.projectionKind == Variance.INVARIANT) {
|
assert(expandedProjection.projectionKind == Variance.INVARIANT) {
|
||||||
"Type alias expansion: result for ${typeAliasExpansion.descriptor} is ${expandedProjection.projectionKind}, should be invariant"
|
"Type alias expansion: result for ${typeAliasExpansion.descriptor} is ${expandedProjection.projectionKind}, should be invariant"
|
||||||
@@ -535,9 +542,7 @@ class TypeResolver(
|
|||||||
originalProjection.type.isMarkedNullable,
|
originalProjection.type.isMarkedNullable,
|
||||||
typeAliasExpansion.arguments, MemberScope.Empty)
|
typeAliasExpansion.arguments, MemberScope.Empty)
|
||||||
|
|
||||||
return expandedProjection.type.replace(
|
return expandedType.withAbbreviatedType(abbreviatedType)
|
||||||
newAnnotations = annotations,
|
|
||||||
newCapabilities = withAbbreviatedType(abbreviatedType))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun expandTypeProjectionForTypeAlias(
|
private fun expandTypeProjectionForTypeAlias(
|
||||||
@@ -545,6 +550,7 @@ class TypeResolver(
|
|||||||
originalProjection: TypeProjection,
|
originalProjection: TypeProjection,
|
||||||
typeAliasExpansion: TypeAliasExpansion,
|
typeAliasExpansion: TypeAliasExpansion,
|
||||||
typeParameterDescriptor: TypeParameterDescriptor?,
|
typeParameterDescriptor: TypeParameterDescriptor?,
|
||||||
|
reportStrategy: TypeAliasExpansionReportStrategy,
|
||||||
recursionDepth: Int
|
recursionDepth: Int
|
||||||
): TypeProjection {
|
): TypeProjection {
|
||||||
assertRecursionDepth(recursionDepth) {
|
assertRecursionDepth(recursionDepth) {
|
||||||
@@ -556,7 +562,7 @@ class TypeResolver(
|
|||||||
val typeAliasArgument = typeAliasExpansion.getReplacement(originalType.constructor)
|
val typeAliasArgument = typeAliasExpansion.getReplacement(originalType.constructor)
|
||||||
|
|
||||||
if (typeAliasArgument == null) {
|
if (typeAliasArgument == null) {
|
||||||
return substituteNonArgumentTypeForTypeAlias(c, originalProjection, typeAliasExpansion, recursionDepth)
|
return substituteNonArgumentTypeForTypeAlias(c, originalProjection, typeAliasExpansion, reportStrategy, recursionDepth)
|
||||||
}
|
}
|
||||||
|
|
||||||
val originalVariance =
|
val originalVariance =
|
||||||
@@ -578,14 +584,7 @@ class TypeResolver(
|
|||||||
argumentVariance
|
argumentVariance
|
||||||
else {
|
else {
|
||||||
if (originalVariance != argumentVariance && !typeAliasArgument.isStarProjection) {
|
if (originalVariance != argumentVariance && !typeAliasArgument.isStarProjection) {
|
||||||
val argumentElement = typeParameterDescriptor?.let { typeAliasExpansion.context.argumentElements[it] }
|
reportStrategy.conflictingProjection(typeAliasExpansion.descriptor, typeParameterDescriptor, originalType)
|
||||||
if (argumentElement != null && typeParameterDescriptor != null) {
|
|
||||||
c.trace.report(CONFLICTING_PROJECTION.on(argumentElement, typeParameterDescriptor))
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c.trace.report(CONFLICTING_PROJECTION_IN_TYPEALIAS_EXPANSION.on(
|
|
||||||
typeAliasExpansion.context.element, typeAliasExpansion.descriptor.underlyingType))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
argumentVariance
|
argumentVariance
|
||||||
}
|
}
|
||||||
@@ -599,6 +598,7 @@ class TypeResolver(
|
|||||||
c: TypeResolutionContext,
|
c: TypeResolutionContext,
|
||||||
originalProjection: TypeProjection,
|
originalProjection: TypeProjection,
|
||||||
typeAliasExpansion: TypeAliasExpansion,
|
typeAliasExpansion: TypeAliasExpansion,
|
||||||
|
reportStrategy: TypeAliasExpansionReportStrategy,
|
||||||
recursionDepth: Int
|
recursionDepth: Int
|
||||||
): TypeProjection {
|
): TypeProjection {
|
||||||
val type = originalProjection.type
|
val type = originalProjection.type
|
||||||
@@ -611,27 +611,26 @@ class TypeResolver(
|
|||||||
}
|
}
|
||||||
is TypeAliasDescriptor -> {
|
is TypeAliasDescriptor -> {
|
||||||
if (typeAliasExpansion.isRecursion(typeDescriptor)) {
|
if (typeAliasExpansion.isRecursion(typeDescriptor)) {
|
||||||
c.trace.report(RECURSIVE_TYPEALIAS_EXPANSION.on(typeAliasExpansion.context.element, typeDescriptor))
|
reportStrategy.recursiveTypeAlias(typeDescriptor)
|
||||||
return TypeProjectionImpl(Variance.INVARIANT, ErrorUtils.createErrorType("Recursive type alias: ${typeDescriptor.name}"))
|
return TypeProjectionImpl(Variance.INVARIANT, ErrorUtils.createErrorType("Recursive type alias: ${typeDescriptor.name}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val expandedArguments = type.arguments.mapIndexed { i, typeAliasArgument ->
|
val expandedArguments = type.arguments.mapIndexed { i, typeAliasArgument ->
|
||||||
expandTypeProjectionForTypeAlias(c, typeAliasArgument, typeAliasExpansion, typeConstructor.parameters[i], recursionDepth)
|
expandTypeProjectionForTypeAlias(c, typeAliasArgument, typeAliasExpansion, typeConstructor.parameters[i], reportStrategy, recursionDepth + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
val nestedExpansion = createNestedTypeAliasExpansion(typeAliasExpansion, typeDescriptor, expandedArguments)
|
val nestedExpansion = createTypeAliasExpansion(typeAliasExpansion, typeDescriptor, expandedArguments)
|
||||||
|
|
||||||
val expandedType = expandTypeAlias(c, nestedExpansion, type.annotations)
|
val expandedType = expandTypeAlias(c, nestedExpansion, reportStrategy, type.annotations, recursionDepth + 1)
|
||||||
|
|
||||||
return TypeProjectionImpl(originalProjection.projectionKind,
|
return TypeProjectionImpl(originalProjection.projectionKind, expandedType.withAbbreviatedType(type))
|
||||||
if (expandedType.isError) expandedType else expandedType.replace(newCapabilities = withAbbreviatedType(type)))
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val substitutedArguments = type.arguments.mapIndexed { i, originalArgument ->
|
val substitutedArguments = type.arguments.mapIndexed { i, originalArgument ->
|
||||||
expandTypeProjectionForTypeAlias(c, originalArgument, typeAliasExpansion, typeConstructor.parameters[i], recursionDepth + 1)
|
expandTypeProjectionForTypeAlias(c, originalArgument, typeAliasExpansion, typeConstructor.parameters[i], reportStrategy, recursionDepth + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
checkTypeArgumentsSubstitutionInTypeAliasExpansion(c, type, substitutedArguments, typeAliasExpansion)
|
checkTypeArgumentsSubstitutionInTypeAliasExpansion(type, substitutedArguments, reportStrategy)
|
||||||
|
|
||||||
val substitutedType = type.replace(newArguments = substitutedArguments)
|
val substitutedType = type.replace(newArguments = substitutedArguments)
|
||||||
|
|
||||||
@@ -641,16 +640,15 @@ class TypeResolver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkTypeArgumentsSubstitutionInTypeAliasExpansion(
|
private fun checkTypeArgumentsSubstitutionInTypeAliasExpansion(
|
||||||
c: TypeResolutionContext,
|
|
||||||
type: KotlinType,
|
type: KotlinType,
|
||||||
substitutedArguments: List<TypeProjection>,
|
substitutedArguments: List<TypeProjection>,
|
||||||
typeAliasExpansion: TypeAliasExpansion
|
reportStrategy: TypeAliasExpansionReportStrategy
|
||||||
) {
|
) {
|
||||||
val typeSubstitutor = TypeSubstitutor.create(type)
|
val typeSubstitutor = TypeSubstitutor.create(type)
|
||||||
|
|
||||||
substitutedArguments.forEachIndexed { i, substitutedArgument ->
|
substitutedArguments.forEachIndexed { i, substitutedArgument ->
|
||||||
val typeParameter = type.constructor.parameters[i]
|
val typeParameter = type.constructor.parameters[i]
|
||||||
DescriptorResolver.checkBoundsInTypeAlias(typeAliasExpansion.context.element, substitutedArgument.type, typeParameter, typeSubstitutor, c.trace)
|
DescriptorResolver.checkBoundsInTypeAlias(reportStrategy, substitutedArgument.type, typeParameter, typeSubstitutor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -17,10 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||||
|
|
||||||
import com.google.common.collect.Sets
|
import com.google.common.collect.Sets
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
|||||||
@@ -47,6 +47,14 @@ fun <T : TypeCapability> TypeCapabilities.addCapability(clazz: Class<T>, typeCap
|
|||||||
return CompositeTypeCapabilities(this, newCapabilities)
|
return CompositeTypeCapabilities(this, newCapabilities)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T : TypeCapability> TypeCapabilities.overrideCapability(clazz: Class<T>, typeCapability: T): TypeCapabilities {
|
||||||
|
if (getCapability(clazz) === typeCapability) return this
|
||||||
|
val newCapabilities = SingletonTypeCapabilities(clazz, typeCapability)
|
||||||
|
if (this === org.jetbrains.kotlin.types.TypeCapabilities.NONE) return newCapabilities
|
||||||
|
|
||||||
|
return CompositeTypeCapabilities(newCapabilities, this)
|
||||||
|
}
|
||||||
|
|
||||||
inline fun <reified T : TypeCapability> KotlinType.getCapability(): T? = getCapability(T::class.java)
|
inline fun <reified T : TypeCapability> KotlinType.getCapability(): T? = getCapability(T::class.java)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user