Skip to content

Commit fca1402

Browse files
committed
Adopt warnUntilSwiftVersion for diag::witness_not_usable_from_inline_warn
This changes the wording of some diagnostics in Swift 4.2 and Swift 4 modes.
1 parent b4855ae commit fca1402

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,11 +2637,7 @@ ERROR(type_witness_not_accessible_type,none,
26372637
ERROR(witness_not_usable_from_inline,none,
26382638
"%kind0 must be declared '@usableFromInline' "
26392639
"because it matches a requirement in protocol %1",
2640-
(const ValueDecl *, Identifier))
2641-
WARNING(witness_not_usable_from_inline_warn,none,
2642-
"%kind0 should be declared '@usableFromInline' "
2643-
"because it matches a requirement in protocol %1",
2644-
(const ValueDecl *, Identifier))
2640+
(const ValueDecl *, const ProtocolDecl *))
26452641
ERROR(type_witness_objc_generic_parameter,none,
26462642
"type %0 involving Objective-C type parameter%select{| %1}2 cannot be "
26472643
"used for associated type %3 of protocol %4",

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3310,14 +3310,10 @@ class DiagnoseUsableFromInline {
33103310
auto proto = conformance->getProtocol();
33113311
ASTContext &ctx = proto->getASTContext();
33123312

3313-
auto diagID = diag::witness_not_usable_from_inline;
3314-
if (!ctx.isSwiftVersionAtLeast(5))
3315-
diagID = diag::witness_not_usable_from_inline_warn;
3316-
33173313
SourceLoc diagLoc = getLocForDiagnosingWitness(conformance, witness);
3318-
ctx.Diags.diagnose(diagLoc, diagID,
3319-
witness,
3320-
proto->getName());
3314+
ctx.Diags.diagnose(diagLoc, diag::witness_not_usable_from_inline, witness,
3315+
proto)
3316+
.warnUntilSwiftVersion(5);
33213317
emitDeclaredHereIfNeeded(ctx.Diags, diagLoc, witness);
33223318
}
33233319
};

test/Compatibility/attr_usableFromInline_protocol.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public protocol PublicProtoWithReqs {
77
}
88

99
@usableFromInline struct UFIAdopter<T> : PublicProtoWithReqs {}
10-
// expected-warning@-1 {{type alias 'Assoc' should be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
11-
// expected-warning@-2 {{instance method 'foo()' should be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
10+
// expected-warning@-1 {{type alias 'Assoc' must be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProtoWithReqs'; this is an error in Swift 5}} {{none}}
11+
// expected-warning@-2 {{instance method 'foo()' must be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProtoWithReqs'; this is an error in Swift 5}} {{none}}
1212
extension UFIAdopter {
1313
typealias Assoc = Int
1414
// expected-note@-1 {{'Assoc' declared here}}
@@ -18,9 +18,9 @@ extension UFIAdopter {
1818

1919
@usableFromInline struct UFIAdopterAllInOne<T> : PublicProtoWithReqs {
2020
typealias Assoc = Int
21-
// expected-warning@-1 {{type alias 'Assoc' should be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
21+
// expected-warning@-1 {{type alias 'Assoc' must be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProtoWithReqs'; this is an error in Swift 5}} {{none}}
2222
func foo() {}
23-
// expected-warning@-1 {{instance method 'foo()' should be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
23+
// expected-warning@-1 {{instance method 'foo()' must be declared '@usableFromInline' because it matches a requirement in protocol 'PublicProtoWithReqs'; this is an error in Swift 5}} {{none}}
2424
}
2525

2626
internal struct InternalAdopter<T> : PublicProtoWithReqs {}
@@ -36,8 +36,8 @@ extension InternalAdopter {
3636
}
3737

3838
public struct PublicAdopter<T> : UFIProtoWithReqs {}
39-
// expected-warning@-1 {{type alias 'Assoc' should be declared '@usableFromInline' because it matches a requirement in protocol 'UFIProtoWithReqs'}} {{none}}
40-
// expected-warning@-2 {{instance method 'foo()' should be declared '@usableFromInline' because it matches a requirement in protocol 'UFIProtoWithReqs'}} {{none}}
39+
// expected-warning@-1 {{type alias 'Assoc' must be declared '@usableFromInline' because it matches a requirement in protocol 'UFIProtoWithReqs'; this is an error in Swift 5}} {{none}}
40+
// expected-warning@-2 {{instance method 'foo()' must be declared '@usableFromInline' because it matches a requirement in protocol 'UFIProtoWithReqs'; this is an error in Swift 5}} {{none}}
4141
extension PublicAdopter {
4242
typealias Assoc = Int
4343
// expected-note@-1 {{'Assoc' declared here}}

0 commit comments

Comments
 (0)