mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #15294 from slavapestov/init-name-lookup-fix
AST: Fix for name lookup not finding initializers in protocols
This commit is contained in:
@@ -2474,19 +2474,6 @@ ConstraintSystem::simplifyConstructionConstraint(
|
||||
return SolutionKind::Error;
|
||||
}
|
||||
|
||||
NameLookupOptions lookupOptions = defaultConstructorLookupOptions;
|
||||
if (isa<AbstractFunctionDecl>(useDC))
|
||||
lookupOptions |= NameLookupFlags::KnownPrivate;
|
||||
|
||||
auto instanceType = valueType;
|
||||
if (auto *selfType = instanceType->getAs<DynamicSelfType>())
|
||||
instanceType = selfType->getSelfType();
|
||||
|
||||
auto ctors = TC.lookupConstructors(useDC, instanceType, lookupOptions);
|
||||
if (!ctors)
|
||||
return SolutionKind::Error;
|
||||
|
||||
auto name = DeclBaseName::createConstructor();
|
||||
auto applyLocator = getConstraintLocator(locator,
|
||||
ConstraintLocator::ApplyArgument);
|
||||
auto fnLocator = getConstraintLocator(locator,
|
||||
@@ -2499,7 +2486,8 @@ ConstraintSystem::simplifyConstructionConstraint(
|
||||
// The constructor will have function type T -> T2, for a fresh type
|
||||
// variable T. T2 is the result type provided via the construction
|
||||
// constraint itself.
|
||||
addValueMemberConstraint(MetatypeType::get(valueType, TC.Context), name,
|
||||
addValueMemberConstraint(MetatypeType::get(valueType, TC.Context),
|
||||
DeclBaseName::createConstructor(),
|
||||
FunctionType::get(tv, resultType),
|
||||
useDC, functionRefKind,
|
||||
getConstraintLocator(
|
||||
|
||||
Reference in New Issue
Block a user