Fixed the problem with 'OnlyInputTypes' annotation

This commit is contained in:
Svetlana Isakova
2015-10-19 17:38:12 +03:00
parent 3476bed18a
commit 6ced795db6
4 changed files with 16 additions and 7 deletions
@@ -84,13 +84,14 @@ public class ConstraintSystemImpl : ConstraintSystem {
override fun hasContradiction() = hasParameterConstraintError() || hasConflictingConstraints()
|| hasCannotCaptureTypesError() || hasTypeInferenceIncorporationError()
|| hasTypeParameterWithUnsatisfiedOnlyInputTypesError()
override fun hasViolatedUpperBound() = !isSuccessful() && filterConstraintsOut(TYPE_BOUND_POSITION).getStatus().isSuccessful()
override fun hasConflictingConstraints() = localTypeParameterBounds.values().any { it.values.size() > 1 }
override fun hasUnknownParameters() = localTypeParameterBounds.values().any { it.values.isEmpty() }
override fun hasUnknownParameters() =
localTypeParameterBounds.values().any { it.values.isEmpty() } || hasTypeParameterWithUnsatisfiedOnlyInputTypesError()
override fun hasParameterConstraintError() = errors.any { it is ParameterConstraintError }
@@ -36,10 +36,6 @@ public class TypeBoundsImpl(
) : TypeBounds {
override val bounds = ArrayList<Bound>()
private val typesInBoundsSet: Set<JetType> by lazy {
bounds.filter { it.isProper }.map { it.constrainingType }.toSet()
}
private var resultValues: Collection<JetType>? = null
var isFixed: Boolean = false
@@ -157,7 +153,10 @@ public class TypeBoundsImpl(
// a captured type might be an answer
if (!possibleAnswer.getConstructor().isDenotable() && !possibleAnswer.isCaptured()) return false
if (typeVariable.hasOnlyInputTypesAnnotation() && !typesInBoundsSet.contains(possibleAnswer)) return false
if (typeVariable.hasOnlyInputTypesAnnotation()) {
val typesInBoundsSet = bounds.filter { it.isProper && it.constrainingType.constructor.isDenotable }.map { it.constrainingType }.toSet()
if (!typesInBoundsSet.contains(possibleAnswer)) return false
}
for (bound in bounds) {
when (bound.kind) {