Removed check for position when storing initial top-level constraints

This commit is contained in:
Svetlana Isakova
2015-07-07 21:46:16 +03:00
parent 425a9516db
commit 016a8f69da
5 changed files with 16 additions and 11 deletions
@@ -25,7 +25,7 @@ interface WithFoo {
fun foo()
}
fun <M2: WithFoo> foo(delegateResolver: ResolverForProject<M2?>): ResolverForProject<M2> {
fun <M2: WithFoo> foo(delegateResolver: ResolverForProject<M2?>): ResolverForProject<M2?> {
val descriptorByModule = MyMap<M2, String>()
val result = ResolverForProjectImpl(descriptorByModule, delegateResolver)
result.exposeM.foo() // M is not M2?
@@ -1,6 +1,6 @@
package
internal fun </*0*/ M2 : WithFoo> foo(/*0*/ delegateResolver: ResolverForProject<M2?>): ResolverForProject<M2>
internal fun </*0*/ M2 : WithFoo> foo(/*0*/ delegateResolver: ResolverForProject<M2?>): ResolverForProject<M2?>
public/*package*/ open class MyMap</*0*/ K, /*1*/ V> : java.util.AbstractMap<K!, V!> {
public/*package*/ constructor MyMap</*0*/ K, /*1*/ V>()
@@ -98,7 +98,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() {
when (constraint.kind) {
MyConstraintKind.SUBTYPE -> constraintSystem.addSubtypeConstraint(firstType, secondType, position)
MyConstraintKind.SUPERTYPE -> constraintSystem.addSupertypeConstraint(firstType, secondType, position)
MyConstraintKind.EQUAL -> constraintSystem.addConstraint(ConstraintSystemImpl.ConstraintKind.EQUAL, firstType, secondType, position)
MyConstraintKind.EQUAL -> constraintSystem.addConstraint(ConstraintSystemImpl.ConstraintKind.EQUAL, firstType, secondType, position, topLevel = true)
}
}
if (fixVariables) constraintSystem.fixVariables()
@@ -203,15 +203,21 @@ public class ConstraintSystemImpl : ConstraintSystem {
if (constrainingType != null && TypeUtils.noExpectedType(constrainingType)) return
val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT)
addConstraint(SUB_TYPE, newSubjectType, constrainingType, constraintPosition)
addConstraint(SUB_TYPE, newSubjectType, constrainingType, constraintPosition, topLevel = true)
}
override fun addSubtypeConstraint(constrainingType: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition) {
val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT)
addConstraint(SUB_TYPE, constrainingType, newSubjectType, constraintPosition)
addConstraint(SUB_TYPE, constrainingType, newSubjectType, constraintPosition, topLevel = true)
}
fun addConstraint(constraintKind: ConstraintKind, subType: JetType?, superType: JetType?, constraintPosition: ConstraintPosition) {
fun addConstraint(
constraintKind: ConstraintKind,
subType: JetType?,
superType: JetType?,
constraintPosition: ConstraintPosition,
topLevel: Boolean
) {
val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks {
private var depth = 0
@@ -253,7 +259,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
return true
}
})
doAddConstraint(constraintKind, subType, superType, constraintPosition, typeCheckingProcedure, topLevel = true)
doAddConstraint(constraintKind, subType, superType, constraintPosition, typeCheckingProcedure, topLevel)
}
private fun isErrorOrSpecialType(type: JetType?, constraintPosition: ConstraintPosition): Boolean {
@@ -447,7 +453,6 @@ public class ConstraintSystemImpl : ConstraintSystem {
replaceUninferredBy(getDefaultValue, substituteOriginal).setApproximateCapturedTypes()
private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: JetType, superType: JetType, position: ConstraintPosition) {
if (position is CompoundConstraintPosition) return
initialConstraints.add(Constraint(constraintKind, subType, superType, position))
}
@@ -64,9 +64,9 @@ private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound)
val position = CompoundConstraintPosition(old.position, new.position)
when {
old.kind.ordinal() < new.kind.ordinal() -> addConstraint(SUB_TYPE, oldType, newType, position)
old.kind.ordinal() > new.kind.ordinal() -> addConstraint(SUB_TYPE, newType, oldType, position)
old.kind == new.kind && old.kind == EXACT_BOUND -> addConstraint(EQUAL, oldType, newType, position)
old.kind.ordinal() < new.kind.ordinal() -> addConstraint(SUB_TYPE, oldType, newType, position, topLevel = false)
old.kind.ordinal() > new.kind.ordinal() -> addConstraint(SUB_TYPE, newType, oldType, position, topLevel = false)
old.kind == new.kind && old.kind == EXACT_BOUND -> addConstraint(EQUAL, oldType, newType, position, topLevel = false)
}
}