diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index 3ea939cd33d76..065a3ed85ee41 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -58,26 +58,6 @@ using namespace swift; #define DEBUG_TYPE "TypeCheckStmt" -#ifndef NDEBUG -/// Determine whether the given context is for the backing property of a -/// property wrapper. -static bool isPropertyWrapperBackingInitContext(DeclContext *dc) { - auto initContext = dyn_cast(dc); - if (!initContext) return false; - - auto patternInitContext = dyn_cast(initContext); - if (!patternInitContext) return false; - - auto binding = patternInitContext->getBinding(); - if (!binding) return false; - - auto singleVar = binding->getSingleVar(); - if (!singleVar) return false; - - return singleVar->getOriginalWrappedProperty() != nullptr; -} -#endif - namespace { class ContextualizeClosures : public ASTWalker { DeclContext *ParentDC; @@ -129,20 +109,7 @@ namespace { // Explicit closures start their own sequence. if (auto CE = dyn_cast(E)) { - // In the repl, the parent top-level context may have been re-written. - if (CE->getParent() != ParentDC) { - if ((CE->getParent()->getContextKind() != - ParentDC->getContextKind()) || - ParentDC->getContextKind() != DeclContextKind::TopLevelCodeDecl) { - // If a closure is nested within an auto closure, we'll need to update - // its parent to the auto closure parent. - assert((ParentDC->getContextKind() == - DeclContextKind::AbstractClosureExpr || - isPropertyWrapperBackingInitContext(ParentDC)) && - "Incorrect parent decl context for closure"); - CE->setParent(ParentDC); - } - } + CE->setParent(ParentDC); // If the closure was type checked within its enclosing context, // we need to walk into it with a new sequence. diff --git a/test/SILGen/lazy_locals.swift b/test/SILGen/lazy_locals.swift index ce007d584dd56..3681d7a909f9d 100644 --- a/test/SILGen/lazy_locals.swift +++ b/test/SILGen/lazy_locals.swift @@ -36,4 +36,10 @@ func generic(x: T) -> T { return z } -// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s11lazy_locals7generic1xxx_tlF1zL_xvg : $@convention(thin) (@guaranteed <τ_0_0> { var Optional<τ_0_0> } , @in_guaranteed T) -> @out T { \ No newline at end of file +// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s11lazy_locals7generic1xxx_tlF1zL_xvg : $@convention(thin) (@guaranteed <τ_0_0> { var Optional<τ_0_0> } , @in_guaranteed T) -> @out T { + +func lazyLocalWithNestedClosure() { + lazy var x = { + return 3 + }() +}