Skip to content

Commit 1c7ee64

Browse files
committed
---
yaml --- r: 347503 b: refs/heads/master c: ccc0e92 h: refs/heads/master i: 347501: 69b87e8 347499: 18129f9 347495: c4dd14e 347487: 2c7c3a6
1 parent 977301e commit 1c7ee64

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-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: d491d2933ac9e682504bf9b319f3ea667c97937a
2+
refs/heads/master: ccc0e921ac3545e9ae9fb45df9d6d5ca5bdf239c
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/SILOptimizer/Mandatory/DiagnoseInvalidEscapingCaptures.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,26 @@ static void checkPartialApply(ASTContext &Context, DeclContext *DC,
329329
}
330330
}
331331

332+
// Enforce exclusivity restrictions on recursive uses of non-escaping closures.
333+
// Exclusivity requires a Non-Escaping Recursion Restriction rule (SE-0176):
334+
// A non-escaping closure A may not be recursively invoked during the
335+
// execution of a non-escaping closure B which captures the same local
336+
// variable or inout parameter unless:
337+
// - A is defined within B or
338+
// - A is a local function declaration which is referenced directly by B.
339+
//
340+
// This is conservatively approximated with a Non-Escaping Parameter Call
341+
// Restriction rule (NPCR), as implemented below:
342+
// A function may not call a non-escaping function parameter passing a
343+
// non-escaping function parameter as an argument.
344+
// For the purposes of this rule, a closure which captures a non-escaping
345+
// function parameter is treated the same as the parameter.
346+
//
347+
// Note: The compiler does not enforce recursion via
348+
// withoutActuallyEscaping. This undefined behavior is exposed to programmers.
349+
//
350+
// TODO: Verify that all uses of noescaping function arguments are SIL patterns
351+
// that are recognized below to prove that this diagnostic is complete.
332352
static void checkApply(ASTContext &Context, FullApplySite site) {
333353
auto isNoEscapeParam = [&](SILValue value) -> const ParamDecl * {
334354
// If the value is an escaping, do not enforce any restrictions.

trunk/test/Generics/non_generic_derived_class.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ class Base<T> {
99
class Derived : Base<Int> {}
1010

1111
var a = Derived.f(42)
12+
13+
protocol SR9160_EmptyProtocol {}
14+
class SR9160_AbstractFoobar<Foo> {}
15+
// This used to cause the swift compiler to never finish compiling.
16+
final class SR9160_SomeFoobar: SR9160_AbstractFoobar<SR9160_SomeFoobar.Foo> {
17+
enum Foo: SR9160_EmptyProtocol {}
18+
}

0 commit comments

Comments
 (0)