Skip to content

Commit a99d07a

Browse files
committed
Add a Test to Ensure That Changes to Extension Members Cause Rebuilds
1 parent db8e6cc commit a99d07a

File tree

6 files changed

+73
-5
lines changed

6 files changed

+73
-5
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public struct S {
2+
private
3+
static func foo(_ i: Int) {print("1: other:2 commented out")}
4+
}
5+
extension S {
6+
// private // commented out to ensure we see a change to the fingerprint
7+
static func foo2(_ i: Int) {print("2: other:6 commented out")}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public struct S {
2+
private // commenting out this line works
3+
static func foo(_ i: Int) {print("1: other:2 commented out")}
4+
}
5+
extension S {
6+
private // commenting out this line fails
7+
static func foo2(_ i: Int) {print("2: other:6 commented out")}
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extension S {
2+
static func foo<I: SignedInteger>(_ si: I) {
3+
print("1: other:2 not commented out")
4+
}
5+
static func foo2<I: SignedInteger>(_ si: I) {
6+
print("2: other:6 not commented out")
7+
}
8+
}
9+
10+
S.foo(3)
11+
S.foo2(3)
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+

test/Incremental/Fingerprints/extension-adds-member.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
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.
1+
// Test that adding an overloaded member to an extension causes the users
2+
// depending on that extension to rebuild.
63

74
// Establish status quo
85

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Test that moving an overloaded member from one extension to another forces a
2+
// rebuild of existing users. We do not strictly need this behavior to occur in
3+
// all cases, but it's good to be safe.
4+
5+
// Establish status quo
6+
7+
// RUN: %empty-directory(%t)
8+
// RUN: cp %S/Inputs/extension-changes-member/* %t
9+
// RUN: cp %t/definesS{-before,}.swift
10+
11+
// Seeing weird failure on CI, so set the mod times
12+
// RUN: touch -t 200101010101 %t/*.swift
13+
14+
// 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
15+
16+
// Change one type, only uses of that type get recompiled
17+
18+
// RUN: cp %t/definesS{-after,}.swift
19+
20+
// Seeing weird failure on CI, so ensure that definesS.swift is newer
21+
// RUN: touch -t 200201010101 %t/*
22+
// RUN: touch -t 200101010101 %t/*.swift
23+
// RUN: touch -t 200301010101 %t/definesS.swift
24+
25+
// 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
26+
27+
// RUN: %FileCheck -check-prefix=CHECK-RECOMPILED-W %s < %t/output4
28+
29+
// CHECK-RECOMPILED-W: {compile: definesS.o <= definesS.swift}
30+
// CHECK-RECOMPILED-W: {compile: main.o <= main.swift}

0 commit comments

Comments
 (0)