mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Expr context type analysis for failed array literal expr
let _: [Foo] = [ .create(str: Int) .create(#^COMPLETE^#) ] Previously, this completion used to fail because the array expression isn't typechecked. We need to analyze the context type of the array literal first, that defines the type of the unresolved member expression. rdar://problem/50696432
This commit is contained in:
@@ -583,6 +583,15 @@ class ExprContextAnalyzer {
|
||||
case ExprKind::Array: {
|
||||
if (auto type = ParsedExpr->getType()) {
|
||||
recordPossibleType(type);
|
||||
break;
|
||||
}
|
||||
|
||||
// Check context types of the array literal expression.
|
||||
ExprContextInfo arrayCtxtInfo(DC, Parent);
|
||||
for (auto arrayT : arrayCtxtInfo.getPossibleTypes()) {
|
||||
if (auto boundGenericT = arrayT->getAs<BoundGenericType>())
|
||||
if (boundGenericT->getDecl() == Context.getArrayDecl())
|
||||
recordPossibleType(boundGenericT->getGenericArgs()[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user