Skip to content

Commit 2b75d7f

Browse files
committed
Sema: Don't complain about internal type aliases referenced from @inlinable functions in Swift < 4.2
1 parent 2715801 commit 2b75d7f

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

lib/Sema/ResilienceDiagnostics.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,12 @@ bool TypeChecker::diagnoseInlinableDeclRef(SourceLoc loc,
129129
DowngradeToWarning downgradeToWarning = DowngradeToWarning::No;
130130

131131
// Swift 4.2 did not perform any checks for type aliases.
132-
if (!Context.isSwiftVersionAtLeast(5) &&
133-
isa<TypeAliasDecl>(D))
134-
downgradeToWarning = DowngradeToWarning::Yes;
132+
if (isa<TypeAliasDecl>(D)) {
133+
if (!Context.isSwiftVersionAtLeast(4, 2))
134+
return false;
135+
if (!Context.isSwiftVersionAtLeast(5))
136+
downgradeToWarning = DowngradeToWarning::Yes;
137+
}
135138

136139
auto diagID = diag::resilience_decl_unavailable;
137140
if (downgradeToWarning == DowngradeToWarning::Yes)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-typecheck-verify-swift -swift-version 4
2+
3+
// No diagnostics at all in Swift 4.0 mode.
4+
5+
private typealias PrivateAlias = Int
6+
7+
internal typealias InternalAlias = Int
8+
9+
@usableFromInline typealias UsableFromInlineAlias = Int
10+
11+
public typealias PublicAlias = Int
12+
13+
@inlinable public func f() {
14+
_ = PrivateAlias.self
15+
16+
_ = InternalAlias.self
17+
18+
_ = UsableFromInlineAlias.self
19+
20+
_ = PublicAlias.self
21+
}

test/Compatibility/attr_inlinable_typealias.swift renamed to test/Compatibility/attr_inlinable_typealias_swift42.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %target-typecheck-verify-swift -swift-version 4
1+
// RUN: %target-typecheck-verify-swift -swift-version 4.2
2+
3+
// Only warnings in Swift 4.2 mode.
24

35
private typealias PrivateAlias = Int
46
// expected-note@-1 {{type alias 'PrivateAlias' is not '@usableFromInline' or public}}

0 commit comments

Comments
 (0)