Skip to content

Commit 7c6877c

Browse files
committed
Sema: Fix oversight in resolveTypeInContext()
When looking up a generic parameter inside a nominal type context, we would go down the most general substitution-based code path, usually meant for typealiases, instead of calling the much simpler resolveGenericTypeParamType(). Amazingly, everything still worked.
1 parent 00700c1 commit 7c6877c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,14 @@ Type TypeChecker::resolveTypeInContext(
394394

395395
bool hasDependentType = typeDecl->getDeclaredInterfaceType()
396396
->hasTypeParameter();
397+
// If we found a generic parameter, map to the archetype if there is one.
398+
if (auto genericParam = dyn_cast<GenericTypeParamDecl>(typeDecl)) {
399+
return resolver->resolveGenericTypeParamType(
400+
genericParam->getDeclaredInterfaceType()
401+
->castTo<GenericTypeParamType>());
402+
}
397403

398404
if (!foundNominal || !hasDependentType) {
399-
// If we found a generic parameter, map to the archetype if there is one.
400-
if (auto genericParam = dyn_cast<GenericTypeParamDecl>(typeDecl)) {
401-
return resolver->resolveGenericTypeParamType(
402-
genericParam->getDeclaredInterfaceType()
403-
->castTo<GenericTypeParamType>());
404-
}
405-
406405
// If this is a typealias not in type context, we still need the
407406
// interface type; the typealias might be in a function context, and
408407
// its underlying type might reference outer generic parameters.

0 commit comments

Comments
 (0)