Introduce very basic support for selector-style initializations.

The type checker changes here are a complete hack; I'll be revisiting
this shortly. Addresses the rest of <rdar://problem/16031332>.


Swift SVN r13858
This commit is contained in:
Doug Gregor
2014-02-13 04:15:55 +00:00
parent 1bbbcaaf98
commit 71f9438dd0
3 changed files with 27 additions and 6 deletions

View File

@@ -253,7 +253,13 @@ namespace {
ASTContext &C = CS.getASTContext();
// Open a member constraint for constructors on the subexpr type.
auto baseTy = expr->getSubExpr()->getType()->getRValueType();
// FIXME: the getRValueInstanceType() here is a hack to make the
// T.init withFoo(foo)
// syntax type-check. We shouldn't rely on any kinds of adjustments to
// the subexpression's type here, but dealing with this requires us to
// clarify when we can refer to constructors with ".init".
auto baseTy = expr->getSubExpr()->getType()
->getLValueOrInOutObjectType()->getRValueInstanceType();
auto argsTy = CS.createTypeVariable(
CS.getConstraintLocator(expr),
TVO_CanBindToLValue|TVO_PrefersSubtypeBinding);