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:
Slava Pestov
2018-03-16 22:19:10 -07:00
committed by GitHub
4 changed files with 23 additions and 17 deletions

View File

@@ -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(