mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The diagnostics engine has some code to pretty-print a declaration when there is no source location for that declaration. The declaration is pretty-printed into a source buffer, and a source location into that buffer is synthesizes. This applies to synthesized declarations as well as those imported from Swift modules (without source code) or from Clang. Reimplement this pretty-printing for declarations as a request. In doing so, change the manner in which we do the printing: the diagnostics engine printed the entire enclosing type into a buffer whose name was the module + that type. This meant that the buffer was shared by every member of that type, but also meant that we would end up deserializing a lot of declarations just for printing and potentially doing a lot more work for these diagnostics.
15 lines
659 B
Swift
15 lines
659 B
Swift
// RUN: rm -f %t.*
|
|
|
|
// Test swift executable
|
|
// RUN: %target-swift-frontend -typecheck -serialize-diagnostics-path %t.dia %s -verify
|
|
// RUN: c-index-test -read-diagnostics %t.dia > %t.deserialized_diagnostics.txt 2>&1
|
|
// RUN: %FileCheck --input-file=%t.deserialized_diagnostics.txt %s
|
|
|
|
var x = String.init // expected-error{{ambiguous use of 'init'}}
|
|
// CHECK: {{.*[/\\]}}serialized-diagnostics-prettyprint.swift:[[@LINE-1]]:16: error: ambiguous use of 'init'
|
|
|
|
// CHECK: Swift.String.init:2:19: note: found this candidate
|
|
// CHECK: CONTENTS OF FILE Swift.String.init:
|
|
// CHECK: struct String {
|
|
// CHECK: public init(_ content: Substring.UnicodeScalarView)
|