Removed check for position when storing initial top-level constraints
This commit is contained in:
Vendored
+1
-1
@@ -25,7 +25,7 @@ interface WithFoo {
|
|||||||
fun foo()
|
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 descriptorByModule = MyMap<M2, String>()
|
||||||
val result = ResolverForProjectImpl(descriptorByModule, delegateResolver)
|
val result = ResolverForProjectImpl(descriptorByModule, delegateResolver)
|
||||||
result.exposeM.foo() // M is not M2?
|
result.exposeM.foo() // M is not M2?
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package
|
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*/ open class MyMap</*0*/ K, /*1*/ V> : java.util.AbstractMap<K!, V!> {
|
||||||
public/*package*/ constructor MyMap</*0*/ K, /*1*/ V>()
|
public/*package*/ constructor MyMap</*0*/ K, /*1*/ V>()
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() {
|
|||||||
when (constraint.kind) {
|
when (constraint.kind) {
|
||||||
MyConstraintKind.SUBTYPE -> constraintSystem.addSubtypeConstraint(firstType, secondType, position)
|
MyConstraintKind.SUBTYPE -> constraintSystem.addSubtypeConstraint(firstType, secondType, position)
|
||||||
MyConstraintKind.SUPERTYPE -> constraintSystem.addSupertypeConstraint(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()
|
if (fixVariables) constraintSystem.fixVariables()
|
||||||
|
|||||||
+10
-5
@@ -203,15 +203,21 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
|||||||
if (constrainingType != null && TypeUtils.noExpectedType(constrainingType)) return
|
if (constrainingType != null && TypeUtils.noExpectedType(constrainingType)) return
|
||||||
|
|
||||||
val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT)
|
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) {
|
override fun addSubtypeConstraint(constrainingType: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition) {
|
||||||
val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT)
|
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 {
|
val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks {
|
||||||
private var depth = 0
|
private var depth = 0
|
||||||
|
|
||||||
@@ -253,7 +259,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
|||||||
return true
|
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 {
|
private fun isErrorOrSpecialType(type: JetType?, constraintPosition: ConstraintPosition): Boolean {
|
||||||
@@ -447,7 +453,6 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
|||||||
replaceUninferredBy(getDefaultValue, substituteOriginal).setApproximateCapturedTypes()
|
replaceUninferredBy(getDefaultValue, substituteOriginal).setApproximateCapturedTypes()
|
||||||
|
|
||||||
private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: JetType, superType: JetType, position: ConstraintPosition) {
|
private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: JetType, superType: JetType, position: ConstraintPosition) {
|
||||||
if (position is CompoundConstraintPosition) return
|
|
||||||
initialConstraints.add(Constraint(constraintKind, subType, superType, position))
|
initialConstraints.add(Constraint(constraintKind, subType, superType, position))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -64,9 +64,9 @@ private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound)
|
|||||||
val position = CompoundConstraintPosition(old.position, new.position)
|
val position = CompoundConstraintPosition(old.position, new.position)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
old.kind.ordinal() < new.kind.ordinal() -> addConstraint(SUB_TYPE, 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)
|
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)
|
old.kind == new.kind && old.kind == EXACT_BOUND -> addConstraint(EQUAL, oldType, newType, position, topLevel = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user