Skip to content

Commit 9e93b7b

Browse files
committed
Frontend: Remove support for -experimental-spi-imports flag.
Its functionality has been superseded by `@_spiOnly import`. There are no longer any known clients and the flag was already unsupported in Swift 6, so the functionality is now removed (but the flag is only deprecated for Swift 5). Resolves rdar://136867210.
1 parent 88ac67d commit 9e93b7b

File tree

6 files changed

+20
-128
lines changed

6 files changed

+20
-128
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ REMARK(interface_file_backup_used,none,
486486
"building module from '%0' failed; retrying building module from '%1'", (StringRef, StringRef))
487487

488488
WARNING(warn_flag_deprecated,none, "flag '%0' is deprecated", (StringRef))
489+
ERROR(flag_unsuppored,none, "flag '%0' is unsupported", (StringRef))
489490

490491
// Output deterministic check
491492
ERROR(error_nondeterministic_output,none,

include/swift/Frontend/ModuleInterfaceSupport.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ struct ModuleInterfaceOptions {
6767
/// Flags which appear only in the .package.swiftinterface.
6868
InterfaceFlags PackageFlags = {};
6969

70-
/// Print imports with both @_implementationOnly and @_spi, only applies
71-
/// when PrintSPIs is true.
72-
bool ExperimentalSPIImports = false;
73-
7470
/// Print imports that are missing from the source and used in API.
7571
bool PrintMissingImports = true;
7672

lib/Frontend/CompilerInvocation.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,6 @@ static void ParseModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
519519
::getenv("SWIFT_ALIAS_MODULE_NAMES_IN_INTERFACES"));
520520
Opts.PrintFullConvention |=
521521
Args.hasArg(OPT_experimental_print_full_convention);
522-
Opts.ExperimentalSPIImports |=
523-
Args.hasArg(OPT_experimental_spi_imports);
524522
Opts.DebugPrintInvalidSyntax |=
525523
Args.hasArg(OPT_debug_emit_invalid_swiftinterface_syntax);
526524
Opts.PrintMissingImports =
@@ -1193,6 +1191,16 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
11931191
}
11941192

11951193
Opts.EnableSPIOnlyImports = Args.hasArg(OPT_experimental_spi_only_imports);
1194+
if (Args.hasArg(OPT_experimental_spi_imports)) {
1195+
if (Opts.EffectiveLanguageVersion.isVersionAtLeast(6)) {
1196+
Diags.diagnose(SourceLoc(), diag::flag_unsuppored,
1197+
"-experimental-spi-imports");
1198+
HadError = true;
1199+
} else {
1200+
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
1201+
"-experimental-spi-imports");
1202+
}
1203+
}
11961204

11971205
if (Args.hasArg(OPT_warn_swift3_objc_inference_minimal))
11981206
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
@@ -3733,15 +3741,10 @@ bool CompilerInvocation::parseArgs(
37333741
}
37343742
}
37353743

3736-
// With Swift 6, enable @_spiOnly by default and forbid the old version.
3737-
// This also enables proper error reporting of ioi references from spi decls.
3744+
// With Swift 6, enable @_spiOnly by default. This also enables proper error
3745+
// reporting of ioi references from spi decls.
37383746
if (LangOpts.EffectiveLanguageVersion.isVersionAtLeast(6)) {
37393747
LangOpts.EnableSPIOnlyImports = true;
3740-
3741-
if (ParsedArgs.hasArg(OPT_experimental_spi_imports)) {
3742-
Diags.diagnose(SourceLoc(), diag::error_old_spi_only_import_unsupported);
3743-
return true;
3744-
}
37453748
}
37463749

37473750
return false;

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -279,27 +279,6 @@ static void printImports(raw_ostream &out,
279279
return importSet;
280280
};
281281

