Skip to content

Commit 7760d5c

Browse files
committed
---
yaml --- r: 347498 b: refs/heads/master c: f5470c5 h: refs/heads/master
1 parent a83f5ea commit 7760d5c

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
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: 350949fe8fa1708931cd7ff8dac86081fbc3fbf1
2+
refs/heads/master: f5470c5abe97bc1eaed88d362c2bc8fec7a16e01
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/AST/DeclContext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ bool DeclContext::isGenericContext() const {
309309
/// domains, this ensures that only sufficiently-conservative access patterns
310310
/// are used.
311311
ResilienceExpansion DeclContext::getResilienceExpansion() const {
312-
for (const auto *dc = this; dc->isLocalContext(); dc = dc->getParent()) {
312+
for (const auto *dc = getLocalContext(); dc && dc->isLocalContext();
313+
dc = dc->getParent()) {
313314
// Default argument initializer contexts have their resilience expansion
314315
// set when they're type checked.
315316
if (isa<DefaultArgumentInitializer>(dc)) {

trunk/lib/Sema/ResilienceDiagnostics.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ using FragileFunctionKind = TypeChecker::FragileFunctionKind;
2525

2626
std::pair<FragileFunctionKind, bool>
2727
TypeChecker::getFragileFunctionKind(const DeclContext *DC) {
28-
for (; DC->isLocalContext(); DC = DC->getParent()) {
28+
for (DC = DC->getLocalContext(); DC && DC->isLocalContext();
29+
DC = DC->getParent()) {
2930
if (isa<DefaultArgumentInitializer>(DC)) {
3031
// Default argument generators of public functions cannot reference
3132
// @usableFromInline declarations; all other fragile function kinds
@@ -176,6 +177,11 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
176177
diagName = accessor->getStorage()->getFullName();
177178
}
178179

180+
// Swift 5.0 did not check the underlying types of local typealiases.
181+
// FIXME: Conditionalize this once we have a new language mode.
182+
if (isa<TypeAliasDecl>(DC))
183+
downgradeToWarning = DowngradeToWarning::Yes;
184+
179185
auto diagID = diag::resilience_decl_unavailable;
180186
if (downgradeToWarning == DowngradeToWarning::Yes)
181187
diagID = diag::resilience_decl_unavailable_warn;

trunk/test/attr/attr_inlinable_typealias.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ private typealias PrivateAlias = Int
55

66
internal typealias InternalAlias = Int
77
// expected-note@-1 {{type alias 'InternalAlias' is not '@usableFromInline' or public}}
8+
// expected-note@-2 * {{type alias 'InternalAlias' is not '@usableFromInline' or public}}
89

910
@usableFromInline typealias UsableFromInlineAlias = Int
1011

@@ -21,3 +22,8 @@ public typealias PublicAlias = Int
2122

2223
_ = PublicAlias.self
2324
}
25+
26+
@inlinable public func localTypealiases() {
27+
typealias LocalAlias = InternalAlias // expected-warning {{type alias 'InternalAlias' is internal and should not be referenced from an '@inlinable' function}}
28+
typealias GenericAlias<T> = (T, InternalAlias) // expected-warning {{type alias 'InternalAlias' is internal and should not be referenced from an '@inlinable' function}}
29+
}

0 commit comments

Comments
 (0)