mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[TypeChecker] Extend type inference from default expressions to handle nested generic parameters
Adds support for parameter types like `[T?]` or `[(T, U?)]`, and relaxes restriction on same-type generic parameters. A same-type requirement is acceptable if it only includes in-scope generic parameters and concrete types i.e. `T.X == Int` if accepted if `T` is referenced only by a parameter default expression is being applied to.
This commit is contained in:
@@ -1632,13 +1632,13 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
|
||||
if (parameterBindings[paramIdx].empty()) {
|
||||
auto &ctx = cs.getASTContext();
|
||||
|
||||
if (paramTy->isTypeVariableOrMember() &&
|
||||
if (paramTy->hasTypeVariable() &&
|
||||
ctx.TypeCheckerOpts.EnableTypeInferenceFromDefaultArguments) {
|
||||
auto *paramList = getParameterList(callee);
|
||||
auto defaultExprType = paramList->get(paramIdx)->getTypeOfDefaultExpr();
|
||||
|
||||
// A caller side default.
|
||||
if (!defaultExprType)
|
||||
if (!defaultExprType || defaultExprType->hasError())
|
||||
continue;
|
||||
|
||||
// If this is just a regular default type that works
|
||||
|
||||
Reference in New Issue
Block a user