Skip to content

Commit 3f0aaf4

Browse files
committed
---
yaml --- r: 327633 b: refs/heads/tensorflow c: 1d6af84 h: refs/heads/master i: 327631: 0314dd6
1 parent 580de63 commit 3f0aaf4

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: c109f9058f573f81047f7736fd9b081e8700a5d9
819+
refs/heads/tensorflow: 1d6af84a639724b0c2cfce45d605c0fe518b3512
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/lib/Sema/TypeCheckCaptures.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,12 @@ void TypeChecker::computeCaptures(AnyFunctionRef AFR) {
645645
}
646646
}
647647

648+
static bool isLazy(PatternBindingDecl *PBD) {
649+
if (auto var = PBD->getSingleVar())
650+
return var->getAttrs().hasAttribute<LazyAttr>();
651+
return false;
652+
}
653+
648654
void TypeChecker::checkPatternBindingCaptures(NominalTypeDecl *typeDecl) {
649655
auto &ctx = typeDecl->getASTContext();
650656

@@ -669,7 +675,7 @@ void TypeChecker::checkPatternBindingCaptures(NominalTypeDecl *typeDecl) {
669675
/*ObjC=*/false);
670676
init->walk(finder);
671677

672-
if (finder.getDynamicSelfCaptureLoc().isValid()) {
678+
if (finder.getDynamicSelfCaptureLoc().isValid() && !isLazy(PBD)) {
673679
ctx.Diags.diagnose(finder.getDynamicSelfCaptureLoc(),
674680
diag::dynamic_self_stored_property_init);
675681
}

branches/tensorflow/test/type/self.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,13 @@ class SelfStoredPropertyInit {
253253
static func myValue() -> Int { return 123 }
254254

255255
var value = Self.myValue() // expected-error {{covariant 'Self' type cannot be referenced from a stored property initializer}}
256-
}
256+
}
257+
258+
// rdar://problem/55273931 - erroneously rejecting 'Self' in lazy initializer
259+
class Foo {
260+
static var value: Int = 17
261+
262+
lazy var doubledValue: Int = {
263+
Self.value * 2
264+
}()
265+
}

0 commit comments

Comments
 (0)