mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make DynamicSelf into its own special type node.
Making DynamicSelf its own special type node makes it easier to opt-in to the behavior we want rather than opting out of the behavior we don't want. Some things already work better with this representation, such as mangling and overriding; others are more broken, such as the handling of DynamicSelf within generic classes and the lookup of the DynamicSelf type. Swift SVN r13141
This commit is contained in:
@@ -918,6 +918,18 @@ ConstraintSystem::getTypeOfMemberReference(Type baseTy, ValueDecl *value,
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a method whose result type is DynamicSelf, replace
|
||||
// DynamicSelf with the actual object type.
|
||||
if (auto func = dyn_cast<FuncDecl>(value)) {
|
||||
if (func->hasDynamicSelf()) {
|
||||
openedType = openedType.transform([&](Type type) {
|
||||
if (type->is<DynamicSelfType>())
|
||||
return baseObjTy;
|
||||
return type;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Constrain the 'self' object type.
|
||||
auto openedFnType = openedType->castTo<FunctionType>();
|
||||
Type selfObjTy = openedFnType->getInput()->getRValueInstanceType();
|
||||
|
||||
Reference in New Issue
Block a user