Commit Graph

6 Commits

Author SHA1 Message Date
Doug Gregor
3d4da69b08 In "x as T", type-check the subexpression "x" using "T" as the context type.
Using "T" as the contextual type, either for an implicit conversion
(in the coercion case) or as a downcast (for the checked-cast case),
opens up more type-inference opportunities. Most importantly, it
allows coercions such as "1 as UInt32" (important for
<rdar://problem/15283100>). Additionally, it allows one to omit
generic arguments within the type we're casting to.

Some additional cleanup to follow.


Swift SVN r10799
2013-12-04 22:32:28 +00:00
Doug Gregor
d52887c9bb Constraint graph WIP: collapse two nodes into a single node.
This currently-untestable code allows updates to the constraint graph
when a same-type constraint causes two type variables to be
unified. Additionally, it handles the removal of a constraint from the
constraint system, e.g., if it is solved.


Swift SVN r10716
2013-12-01 16:42:33 +00:00
Doug Gregor
8cd63c9b8d Use the constraint graph to isolate and solve the smallest connected component.
At each solution phase, construct a constraint graph and identify the
smallest connected component. Only solve for the variables in that
connected component, and restrict simplification to the constraints
within that connected component. This reduces the number of
visited-but-not-simplified constraints by ~2x when type-checking the
standard library.

Performance-wise, this is actually a regression (0.25s/8% when parsing
the standard library), because the time spent building the constraint
graph exceeds the time saved by the optimization above.

The hackaround in the standard library is due to
<rdar://problem/15168483>. Essentially, this commit changes the order
in which we visit type variables, causing the type checker to make
some very poor deduction choices.

The point of actually committing this is that it validates the
constraint graph construction and sets the stage for an actual
optimization based on isolating the solving work for the different
components.



Swift SVN r10672
2013-11-23 03:44:40 +00:00
Doug Gregor
5d9b955369 Overload-binding constraints can have base types; add those adjacencies.
Swift SVN r10665
2013-11-22 22:11:52 +00:00
Doug Gregor
e28c425a64 Compute connected components for the constraint graph.
This implements an offline algorithm for connected components. We
could use an online algorithm, which would be slightly more efficient
in the case where we always require the connected components, but such
algorithms don't cope with edge removals very well.

Still just a debugging tool!



Swift SVN r10663
2013-11-22 19:21:43 +00:00
Doug Gregor
ccf01377cc Introduce a constraint graph to track relationships among type variables.
We're not using this for anything other than debugging at the moment.


Swift SVN r10661
2013-11-22 18:25:14 +00:00