Commits
Doug Gregor committed c946eccb087
Collect all of the constraints that relate directly to a type
variable T, e.g., T < Int or T << Int. Use this information to
eliminate redundant constraints, such as "T << Int" in the above
example (since subtyping is a stronger constraint than
convertibility).
Today's fun little constraint system:
func f<T>(x : T, fn : (T) -> T) {}
var i : Int
var fnii : (Int) -> Int
:dump_constraints f(i, fnii)
---Initial constraints for the given expression---
(call_expr type='<null>'
(declref_expr type='<T> (x : T, fn : (T) -> T) -> ()' decl=f)
(tuple_expr type='<null>'
(declref_expr type='[byref(heap)] Int' decl=i)
(declref_expr type='[byref(heap)] (Int) -> Int' decl=fnii)))
Type Variables:
$T0
$T1
$T2
Constraints:
(x : $T0, fn : ($T0) -> $T0) -> () == $T1 -> $T2
([byref(heap)] Int, [byref(heap)] (Int) -> Int) << $T1
---Simplified constraints---
Type Variables:
$T0
$T1 as (x : $T0, fn : $T0 -> $T0)
$T2 as ()
Constraints:
$T0 < Int64
Int64 < $T0
Constraint system is still viable
Swift SVN r2654