Files
swift-mirror/test/diagnostics/testable-printast-locations.swift
Brent Royal-Gordon 9dcec05309 Fix non-public imported declaration diagnostic bug
When DiagnosticEngine needs to diagnose something about an imported declaration, it uses ASTPrinter to print the declaration’s interface into a source buffer and then diagnoses it there. However, this code only printed public declarations, so it failed to account for features like `@testable import` which allow less-than-public declarations to be imported. Errors involving these declarations would therefore be diagnosed at <unknown>:0.

This commit changes DiagnosticEngine to determine the access level of the declaration it needs to print and, if it is below `Public`, instead prints a separate interface whose minimum access level is low enough to include the desired declaration.
2020-09-23 14:04:17 -07:00

14 lines
779 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -module-name ModuleA -emit-module-path %t/ModuleA.swiftmodule -primary-file %S/Inputs/TestablePrintASTLocationsModule.swift -enable-testing
// RUN: %target-swift-frontend -emit-module -module-name ModuleB -emit-module-path %t/ModuleB.swiftmodule -primary-file %S/Inputs/TestablePrintASTLocationsModule.swift -enable-testing
// RUN: not %target-swift-frontend -typecheck -I %t %s 2>&1 | %FileCheck %s
@testable import ModuleA
@testable import ModuleB
ambiguous()
// CHECK: testable-printast-locations.swift:[[@LINE-2]]:1: error: ambiguous use of 'ambiguous()'
// CHECK: ModuleA.ambiguous (internal):1:15: note: found this candidate
// CHECK: ModuleB.ambiguous (internal):1:15: note: found this candidate