Skip to content

Commit 6dc2f04

Browse files
authored
Merge pull request #80762 from hamishknight/serial-port
[test] Avoid relying on stdlib in `serialized-diagnostics-prettyprint.swift`
2 parents 9cc1947 + 38b143d commit 6dc2f04

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed
Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
// RUN: rm -f %t.*
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
23

3-
// Test swift executable
4-
// RUN: %target-swift-frontend -typecheck -serialize-diagnostics-path %t.dia %s -verify
5-
// RUN: c-index-test -read-diagnostics %t.dia > %t.deserialized_diagnostics.txt 2>&1
6-
// RUN: %FileCheck --input-file=%t.deserialized_diagnostics.txt %s
4+
// RUN: %target-swift-frontend -emit-module %t/Lib.swift -module-name Lib -emit-module-path %t/Lib.swiftmodule
5+
// RUN: %target-swift-frontend -typecheck -I %t -serialize-diagnostics-path %t/diags.dia %t/Client.swift -verify
6+
// RUN: c-index-test -read-diagnostics %t/diags.dia > %t/diags.deserialized_diagnostics.txt 2>&1
7+
// RUN: %FileCheck --input-file=%t/diags.deserialized_diagnostics.txt %t/Client.swift
78

8-
var x = String.init(_:) // expected-error{{ambiguous use of 'init(_:)'}}
9-
// CHECK: {{.*[/\\]}}serialized-diagnostics-prettyprint.swift:[[@LINE-1]]:16: error: ambiguous use of 'init(_:)'
9+
//--- Lib.swift
1010

11-
// CHECK: Swift.String.init:2:19: note: found this candidate
12-
// CHECK: CONTENTS OF FILE Swift.String.init:
13-
// CHECK: struct String {
14-
// CHECK: public init(_ content: Substring.UnicodeScalarView)
11+
public struct S {
12+
public init(a: String) {}
13+
@discardableResult // We use @discardableResult here to give this init a distinct line number in the pretty print.
14+
public init(b: Int) {}
15+
}
16+
17+
//--- Client.swift
18+
19+
import Lib
20+
21+
var x = S.init // expected-error {{ambiguous use of 'init'}}
22+
// CHECK: {{.*[/\\]}}Client.swift:[[@LINE-1]]:11: error: ambiguous use of 'init'
23+
24+
// FIXME: Currently we can't check for 'init(a:)' because c-index-test is
25+
// keying the source file contents on the buffer identifier, so we end up
26+
// with duplicated 'init(b:)'.
27+
28+
// CHECK: Lib.S.init:3:10: note: found this candidate
29+
// CHECK: CONTENTS OF FILE Lib.S.init:
30+
// CHECK: struct S {
31+
// CHECK-NEXT: @discardableResult
32+
// CHECK-NEXT: public init(b: Int)

0 commit comments

Comments
 (0)