Skip to content

Commit 8f97511

Browse files
committed
Sema: Use TypeResolution::forInterface() to resolve type alias underlying types
1 parent 4ef1904 commit 8f97511

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ static NominalTypeDecl *resolveSingleNominalTypeDecl(
20572057

20582058
TypeResolutionOptions options = TypeResolverContext::TypeAliasDecl;
20592059
options |= flags;
2060-
if (tc.validateType(typeLoc, TypeResolution::forContextual(DC), options))
2060+
if (tc.validateType(typeLoc, TypeResolution::forInterface(DC), options))
20612061
return nullptr;
20622062

20632063
return typeLoc.getType()->getAnyNominal();
@@ -3469,7 +3469,7 @@ static void validateTypealiasType(TypeChecker &tc, TypeAliasDecl *typeAlias) {
34693469
}
34703470

34713471
if (tc.validateType(typeAlias->getUnderlyingTypeLoc(),
3472-
TypeResolution::forContextual(typeAlias), options)) {
3472+
TypeResolution::forInterface(typeAlias), options)) {
34733473
typeAlias->setInvalid();
34743474
typeAlias->getUnderlyingTypeLoc().setInvalidType(tc.Context);
34753475
}

test/decl/typealias/protocol.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,18 @@ protocol P3 {
144144

145145
// Test for not crashing on recursive aliases
146146
protocol Circular {
147-
typealias Y = Self.Y // expected-error {{type alias 'Y' is not a member type of 'Self'}}
147+
typealias Y = Self.Y // expected-error {{'Y' is not a member type of 'Self'}}
148+
// expected-note@-1 {{did you mean 'Y'?}}
148149

149150
typealias Y2 = Y2 // expected-error {{type alias 'Y2' references itself}}
150151
// expected-note@-1 {{type declared here}}
152+
// expected-note@-2 {{did you mean 'Y2'?}}
151153

152154
typealias Y3 = Y4 // expected-note {{type declared here}}
155+
// expected-note@-1 {{did you mean 'Y3'?}}
156+
153157
typealias Y4 = Y3 // expected-error {{type alias 'Y3' references itself}}
158+
// expected-note@-1 {{did you mean 'Y4'?}}
154159
}
155160

156161
// Qualified and unqualified references to protocol typealiases from concrete type

0 commit comments

Comments
 (0)