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
This commit is contained in:
Doug Gregor
2013-12-04 22:32:28 +00:00
parent 78330bef87
commit 3d4da69b08
6 changed files with 195 additions and 10 deletions

View File

@@ -54,6 +54,7 @@ gatherReferencedTypeVarsRec(ConstraintSystem &cs,
case ConstraintKind::Bind:
case ConstraintKind::Construction:
case ConstraintKind::Conversion:
case ConstraintKind::CheckedCast:
case ConstraintKind::Equal:
case ConstraintKind::Subtype:
case ConstraintKind::TrivialSubtype: