Adjust type approximation to broken code and missing dependencies

- Do not run approximation if arguments number is different
- Add nullable Any? as supertype to MissingDependencyErrorClass

The latter is needed because otherwise TypeArgument.isConsistent became false
This commit is contained in:
Denis Zharkov
2015-12-23 20:00:53 +03:00
parent 722a152a74
commit 688a1b6305
2 changed files with 6 additions and 2 deletions
@@ -117,7 +117,7 @@ public fun approximateCapturedTypes(type: KotlinType): ApproximationBounds<Kotli
else -> throw AssertionError("Only nontrivial projections should have been captured, not: $typeProjection")
}
}
if (type.arguments.isEmpty()) {
if (type.arguments.isEmpty() || type.arguments.size != typeConstructor.parameters.size) {
return ApproximationBounds(type, type)
}
val lowerBoundArguments = ArrayList<TypeArgument>()
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
import org.jetbrains.kotlin.types.ErrorUtils.createErrorType
@@ -63,7 +64,10 @@ internal class PackageFragmentProviderForMissingDependencies(val moduleDescripto
private class MissingDependencyErrorClassDescriptor(
containing: DeclarationDescriptor,
override val fullFqName: FqName
) : MissingDependencyErrorClass, ClassDescriptorImpl(containing, fullFqName.shortName(), Modality.OPEN, ClassKind.CLASS, listOf(), SourceElement.NO_SOURCE) {
) : MissingDependencyErrorClass, ClassDescriptorImpl(
containing, fullFqName.shortName(), Modality.OPEN, ClassKind.CLASS, listOf(containing.builtIns.nullableAnyType),
SourceElement.NO_SOURCE
) {
private val scope = ScopeWithMissingDependencies(fullFqName, this)