mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ConstraintSystem] Fix regression in partial application of initializers
Correct a regression related to use of partially applied initializers, which should be rejected only if it happens in a delegation chain. Resolves: [SR-10837](https://bugs.swift.org/browse/SR-10837) Resolves: rdar://problem/51442825
This commit is contained in:
@@ -1734,11 +1734,15 @@ isInvalidPartialApplication(ConstraintSystem &cs, const ValueDecl *member,
|
||||
auto baseTy =
|
||||
cs.simplifyType(cs.getType(anchor->getBase()))->getWithoutSpecifierType();
|
||||
|
||||
// Partial applications are not allowed only for constructor
|
||||
// delegation, reference on the metatype is considered acceptable.
|
||||
if (baseTy->is<MetatypeType>() && isa<ConstructorDecl>(member))
|
||||
return {false, 0};
|
||||
|
||||
// If base is a metatype it would be ignored (unless this is an initializer
|
||||
// call), but if it is some other type it means that we have a single
|
||||
// application level already.
|
||||
unsigned level =
|
||||
baseTy->is<MetatypeType>() && !isa<ConstructorDecl>(member) ? 0 : 1;
|
||||
unsigned level = baseTy->is<MetatypeType>() ? 0 : 1;
|
||||
if (auto *call = dyn_cast_or_null<CallExpr>(cs.getParentExpr(anchor))) {
|
||||
level += dyn_cast_or_null<CallExpr>(cs.getParentExpr(call)) ? 2 : 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user