Inherit complete object initializers when a class supports it.

Teach name lookup to find complete object initializers in its
superclass when the current class overrides all of the subobject
initializers of its direct superclass.

Clean up the implicit declaration of constructors, so we don't rely on
callers in the type checker doing the right thing.

When we refer to a constructor within the type checker, always use the
type through which the constructor was found as the result of
construction, so that we can type-check uses of inherited complete
object initializers. Fixed a problem with the creation of
OpenExistentialExprs when the base object is a metatype.

The changes to the code completion tests are an improvement: we're
generating ExprSpecific completion results when referring to the
superclass initializer with the same signature as the initializer
we're in after "super.".

Swift SVN r14551
This commit is contained in:
Doug Gregor
2014-03-01 00:51:21 +00:00
parent e4444e36cb
commit d92f1a3158
11 changed files with 180 additions and 46 deletions

View File

@@ -962,12 +962,8 @@ ConstraintSystem::getTypeOfMemberReference(Type baseTy, ValueDecl *value,
});
}
}
// Alternatively, if this is a constructor referenced from a DynamicSelf base
// object, or a constructor within a protocol, replace the result type with
// the base object type.
else if (isa<ConstructorDecl>(value) &&
(baseObjTy->is<DynamicSelfType>() ||
isa<ProtocolDecl>(value->getDeclContext()))) {
// If this is a construct, replace the result type with the base object type.
else if (isa<ConstructorDecl>(value)) {
auto outerFnType = openedType->castTo<FunctionType>();
auto innerFnType = outerFnType->getResult()->castTo<FunctionType>();