Skip to content

Commit d4782b0

Browse files
committed
Sema: Another validateDeclForNameLookup() state transition bug
1 parent 8cd89bd commit d4782b0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,6 +3350,7 @@ static void validateTypealiasType(TypeChecker &tc, TypeAliasDecl *typeAlias) {
33503350
// of typealias underlying type e.g. `typealias F = () -> Int#^TOK^#`
33513351
auto underlyingType = typeAlias->getUnderlyingTypeLoc();
33523352
if (underlyingType.isNull()) {
3353+
typeAlias->getUnderlyingTypeLoc().setInvalidType(tc.Context);
33533354
typeAlias->setInterfaceType(ErrorType::get(tc.Context));
33543355
typeAlias->setInvalid();
33553356
return;
@@ -4726,8 +4727,14 @@ void TypeChecker::validateDeclForNameLookup(ValueDecl *D) {
47264727
if (!typealias->getGenericParams()) {
47274728
if (typealias->isBeingValidated()) return;
47284729

4729-
typealias->setIsBeingValidated();
4730-
SWIFT_DEFER { typealias->setIsBeingValidated(false); };
4730+
bool validated = typealias->hasValidationStarted();
4731+
4732+
if (!validated)
4733+
typealias->setIsBeingValidated();
4734+
SWIFT_DEFER {
4735+
if (!validated)
4736+
typealias->setIsBeingValidated(false);
4737+
};
47314738

47324739
(void) typealias->getFormalAccess();
47334740

validation-test/compiler_crashers/28840-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28840-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
protocol P{{}typealias a=(t:Self.a{}typealias a:a

0 commit comments

Comments
 (0)