Skip to content

Commit 6d9b82b

Browse files
committed
[Sema] Error on aliases desugaring to a reference SPI only imported
There are only new users of @_spiOnly so we can already make this diagnostic an error.
1 parent d1e36b0 commit 6d9b82b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/Sema/ResilienceDiagnostics.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,17 @@ static bool diagnoseTypeAliasDeclRefExportability(SourceLoc loc,
132132
TAD->getName(), definingModule->getNameStr(), D->getNameStr(),
133133
static_cast<unsigned>(*reason), definingModule->getName(),
134134
static_cast<unsigned>(originKind))
135-
.warnUntilSwiftVersion(6);
135+
.warnUntilSwiftVersionIf(originKind != DisallowedOriginKind::SPIOnly,
136+
6);
136137
} else {
137138
ctx.Diags
138139
.diagnose(loc,
139140
diag::inlinable_typealias_desugars_to_type_from_hidden_module,
140141
TAD->getName(), definingModule->getNameStr(), D->getNameStr(),
141142
fragileKind.getSelector(), definingModule->getName(),
142143
static_cast<unsigned>(originKind))
143-
.warnUntilSwiftVersion(6);
144+
.warnUntilSwiftVersionIf(originKind != DisallowedOriginKind::SPIOnly,
145+
6);
144146
}
145147
D->diagnose(diag::kind_declared_here, DescriptiveDeclKind::Type);
146148

test/Sema/implicit-import-typealias.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// RUN: %target-swift-frontend -typecheck -verify %t/UsesAliasesNoImport.swift -I %t
1111
// RUN: %target-swift-frontend -typecheck -verify %t/UsesAliasesImplementationOnlyImport.swift -I %t
12+
// RUN: %target-swift-frontend -typecheck -verify %t/UsesAliasesSPIOnlyImport.swift -I %t -experimental-spi-only-imports
1213
// RUN: %target-swift-frontend -typecheck -verify %t/UsesAliasesWithImport.swift -I %t
1314

1415
/// The swiftinterface is broken by the missing import without the workaround.
@@ -101,6 +102,20 @@ import Aliases
101102
public func takesGeneric<T: ProtoAlias>(_ t: T) {}
102103

103104

105+
//--- UsesAliasesSPIOnlyImport.swift
106+
107+
import Aliases
108+
@_spiOnly import Original
109+
110+
@inlinable public func inlinableFunc() {
111+
// expected-error@+1 {{'StructAlias' aliases 'Original.Struct' and cannot be used in an '@inlinable' function because 'Original' was imported for SPI only}}
112+
_ = StructAlias.self
113+
}
114+
115+
// expected-error@+1 {{'ProtoAlias' aliases 'Original.Proto' and cannot be used here because 'Original' was imported for SPI only}}
116+
public func takesGeneric<T: ProtoAlias>(_ t: T) {}
117+
118+
104119
//--- UsesAliasesWithImport.swift
105120

106121
import Aliases

0 commit comments

Comments
 (0)