Commits
Doug Gregor committed 43578522977
Introduce two new kinds of constraints: value members and type
members. Both constraints have the form "T1 is a type with a member
named N, such that a reference to N in T1 has type T2". Value member
constraints reference N in an expression contents, based on a value of
type T1, while type member constraints can only refer to types (duh)
and return the declared type of the entity (rather than the type of
its value). Type member constraints are currently used in a moderately
hacky way for nested types of archetypes.
We build and simplify the given session nicely now:
struct X {
func f(_ : Float) -> Int {}
}
var x : X
var f : Float
:dump_constraints x.f(f)
which comes out to
---Initial constraints for the given expression---
(call_expr type='$T2'
(unresolved_dot_expr type='$T0' field 'f'
(declref_expr type='[byref(heap)] X' decl=x))
(paren_expr type='[byref(heap)] Float'
(declref_expr type='[byref(heap)] Float' decl=f)))
---Type Variables---
$T0
$T1
$T2
---Constraints---
[byref(heap)] X[.f: value] == $T0
$T0 == $T1 -> $T2
[byref(heap)] Float << $T1
which simplifies down to no constraints (w/ all type variables bound),
as it should:
---Simplified constraints---
---Type Variables---
$T0 as $T1 -> $T2
$T1 as Float
$T2 as Int64
Swift SVN r2643