Skip to content

[Sema] Report exported uses of conformances that are implicitly imported #60008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2922,7 +2922,8 @@ ERROR(conformance_from_implementation_only_module,none,
"in an extension with conditional conformances}2; "
"%select{%3 has been imported as implementation-only|"
"the conformance is declared as SPI in %3|"
"the conformance is declared as SPI}4",
"the conformance is declared as SPI|"
"%3 was not imported by this file}4",
(Type, Identifier, unsigned, Identifier, unsigned))
NOTE(assoc_conformance_from_implementation_only_module,none,
"in associated type %0 (inferred as %1)", (Type, Type))
Expand Down
12 changes: 12 additions & 0 deletions test/Sema/implicit-import-in-inlinable-code.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ public struct ImportedType {
public init() {}
}

// Test exportability of conformance uses
public protocol SomeProtocol {}
public func conformanceUse(_ a: SomeProtocol) {}

// BEGIN libB.swift
import libA

extension ImportedType {
public func implicitlyImportedMethod() {}
}

extension ImportedType : SomeProtocol {}

/// Client module
// BEGIN clientFileA-Swift5.swift
import libA
Expand All @@ -40,6 +46,8 @@ import libA

// Expected implicit imports are still fine
a.localModuleMethod()

conformanceUse(a) // expected-warning {{cannot use conformance of 'ImportedType' to 'SomeProtocol' here; 'libB' was not imported by this file; this is an error in Swift 6}}
}

// BEGIN clientFileA-OldCheck.swift
Expand All @@ -52,6 +60,8 @@ import libA

// Expected implicit imports are still fine
a.localModuleMethod()

conformanceUse(a) // expected-warning {{cannot use conformance of 'ImportedType' to 'SomeProtocol' here; 'libB' was not imported by this file; this is an error in Swift 6}}
}

// BEGIN clientFileA-Swift6.swift
Expand All @@ -63,6 +73,8 @@ import libA

// Expected implicit imports are still fine
a.localModuleMethod()

conformanceUse(a) // expected-error {{cannot use conformance of 'ImportedType' to 'SomeProtocol' here; 'libB' was not imported by this file}}
}

// BEGIN clientFileB.swift
Expand Down