282-
// With -experimental-spi-imports:
283-
// When printing the private or package swiftinterface file, print implementation-only
284-
// imports only if they are also SPI. First, list all implementation-only imports and
285-
// filter them later.
286-
llvm::SmallSet<ImportedModule, 4, ImportedModule::Order> ioiImportSet;
287-
if (!Opts.printPublicInterface() && Opts.ExperimentalSPIImports) {
288-
289-
SmallVector<ImportedModule, 4> ioiImports, allImports;
290-
M->getImportedModules(ioiImports,
291-
ModuleDecl::ImportFilterKind::ImplementationOnly);
292-
293-
// Only consider modules imported consistently as implementation-only.
294-
ImportSet allImportSet = getImports(allImportFilter);
295-
296-
for (auto import: ioiImports)
297-
if (allImportSet.count(import) == 0)
298-
ioiImportSet.insert(import);
299-
300-
allImportFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
301-
}
302-
303282
/// Collect @_spiOnly imports that are not imported elsewhere publicly.
304283
ImportSet spiOnlyImportSet;
305284
if (!Opts.printPublicInterface()) {
@@ -367,13 +346,6 @@ static void printImports(raw_ostream &out,
367346
llvm::SmallSetVector<Identifier, 4> spis;
368347
M->lookupImportedSPIGroups(importedModule, spis);
369348

370-
// Only print implementation-only imports which have an SPI import.
371-
if (ioiImportSet.count(import)) {
372-
if (spis.empty())
373-
continue;
374-
out << "@_implementationOnly ";
375-
}
376-
377349
if (exportedImportSet.count(import))
378350
out << "@_exported ";
379351

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,11 @@
1-
/// Test the textual interfaces generated with -experimental-spi-imports.
1+
// RUN: %target-swift-frontend -typecheck %s -swift-version 5 \
2+
// RUN: -experimental-spi-imports 2>&1 | %FileCheck %s -check-prefix=CHECK-5
23

3-
// RUN: %empty-directory(%t)
4-
5-
/// Generate 3 empty modules.
6-
// RUN: touch %t/empty.swift
7-
// RUN: %target-swift-frontend -emit-module %S/Inputs/ioi_helper.swift -module-name ExperimentalImported -emit-module-path %t/ExperimentalImported.swiftmodule -swift-version 5 -enable-library-evolution
8-
// RUN: %target-swift-frontend -emit-module %t/empty.swift -module-name IOIImported -emit-module-path %t/IOIImported.swiftmodule -swift-version 5 -enable-library-evolution
9-
// RUN: %target-swift-frontend -emit-module %t/empty.swift -module-name SPIImported -emit-module-path %t/SPIImported.swiftmodule -swift-version 5 -enable-library-evolution
10-
// RUN: %target-swift-frontend -emit-module %t/empty.swift -module-name InconsistentlyImported -emit-module-path %t/InconsistentlyImported.swiftmodule -swift-version 5 -enable-library-evolution
11-
12-
/// Test the generated swiftinterface.
13-
// RUN: %target-swift-frontend -typecheck %s %S/Inputs/experimental_spi_imports_inconsistent.swift -emit-module-interface-path %t/main.swiftinterface -emit-private-module-interface-path %t/main.private.swiftinterface -enable-library-evolution -swift-version 5 -I %t -experimental-spi-imports
14-
// RUN: %target-swift-typecheck-module-from-interface(%t/main.swiftinterface) -I %t
15-
// RUN: %target-swift-typecheck-module-from-interface(%t/main.private.swiftinterface) -I %t
16-
// RUN: %FileCheck -check-prefix=CHECK-PUBLIC %s < %t/main.swiftinterface
17-
// RUN: %FileCheck -check-prefix=CHECK-PRIVATE %s < %t/main.private.swiftinterface
18-
19-
/// The flag is rejected in Swift 6.
20-
// RUN: not %target-swift-frontend -typecheck % -swift-version 6 \
4+
// RUN: not %target-swift-frontend -typecheck %s -swift-version 6 \
215
// RUN: -experimental-spi-imports 2>&1 | %FileCheck %s -check-prefix=CHECK-6
22-
// CHECK-6: error: '-experimental-spi-imports' is unsupported in Swift 6, use '@_spiOnly' instead
236

24-
@_spi(dummy) @_implementationOnly import ExperimentalImported
25-
// CHECK-PUBLIC-NOT: import ExperimentalImported
26-
// CHECK-PRIVATE: @_implementationOnly @_spi{{.*}} import ExperimentalImported
7+
/// The flag is deprecated before Swift 6.
8+
// CHECK-5: flag '-experimental-spi-imports' is deprecated
279

28-
// This is also imported as implementation-only via another source file.
29-
import InconsistentlyImported
30-
// CHECK-PUBLIC: {{^}}import InconsistentlyImported
31-
// CHECK-PRIVATE: {{^}}import InconsistentlyImported
32-
33-
@_implementationOnly import IOIImported
34-
// CHECK-PUBLIC-NOT: IOIImported
35-
// CHECK-PRIVATE-NOT: IOIImported
36-
37-
@_spi(dummy) import SPIImported
38-
// CHECK-PUBLIC: {{^}}import SPIImported
39-
// CHECK-PRIVATE: @_spi{{.*}} import SPIImported
40-
41-
@_spi(X)
42-
extension IOIPublicStruct {
43-
public func foo() {}
44-
}
45-
// CHECK-PUBLIC-NOT: ExperimentalImported.IOIPublicStruct
46-
// CHECK-PRIVATE: @_spi{{.*}} extension ExperimentalImported.IOIPublicStruct
10+
/// The flag is rejected in Swift 6.
11+
// CHECK-6: flag '-experimental-spi-imports' is unsupported

test/SPI/experimental_spi_imports_type_check.swift

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)