@@ -8861,17 +8861,14 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
8861
8861
if (!anchor)
8862
8862
return nullptr;
8863
8863
8864
+ // Avoid checking implicit conversions injected by the compiler.
8865
+ if (locator->findFirst<LocatorPathElt::ImplicitConversion>())
8866
+ return nullptr;
8867
+
8864
8868
auto getType = [&cs](Expr *expr) -> Type {
8865
8869
return cs.simplifyType(cs.getType(expr))->getRValueType();
8866
8870
};
8867
8871
8868
- auto locatorEndsWith =
8869
- [](ConstraintLocator *locator,
8870
- ConstraintLocator::PathElementKind eltKind) -> bool {
8871
- auto path = locator->getPath();
8872
- return !path.empty() && path.back().getKind() == eltKind;
8873
- };
8874
-
8875
8872
Expr *baseExpr = nullptr;
8876
8873
Type baseType;
8877
8874
@@ -8928,7 +8925,7 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
8928
8925
// member.
8929
8926
// We need to find type variable which represents contextual base.
8930
8927
auto *baseLocator = cs.getConstraintLocator(
8931
- UME, locatorEndsWith( locator, ConstraintLocator ::ConstructorMember)
8928
+ UME, locator->isLastElement<LocatorPathElt ::ConstructorMember>( )
8932
8929
? ConstraintLocator::UnresolvedMember
8933
8930
: ConstraintLocator::MemberRefBase);
8934
8931
@@ -8943,7 +8940,7 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
8943
8940
baseType = cs.simplifyType(*result)->getRValueType();
8944
8941
// Constraint for member base is formed as '$T.Type[.<member] = ...`
8945
8942
// which means MetatypeType has to be added after finding a type variable.
8946
- if (locatorEndsWith( baseLocator, ConstraintLocator ::MemberRefBase))
8943
+ if (baseLocator->isLastElement<LocatorPathElt ::MemberRefBase>( ))
8947
8944
baseType = MetatypeType::get(baseType);
8948
8945
} else if (auto *keyPathExpr = getAsExpr<KeyPathExpr>(anchor)) {
8949
8946
// Key path can't refer to initializers e.g. `\Type.init`
0 commit comments