Skip to content

[AST] Allow the computation of an extensions type for unresolved type aliases #15625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/AST/DeclContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,14 @@ static Type computeExtensionType(const ExtensionDecl *ED, DeclTypeKind kind) {
return type->getAnyNominal()->getDeclaredType();
case DeclTypeKind::DeclaredTypeInContext:
return type;
case DeclTypeKind::DeclaredInterfaceType:
case DeclTypeKind::DeclaredInterfaceType: {
// FIXME: Need a sugar-preserving getExtendedInterfaceType for extensions
return type->getAnyNominal()->getDeclaredInterfaceType();
if (auto nominal = type->getAnyNominal())
return nominal->getDeclaredInterfaceType();

auto typealias = cast<TypeAliasDecl>(type->getAnyGeneric());
return typealias->getUnderlyingTypeLoc().getType();
}
}

llvm_unreachable("Unhandled DeclTypeKind in switch.");
Expand Down
6 changes: 6 additions & 0 deletions test/Compatibility/stdlib_generic_typealiases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ extension DictionaryIndex {
_ = RequiresHashable<Key>()
}
}

extension CountableRange where Element == Int {
// expected-warning@-1{{'CountableRange' is deprecated: renamed to 'Range'}}
// expected-note@-2{{use 'Range' instead}}
func getLowerBoundAsInt() -> Int { return lowerBound }
}