[Diagnostics] Diagnose key path reference to initializer methods.

This commit is contained in:
Luciano Almeida
2020-03-28 16:32:08 -03:00
parent 4981da4a4d
commit faba29a55f
4 changed files with 19 additions and 3 deletions

View File

@@ -6305,6 +6305,9 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
// which means MetatypeType has to be added after finding a type variable.
if (locatorEndsWith(baseLocator, ConstraintLocator::MemberRefBase))
baseType = MetatypeType::get(baseType);
} else if (auto *keyPathExpr = dyn_cast<KeyPathExpr>(anchor)) {
// Key path can't refer to initializers e.g. `\Type.init`
return AllowInvalidRefInKeyPath::forRef(cs, init, locator);
}
if (!baseType)