File tree Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -2478,11 +2478,11 @@ namespace {
2478
2478
}
2479
2479
2480
2480
Type visitDefaultArgumentExpr (DefaultArgumentExpr *expr) {
2481
- llvm_unreachable ( " Already type checked " );
2481
+ return expr-> getType ( );
2482
2482
}
2483
2483
2484
2484
Type visitCallerDefaultArgumentExpr (CallerDefaultArgumentExpr *expr) {
2485
- llvm_unreachable ( " Already type checked " );
2485
+ return expr-> getType ( );
2486
2486
}
2487
2487
2488
2488
Type visitApplyExpr (ApplyExpr *expr) {
Original file line number Diff line number Diff line change @@ -2880,6 +2880,9 @@ ConstraintSystem::getArgumentInfoLocator(ConstraintLocator *locator) {
2880
2880
2881
2881
Optional<ConstraintSystem::ArgumentInfo>
2882
2882
ConstraintSystem::getArgumentInfo (ConstraintLocator *locator) {
2883
+ if (!locator)
2884
+ return None;
2885
+
2883
2886
if (auto *infoLocator = getArgumentInfoLocator (locator)) {
2884
2887
auto known = ArgumentInfos.find (infoLocator);
2885
2888
if (known != ArgumentInfos.end ())
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