Skip to content

Commit aef9f8f

Browse files
committed
AST: Fix DeclContext::getAsTypeOrTypeExtensionContext() for extensions of typealiases
1 parent 3e8e3fb commit aef9f8f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

lib/AST/DeclContext.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,10 @@ DeclContext::getAsTypeOrTypeExtensionContext() const {
6161
auto ED = cast<ExtensionDecl>(this);
6262
auto type = ED->getExtendedType();
6363

64-
if (type.isNull() || type->hasError())
64+
if (!type)
6565
return nullptr;
6666

67-
if (auto ND = type->getNominalOrBoundGenericNominal())
68-
return ND;
69-
70-
if (auto unbound = dyn_cast<UnboundGenericType>(type.getPointer())) {
71-
return unbound->getDecl();
72-
}
73-
74-
return nullptr;
67+
return type->getAnyNominal();
7568
}
7669

7770
case DeclContextKind::GenericTypeDecl:

test/decl/ext/generic.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,9 @@ struct S5<Q> {
158158
}
159159

160160
extension S5 : P4 {}
161+
162+
// rdar://problem/21607421
163+
public typealias Array2 = Array
164+
extension Array2 where QQQ : VVV {}
165+
// expected-error@-1 {{use of undeclared type 'QQQ'}}
166+
// expected-error@-2 {{use of undeclared type 'VVV'}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

88
// REQUIRES: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
9+
// RUN: not %target-swift-frontend %s -emit-ir
1010
protocol P}extension P{{}typealias a:P}extension P.a{protocol P

0 commit comments

Comments
 (0)