[ConstraintSystem] Look through specialization while simplifying constructor locator

If type is explicitly specialized i.e. `A<Int>` in certain cases its `TypeExpr`
or `OverloadedDeclRefExpr` (if type name is ambiguous) would be wrapped in
`UnresolvedSpecializeExpr` which has to be looked through when simplifying
`constructor member` so the anchor could point to the underlying type reference.

Resolves: https://github.com/apple/swift/issues/67799
Resolves: rdar://113577294
This commit is contained in:
Pavel Yaskevich
2023-08-28 11:21:58 -07:00
parent fc8da01c05
commit e00034e056
2 changed files with 55 additions and 0 deletions

View File

@@ -5724,6 +5724,13 @@ void constraints::simplifyLocator(ASTNode &anchor,
}
case ConstraintLocator::ConstructorMember:
// Look through specialization first, because it doesn't play a
// functional role here.
if (auto *USE = getAsExpr<UnresolvedSpecializeExpr>(anchor)) {
anchor = USE->getSubExpr();
range = anchor.getSourceRange();
}
// - This is really an implicit 'init' MemberRef, so point at the base,
// i.e. the TypeExpr.
// - For re-declarations we'd get an overloaded reference