Report warnings by enhanced base types

This commit is contained in:
Victor Petukhov
2021-05-13 13:02:26 +03:00
parent 2239404085
commit b78c645fb0
12 changed files with 76 additions and 37 deletions
@@ -215,10 +215,7 @@ class LazyJavaClassDescriptor(
for (javaType in javaTypes) {
val kotlinType = c.typeResolver.transformJavaType(javaType, TypeUsage.SUPERTYPE.toAttributes())
val areImprovementsInStrictMode = c.components.settings.typeEnhancementImprovementsInStrictMode
val enhancedKotlinType = if (areImprovementsInStrictMode) {
c.components.signatureEnhancement.enhanceSuperType(kotlinType, c)
} else kotlinType
val enhancedKotlinType = c.components.signatureEnhancement.enhanceSuperType(kotlinType, c)
if (enhancedKotlinType.constructor.declarationDescriptor is NotFoundClasses.MockClassDescriptor) {
incomplete.add(javaType)
@@ -188,7 +188,10 @@ public class TypeSubstitutor implements TypeSubstitutorMarker {
);
KotlinType substitutedEnhancement = substitute(enhancement, originalProjection.getProjectionKind());
KotlinType resultingType = TypeWithEnhancementKt.wrapEnhancement(substitution.getType().unwrap(), substitutedEnhancement);
KotlinType resultingType = TypeWithEnhancementKt.wrapEnhancement(
substitution.getType().unwrap(),
substitutedEnhancement instanceof TypeWithEnhancement ? ((TypeWithEnhancement) substitutedEnhancement).getEnhancement() : substitutedEnhancement
);
return new TypeProjectionImpl(substitution.getProjectionKind(), resultingType);
}
@@ -77,11 +77,14 @@ class NewKotlinTypeCheckerImpl(
override val overridingUtil: OverridingUtil = OverridingUtil.createWithTypeRefiner(kotlinTypeRefiner)
override fun isSubtypeOf(subtype: KotlinType, supertype: KotlinType): Boolean =
ClassicTypeCheckerContext(true, kotlinTypeRefiner = kotlinTypeRefiner)
.isSubtypeOf(subtype.unwrap(), supertype.unwrap()) // todo fix flag errorTypeEqualsToAnything
ClassicTypeCheckerContext(
true, kotlinTypeRefiner = kotlinTypeRefiner, kotlinTypePreparator = kotlinTypePreparator
).isSubtypeOf(subtype.unwrap(), supertype.unwrap()) // todo fix flag errorTypeEqualsToAnything
override fun equalTypes(a: KotlinType, b: KotlinType): Boolean =
ClassicTypeCheckerContext(false, kotlinTypeRefiner = kotlinTypeRefiner).equalTypes(a.unwrap(), b.unwrap())
ClassicTypeCheckerContext(
false, kotlinTypeRefiner = kotlinTypeRefiner, kotlinTypePreparator = kotlinTypePreparator
).equalTypes(a.unwrap(), b.unwrap())
fun ClassicTypeCheckerContext.equalTypes(a: UnwrappedType, b: UnwrappedType): Boolean {
return AbstractTypeChecker.equalTypes(this as AbstractTypeCheckerContext, a, b)