File tree Expand file tree Collapse file tree 8 files changed +98
-2
lines changed
test/Serialization/Recovery Expand file tree Collapse file tree 8 files changed +98
-2
lines changed Original file line number Diff line number Diff line change @@ -4307,6 +4307,31 @@ Expected<Type> ModuleFile::getTypeChecked(TypeID TID) {
4307
4307
if (!nominalOrError)
4308
4308
return nominalOrError.takeError ();
4309
4309
4310
+ // Look through compatibility aliases.
4311
+ if (auto *alias = dyn_cast<TypeAliasDecl>(nominalOrError.get ())) {
4312
+ // Reminder: TypeBase::getAs will look through sugar. But we don't want to
4313
+ // do that here, so we do isa<> checks on the TypeBase itself instead of
4314
+ // using the Type wrapper.
4315
+ const TypeBase *underlyingTy = nullptr ;
4316
+ while (alias->isCompatibilityAlias ()) {
4317
+ underlyingTy = alias->getUnderlyingTypeLoc ().getType ().getPointer ();
4318
+
4319
+ // If the underlying type is itself a typealias, it might be another
4320
+ // compatibility alias, meaning we need to go around the loop again.
4321
+ auto aliasTy = dyn_cast<NameAliasType>(underlyingTy);
4322
+ if (!aliasTy)
4323
+ break ;
4324
+ alias = aliasTy->getDecl ();
4325
+ }
4326
+
4327
+ // We only want to use the type we found if it's a simple non-generic
4328
+ // nominal type.
4329
+ if (auto simpleNominalTy = dyn_cast_or_null<NominalType>(underlyingTy)) {
4330
+ nominalOrError = simpleNominalTy->getDecl ();
4331
+ (void )!nominalOrError; // "Check" the llvm::Expected<> value.
4332
+ }
4333
+ }
4334
+
4310
4335
auto nominal = dyn_cast<NominalTypeDecl>(nominalOrError.get ());
4311
4336
if (!nominal) {
4312
4337
XRefTracePath tinyTrace{*nominalOrError.get ()->getModuleContext ()};
Original file line number Diff line number Diff line change
1
+ #if NEW
2
+ # define NEW_NAME (x ) __attribute__((swift_name(#x)))
3
+ #else
4
+ # define NEW_NAME (x )
5
+ #endif
6
+
7
+ struct BeforeStruct {
8
+ int value ;
9
+ } NEW_NAME (AfterStruct );
10
+
11
+ typedef int BeforeTypedef NEW_NAME (AfterTypedef );
12
+ typedef int BeforeWrappedTypedef __attribute__((swift_wrapper (struct ))) NEW_NAME (AfterWrappedTypedef );
13
+
14
+ #if NEW
15
+ typedef struct DifferentStruct {
16
+ int value ;
17
+ } BeforeReplacedType NEW_NAME (AfterReplacedType );
18
+ #else
19
+ struct BeforeReplacedType {
20
+ float value ;
21
+ };
22
+ #endif
Original file line number Diff line number Diff line change 7
7
Typedefs:
8
8
- Name: RenamedTypedef
9
9
SwiftName: RenamedTypedef
10
+ - Name: RenamedWrappedTypedef
11
+ SwiftName: RenamedWrappedTypedef
10
12
Tags:
11
13
- Name: RenamedStruct
12
14
SwiftName: RenamedStruct
@@ -27,6 +29,8 @@ SwiftVersions:
27
29
SwiftName: Swift3RenamedTypedef
28
30
- Name: NewlyWrappedTypedef
29
31
SwiftWrapper: none
32
+ - Name: RenamedWrappedTypedef
33
+ SwiftName: Swift3RenamedWrappedTypedef
30
34
Tags:
31
35
- Name: RenamedStruct
32
36
SwiftName: Swift3RenamedStruct
Original file line number Diff line number Diff line change 10
10
11
11
typedef int RenamedTypedef;
12
12
typedef int NewlyWrappedTypedef __attribute__ ((swift_wrapper(struct )));
13
+ typedef int RenamedWrappedTypedef __attribute__ ((swift_wrapper(struct )));
13
14
14
15
struct RenamedStruct {
15
16
int value;
Original file line number Diff line number Diff line change 1
1
module Overrides { header "Overrides.h" }
2
2
module ProtocolInheritance { header "ProtocolInheritance.h" }
3
+ module RenameAcrossVersions { header "RenameAcrossVersions.h" }
3
4
module Typedefs { header "Typedefs.h" }
4
5
module TypeRemovalObjC { header "TypeRemovalObjC.h" }
5
6
module Types { header "Types.h" }
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-frontend -emit-module -o %t -module-name Lib -I %S/Inputs/custom-modules %s
3
+
4
+ // RUN: %target-swift-ide-test -source-filename=x -print-module -module-to-print Lib -I %t -I %S/Inputs/custom-modules | %FileCheck %s
5
+
6
+ // RUN: %target-swift-ide-test -source-filename=x -print-module -module-to-print Lib -I %t -I %S/Inputs/custom-modules -Xcc -DNEW > %t/recovery.txt
7
+ // RUN: %FileCheck -check-prefix CHECK-RECOVERY %s < %t/recovery.txt
8
+ // RUN: %FileCheck -check-prefix NEGATIVE-RECOVERY %s < %t/recovery.txt
9
+
10
+ import RenameAcrossVersions
11
+
12
+ public func test(
13
+ a: BeforeStruct ,
14
+ b: BeforeTypedef ,
15
+ c: BeforeWrappedTypedef
16
+ ) { }
17
+
18
+ // CHECK-LABEL: func test(
19
+ // CHECK-SAME: a: BeforeStruct
20
+ // CHECK-SAME: b: BeforeTypedef
21
+ // CHECK-SAME: c: BeforeWrappedTypedef
22
+ // CHECK-SAME: )
23
+
24
+ // CHECK-RECOVERY-LABEL: func test(
25
+ // CHECK-RECOVERY-SAME: a: AfterStruct
26
+ // CHECK-RECOVERY-SAME: b: AfterTypedef
27
+ // CHECK-RECOVERY-SAME: c: AfterWrappedTypedef
28
+ // CHECK-RECOVERY-SAME: )
29
+
30
+ // Test replacements that look like renames.
31
+
32
+ // Please only include one parameter per function, so that we test that that one
33
+ // parameter is enough to get the function dropped from the recovery interface.
34
+ public func testReplacementA( _: BeforeReplacedType ) { }
35
+
36
+ // CHECK-LABEL: func testReplacementA(_: BeforeReplacedType)
37
+
38
+ // NEGATIVE-RECOVERY-NOT: testReplacement
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ public func A_renameAllTheThings(
32
32
c: Swift3RenamedTypedef ,
33
33
d: Swift3RenamedStruct ,
34
34
e: Swift3RenamedEnum ,
35
- f: Swift3RenamedProtocol
35
+ f: Swift3RenamedProtocol ,
36
+ g: Swift3RenamedWrappedTypedef
36
37
) { }
37
38
38
39
// CHECK-4-LABEL: func A_renameAllTheThings(
@@ -42,6 +43,7 @@ public func A_renameAllTheThings(
42
43
// CHECK-4-SAME: d: RenamedStruct
43
44
// CHECK-4-SAME: e: RenamedEnum
44
45
// CHECK-4-SAME: f: RenamedProtocol
46
+ // CHECK-4-SAME: g: RenamedWrappedTypedef
45
47
// CHECK-4-SAME: )
46
48
47
49
@@ -56,6 +58,7 @@ public func A_renameAllTheThings(
56
58
// CHECK-3-SAME: d: Swift3RenamedStruct
57
59
// CHECK-3-SAME: e: Swift3RenamedEnum
58
60
// CHECK-3-SAME: f: Swift3RenamedProtocol
61
+ // CHECK-3-SAME: g: Swift3RenamedWrappedTypedef
59
62
// CHECK-3-SAME: )
60
63
61
64
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ public func A_renameAllTheThings(
32
32
c: RenamedTypedef ,
33
33
d: RenamedStruct ,
34
34
e: RenamedEnum ,
35
- f: RenamedProtocol
35
+ f: RenamedProtocol ,
36
+ g: RenamedWrappedTypedef
36
37
) { }
37
38
38
39
// CHECK-LABEL: func A_renameAllTheThings(
@@ -42,6 +43,7 @@ public func A_renameAllTheThings(
42
43
// CHECK-SAME: d: RenamedStruct
43
44
// CHECK-SAME: e: RenamedEnum
44
45
// CHECK-SAME: f: RenamedProtocol
46
+ // CHECK-SAME: g: RenamedWrappedTypedef
45
47
// CHECK-SAME: )
46
48
47
49
You can’t perform that action at this time.
0 commit comments