File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816
816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817
817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818
818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819
- refs/heads/tensorflow: c109f9058f573f81047f7736fd9b081e8700a5d9
819
+ refs/heads/tensorflow: 1d6af84a639724b0c2cfce45d605c0fe518b3512
820
820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821
821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822
822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2
Original file line number Diff line number Diff line change @@ -645,6 +645,12 @@ void TypeChecker::computeCaptures(AnyFunctionRef AFR) {
645
645
}
646
646
}
647
647
648
+ static bool isLazy (PatternBindingDecl *PBD) {
649
+ if (auto var = PBD->getSingleVar ())
650
+ return var->getAttrs ().hasAttribute <LazyAttr>();
651
+ return false ;
652
+ }
653
+
648
654
void TypeChecker::checkPatternBindingCaptures (NominalTypeDecl *typeDecl) {
649
655
auto &ctx = typeDecl->getASTContext ();
650
656
@@ -669,7 +675,7 @@ void TypeChecker::checkPatternBindingCaptures(NominalTypeDecl *typeDecl) {
669
675
/* ObjC=*/ false );
670
676
init->walk (finder);
671
677
672
- if (finder.getDynamicSelfCaptureLoc ().isValid ()) {
678
+ if (finder.getDynamicSelfCaptureLoc ().isValid () && ! isLazy (PBD) ) {
673
679
ctx.Diags .diagnose (finder.getDynamicSelfCaptureLoc (),
674
680
diag::dynamic_self_stored_property_init);
675
681
}
Original file line number Diff line number Diff line change @@ -253,4 +253,13 @@ class SelfStoredPropertyInit {
253
253
static func myValue( ) -> Int { return 123 }
254
254
255
255
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
+ }
You can’t perform that action at this time.
0 commit comments