Skip to content

Commit 7b0e8d2

Browse files
committed
Reflection: Clean up duplication in typeref_decoding*.result.txt
Previously we would pre-process the same input files in the ObjC and non-ObjC tests. This made the tests difficult to update because the output of one was a subset of the other, and only one of the two tests would run on any given platform. Instead, let's just put the Objective-C tests in their own test and input files.
1 parent 824bd75 commit 7b0e8d2

File tree

8 files changed

+51
-701
lines changed

8 files changed

+51
-701
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class ReflectionContext
286286
auto protocolName = Demangle::demangleTypeAsString(
287287
descriptor.getMangledProtocolTypeName());
288288

289-
OS << conformingTypeName << " : " << protocolName;
289+
OS << "- " << conformingTypeName << " : " << protocolName;
290290
OS << '\n';
291291

292292
for (const auto &associatedType : descriptor) {
@@ -303,7 +303,7 @@ class ReflectionContext
303303
auto typeName = Demangle::demangleTypeAsString(
304304
descriptor.getMangledTypeName());
305305

306-
OS << typeName << " :\n";
306+
OS << "\n- " << typeName << ":\n";
307307
OS << "Size: " << descriptor.Size << "\n";
308308
OS << "Alignment: " << descriptor.Alignment << "\n";
309309
OS << "Stride: " << descriptor.Stride << "\n";

test/Reflection/Inputs/ConcreteTypes.swift

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#if _runtime(_ObjC)
2-
import Foundation
3-
#endif
4-
51
public class Box<Treasure> {
62
public let item: Treasure
73
public init(item: Treasure) {
@@ -60,30 +56,3 @@ public struct References {
6056
public weak var weakRef: C?
6157
public unowned var unownedRef: C
6258
}
63-
64-
#if _runtime(_ObjC)
65-
66-
public class OC : NSObject {
67-
public let aClass: C
68-
public let aStruct: S
69-
public let anEnum: E
70-
public let aTuple: (C, S, E, Int)
71-
public let aMetatype: C.Type
72-
public let aFunction: (C, S, E, Int) -> (Int)
73-
public let nsObject: NSObject
74-
public let nsString: NSString
75-
public let cfString: CFString
76-
public init(aClass: C, aStruct: S, anEnum: E, aTuple: (C, S, E, Int), aMetatype: C.Type, aFunction: (C, S, E, Int) -> Int, nsObject: NSObject, nsString: NSString, cfString: CFString) {
77-
self.aClass = aClass
78-
self.aStruct = aStruct
79-
self.anEnum = anEnum
80-
self.aTuple = aTuple
81-
self.aMetatype = aMetatype
82-
self.aFunction = aFunction
83-
self.nsObject = nsObject
84-
self.nsString = nsString
85-
self.cfString = cfString
86-
}
87-
}
88-
89-
#endif

test/Reflection/Inputs/GenericTypes.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#if _runtime(_ObjC)
2-
import Foundation
3-
#endif
4-
51
public class C1<T> : ClassBoundP {
62
public typealias Function = C1<T> -> S1<T> -> E1<T> -> Int
73
public typealias Tuple = (C1<T>, S1<T>, E1<T>, Int)
@@ -162,16 +158,3 @@ extension E4 : P1, P2, P3 {
162158
public typealias Outer = U
163159
public typealias Second = U
164160
}
165-
166-
#if _runtime(_ObjC)
167-
168-
public class GenericOC<T> : NSObject {
169-
public let ocnss: GenericOC<NSString>
170-
public let occfs: GenericOC<CFString>
171-
public init(nss: GenericOC<NSString>, cfs: GenericOC<CFString>) {
172-
self.ocnss = nss
173-
self.occfs = cfs
174-
}
175-
}
176-
177-
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
3+
public class OC : NSObject {
4+
public let nsObject: NSObject
5+
public let nsString: NSString
6+
public let cfString: CFString
7+
public init(nsObject: NSObject, nsString: NSString, cfString: CFString) {
8+
self.nsObject = nsObject
9+
self.nsString = nsString
10+
self.cfString = cfString
11+
}
12+
}
13+
14+
public class GenericOC<T> : NSObject {
15+
public let ocnss: GenericOC<NSString>
16+
public let occfs: GenericOC<CFString>
17+
public init(nss: GenericOC<NSString>, cfs: GenericOC<CFString>) {
18+
self.ocnss = nss
19+
self.occfs = cfs
20+
}
21+
}

test/Reflection/typeref_decoding.result.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -556,40 +556,40 @@ TypesToReflect.E4
556556

557557
ASSOCIATED TYPES:
558558
=================
559-
TypesToReflect.Box : Swift.AnyObject
560-
TypesToReflect.C : Swift.AnyObject
561-
TypesToReflect.C1 : Swift.AnyObject
562-
TypesToReflect.C1 : TypesToReflect.ClassBoundP
559+
- TypesToReflect.Box : Swift.AnyObject
560+
- TypesToReflect.C : Swift.AnyObject
561+
- TypesToReflect.C1 : Swift.AnyObject
562+
- TypesToReflect.C1 : TypesToReflect.ClassBoundP
563563
typealias Inner = A
564564
(generic-type-parameter depth=0 index=0)
565565

566-
TypesToReflect.C2 : Swift.AnyObject
567-
TypesToReflect.C3 : Swift.AnyObject
568-
TypesToReflect.C4 : TypesToReflect.P1
566+
- TypesToReflect.C2 : Swift.AnyObject
567+
- TypesToReflect.C3 : Swift.AnyObject
568+
- TypesToReflect.C4 : TypesToReflect.P1
569569
typealias Inner = A
570570
(generic-type-parameter depth=0 index=0)
571571

572-
TypesToReflect.C4 : TypesToReflect.P2
572+
- TypesToReflect.C4 : TypesToReflect.P2
573573
typealias Outer = A
574574
(generic-type-parameter depth=0 index=0)
575575

576-
TypesToReflect.S4 : TypesToReflect.P1
576+
- TypesToReflect.S4 : TypesToReflect.P1
577577
typealias Inner = A
578578
(generic-type-parameter depth=0 index=0)
579579

580-
TypesToReflect.S4 : TypesToReflect.P2
580+
- TypesToReflect.S4 : TypesToReflect.P2
581581
typealias Outer = A
582582
(generic-type-parameter depth=0 index=0)
583583

584-
TypesToReflect.E4 : TypesToReflect.P1
584+
- TypesToReflect.E4 : TypesToReflect.P1
585585
typealias Inner = A
586586
(generic-type-parameter depth=0 index=0)
587587

588-
TypesToReflect.E4 : TypesToReflect.P2
588+
- TypesToReflect.E4 : TypesToReflect.P2
589589
typealias Outer = B
590590
(generic-type-parameter depth=0 index=1)
591591

592-
TypesToReflect.E4 : TypesToReflect.P3
592+
- TypesToReflect.E4 : TypesToReflect.P3
593593
typealias First = A
594594
(generic-type-parameter depth=0 index=0)
595595

test/Reflection/typeref_decoding.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// UNSUPPORTED: objc_interop
21
// RUN: rm -rf %t && mkdir -p %t
32
// RUN: %target-build-swift %S/Inputs/ConcreteTypes.swift %S/Inputs/GenericTypes.swift %S/Inputs/Protocols.swift -emit-module -emit-library -module-name TypesToReflect -Xfrontend -enable-reflection-metadata -o %t/libTypesToReflect
43
// RUN: %target-swift-reflection-dump -binary-filename %t/libTypesToReflect > %t/typeref_decoding.txt

0 commit comments

Comments
 (0)