Skip to content

Commit 49c89e2

Browse files
committed
Add a Test for Moving Declarations From One Extension to Another
1 parent ef7dfad commit 49c89e2

File tree

5 files changed

+88
-0
lines changed

5 files changed

+88
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public protocol P {
2+
func foo()
3+
}
4+
5+
public protocol Q: P {
6+
func bar()
7+
}
8+
9+
public struct S {}
10+
11+
extension S: P {
12+
public func foo() {}
13+
}
14+
15+
extension S: Q {
16+
public func bar() {}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public protocol P {
2+
func foo()
3+
}
4+
5+
public protocol Q: P {
6+
func bar()
7+
}
8+
9+
public struct S {}
10+
11+
extension S: P {
12+
public func foo() {}
13+
public func bar() {}
14+
}
15+
16+
extension S: Q {
17+
18+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extension S {
2+
public func foo(_ parameter: Int = 42) {}
3+
public func bar(_ parameter: Int = 42) {}
4+
}
5+
6+
S().foo()
7+
S().bar()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"main.swift": {
3+
"object": "./main.o",
4+
"swift-dependencies": "./main.swiftdeps"
5+
},
6+
"definesS.swift": {
7+
"object": "./definesS.o",
8+
"swift-dependencies": "./definesS.swiftdeps"
9+
},
10+
"": {
11+
"swift-dependencies": "./main~buildrecord.swiftdeps"
12+
}
13+
}
14+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Test per-type-body fingerprints using simple extensions
2+
//
3+
// If the parser is allowed to use a body fingerprint for an extension
4+
// this test will fail because usesA.swift won't be recompiled for the
5+
// last step.
6+
7+
// Establish status quo
8+
9+
// RUN: %empty-directory(%t)
10+
// RUN: cp %S/Inputs/member-moves-extensions/* %t
11+
// RUN: cp %t/definesS{-before,}.swift
12+
13+
// Seeing weird failure on CI, so set the mod times
14+
// RUN: touch -t 200101010101 %t/*.swift
15+
16+
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesS.swift -module-name main -output-file-map ofm.json >& %t/output3
17+
18+
// Change one type, only uses of that type get recompiled
19+
20+
// RUN: cp %t/definesS{-after,}.swift
21+
22+
// Seeing weird failure on CI, so ensure that definesS.swift is newer
23+
// RUN: touch -t 200201010101 %t/*
24+
// RUN: touch -t 200101010101 %t/*.swift
25+
// RUN: touch -t 200301010101 %t/definesS.swift
26+
27+
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesS.swift -module-name main -output-file-map ofm.json >& %t/output4
28+
29+
// RUN: %FileCheck -check-prefix=CHECK-RECOMPILED-W %s < %t/output4
30+
31+
// CHECK-RECOMPILED-W: {compile: definesS.o <= definesS.swift}
32+
// CHECK-RECOMPILED-W: {compile: main.o <= main.swift}

0 commit comments

Comments
 (0)