Skip to content

Commit 3c793e4

Browse files
committed
---
yaml --- r: 347255 b: refs/heads/master c: 07fd38f h: refs/heads/master i: 347253: 405a6ca 347251: 0820573 347247: bd2d98e
1 parent ae7739a commit 3c793e4

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 735003752681e409e7c5dbdcefce256f31d6742e
2+
refs/heads/master: 07fd38f97d87d70a2cd037019ca772f62d03460a
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/Serialization/Deserialization.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4329,28 +4329,35 @@ class swift::TypeDeserializer {
43294329
underlyingTypeID,
43304330
substitutedTypeID,
43314331
substitutionsID);
4332-
auto aliasOrError = MF.getDeclChecked(typealiasID);
4333-
if (!aliasOrError)
4334-
return aliasOrError.takeError();
4335-
auto alias = dyn_cast<TypeAliasDecl>(aliasOrError.get());
4336-
4337-
bool formSugaredType = true;
43384332

4333+
TypeAliasDecl *alias = nullptr;
43394334
Type underlyingType;
43404335
if (ctx.LangOpts.EnableDeserializationRecovery) {
43414336
auto underlyingTypeOrError = MF.getTypeChecked(underlyingTypeID);
4342-
if (!underlyingTypeOrError)
4337+
if (!underlyingTypeOrError) {
4338+
// If we can't deserialize the underlying type, we can't be sure the
4339+
// actual typealias hasn't changed.
43434340
return underlyingTypeOrError.takeError();
4341+
}
43444342

43454343
underlyingType = underlyingTypeOrError.get();
43464344

4345+
if (auto aliasOrError = MF.getDeclChecked(typealiasID)) {
4346+
alias = dyn_cast<TypeAliasDecl>(aliasOrError.get());
4347+
} else {
4348+
// We're going to recover by falling back to the underlying type, so
4349+
// just ignore the error.
4350+
llvm::consumeError(aliasOrError.takeError());
4351+
}
4352+
43474353
if (!alias ||
43484354
!alias->getDeclaredInterfaceType()->isEqual(underlyingType)) {
43494355
// Fall back to the canonical type.
4350-
formSugaredType = false;
4356+
return underlyingType;
43514357
}
43524358

43534359
} else {
4360+
alias = dyn_cast<TypeAliasDecl>(MF.getDecl(typealiasID));
43544361
underlyingType = MF.getType(underlyingTypeID);
43554362
}
43564363

@@ -4377,9 +4384,6 @@ class swift::TypeDeserializer {
43774384
return underlyingType;
43784385
}
43794386

4380-
if (!formSugaredType)
4381-
return underlyingType;
4382-
43834387
auto parentType = parentTypeOrError.get();
43844388
return TypeAliasType::get(alias, parentType, subMap, substitutedType);
43854389
}

trunk/test/Serialization/Recovery/Inputs/custom-modules/TypeRemovalObjC.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ __attribute__((objc_root_class))
1212

1313
@protocol SomeProto
1414
@end
15+
16+
typedef long long SomeTypedef;
1517
#endif
1618

1719
@protocol ZProto

trunk/test/Serialization/Recovery/type-removal-objc.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public let someProtoCompositionValue: (AProto & SomeProto)? = nil
3434
// CHECK-RECOVERY-NEGATIVE-NOT: let someProtoCompositionValue2:
3535
public let someProtoCompositionValue2: (SomeProto & ZProto)? = nil
3636

37+
// CHECK-DAG: let someTypedefValue: SomeTypedef
38+
// CHECK-RECOVERY-DAG: let someTypedefValue: Int64
39+
public let someTypedefValue: SomeTypedef = 0
40+
// CHECK-DAG: let someTypedefOptValue: SomeTypedef?
41+
// CHECK-RECOVERY-DAG: let someTypedefOptValue: Int64?
42+
public let someTypedefOptValue: SomeTypedef? = nil
43+
3744
// CHECK-DAG: unowned var someUnownedObject: @sil_unowned Base
3845
// CHECK-RECOVERY-NEGATIVE-NOT: var someUnownedObject:
3946
public unowned var someUnownedObject: Base = Base()

0 commit comments

Comments
 (0)