Skip to content

Commit 6a6f955

Browse files
committed
---
yaml --- r: 345945 b: refs/heads/master c: 3cd7f2f h: refs/heads/master i: 345943: 570c26c
1 parent 725c3a1 commit 6a6f955

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9943d27da2fe5e9a2666365d71924500e89e30f8
2+
refs/heads/master: 3cd7f2f7b46151b78bc95b72523de5c3d459d72f
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/Sema/TypeCheckProtocol.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,13 @@ RequirementCheck WitnessChecker::checkWitness(ValueDecl *requirement,
13221322
return RequirementCheck(kind, getRequiredAccessScope());
13231323
}
13241324

1325+
if (isUsableFromInlineRequired()) {
1326+
bool witnessIsUsableFromInline = match.Witness->getFormalAccessScope(
1327+
DC, /*usableFromInlineAsPublic*/true).isPublic();
1328+
if (!witnessIsUsableFromInline)
1329+
return CheckKind::UsableFromInline;
1330+
}
1331+
13251332
auto requiredAvailability = AvailabilityContext::alwaysAvailable();
13261333
if (checkWitnessAvailability(requirement, match.Witness,
13271334
&requiredAvailability)) {
@@ -3067,6 +3074,10 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
30673074
break;
30683075
}
30693076

3077+
case CheckKind::UsableFromInline:
3078+
diagnoseOrDefer(requirement, false, DiagnoseUsableFromInline(witness));
3079+
break;
3080+
30703081
case CheckKind::Availability: {
30713082
diagnoseOrDefer(requirement, false,
30723083
[witness, requirement, check](

trunk/lib/Sema/TypeCheckProtocol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ enum class CheckKind : unsigned {
252252
/// requirement.
253253
AccessOfSetter,
254254

255+
/// The witness needs to be @usableFromInline.
256+
UsableFromInline,
257+
255258
/// The witness is less available than the requirement.
256259
Availability,
257260

trunk/test/Compatibility/attr_usableFromInline_protocol.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ public protocol PublicProtoWithReqs {
88

99
@usableFromInline struct UFIAdopter<T> : PublicProtoWithReqs {}
1010
// expected-warning@-1 {{type alias 'Assoc' should be declared '@usableFromInline' because because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
11+
// expected-warning@-2 {{instance method 'foo()' should be declared '@usableFromInline' because because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
1112
extension UFIAdopter {
1213
typealias Assoc = Int
1314
// expected-note@-1 {{'Assoc' declared here}}
1415
func foo() {}
16+
// expected-note@-1 {{'foo()' declared here}}
1517
}
1618

1719
@usableFromInline struct UFIAdopterAllInOne<T> : PublicProtoWithReqs {
1820
typealias Assoc = Int
1921
// expected-warning@-1 {{type alias 'Assoc' should be declared '@usableFromInline' because because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
2022
func foo() {}
23+
// expected-warning@-1 {{instance method 'foo()' should be declared '@usableFromInline' because because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
2124
}
2225

2326
internal struct InternalAdopter<T> : PublicProtoWithReqs {}
@@ -34,9 +37,11 @@ extension InternalAdopter {
3437

3538
public struct PublicAdopter<T> : UFIProtoWithReqs {}
3639
// expected-warning@-1 {{type alias 'Assoc' should be declared '@usableFromInline' because because it matches a requirement in protocol 'UFIProtoWithReqs'}} {{none}}
40+
// expected-warning@-2 {{instance method 'foo()' should be declared '@usableFromInline' because because it matches a requirement in protocol 'UFIProtoWithReqs'}} {{none}}
3741
extension PublicAdopter {
3842
typealias Assoc = Int
3943
// expected-note@-1 {{'Assoc' declared here}}
4044
func foo() {}
45+
// expected-note@-1 {{'foo()' declared here}}
4146
}
4247
extension InternalAdopter: UFIProtoWithReqs {} // okay

trunk/test/attr/attr_usableFromInline_protocol.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ public protocol PublicProtoWithReqs {
88

99
@usableFromInline struct UFIAdopter<T> : PublicProtoWithReqs {}
1010
// expected-error@-1 {{type alias 'Assoc' must be declared '@usableFromInline' because because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
11+
// expected-error@-2 {{instance method 'foo()' must be declared '@usableFromInline' because because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
1112
extension UFIAdopter {
1213
typealias Assoc = Int
1314
// expected-note@-1 {{'Assoc' declared here}}
1415
func foo() {}
16+
// expected-note@-1 {{'foo()' declared here}}
1517
}
1618

1719
@usableFromInline struct UFIAdopterAllInOne<T> : PublicProtoWithReqs {
1820
typealias Assoc = Int
1921
// expected-error@-1 {{type alias 'Assoc' must be declared '@usableFromInline' because because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
2022
func foo() {}
23+
// expected-error@-1 {{instance method 'foo()' must be declared '@usableFromInline' because because it matches a requirement in protocol 'PublicProtoWithReqs'}} {{none}}
2124
}
2225

2326
internal struct InternalAdopter<T> : PublicProtoWithReqs {}
@@ -34,9 +37,11 @@ extension InternalAdopter {
3437

3538
public struct PublicAdopter<T> : UFIProtoWithReqs {}
3639
// expected-error@-1 {{type alias 'Assoc' must be declared '@usableFromInline' because because it matches a requirement in protocol 'UFIProtoWithReqs'}} {{none}}
40+
// expected-error@-2 {{instance method 'foo()' must be declared '@usableFromInline' because because it matches a requirement in protocol 'UFIProtoWithReqs'}} {{none}}
3741
extension PublicAdopter {
3842
typealias Assoc = Int
3943
// expected-note@-1 {{'Assoc' declared here}}
4044
func foo() {}
45+
// expected-note@-1 {{'foo()' declared here}}
4146
}
4247
extension InternalAdopter: UFIProtoWithReqs {} // okay

0 commit comments

Comments
 (0)