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
@@ -11,4 +11,11 @@ class D
fun test1(a: A, b: B, c: C) {
assertEquals1(a, b)
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>assertEquals1<!>(b, c)
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
public fun <@kotlin.internal.OnlyInputTypes T> expect1(expected: T, block: () -> T) {}
fun test() {
expect1(2) { byteArrayOf(1, 2, 3).indexOf(3) }
}
@@ -1,6 +1,8 @@
package
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ T> assertEquals1(/*0*/ t1: T, /*1*/ t2: T): kotlin.Unit
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ T> expect1(/*0*/ expected: T, /*1*/ block: () -> T): kotlin.Unit
public fun test(): kotlin.Unit
public fun test1(/*0*/ a: A, /*1*/ b: B, /*2*/ c: C): kotlin.Unit
public open class A {
@@ -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) {