-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix regression with lazy properties and add another test case [4.0] #10911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix regression with lazy properties and add another test case [4.0] #10911
Conversation
@swift-ci Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This is failing in ASan unfortunately. I'll have a corrected version soon. |
…ymous closure parameters Even if we don't apply the solution, we still end up writing types into ParamDecls of closures contained the expression. Make sure this is idempotent by disabling 'cleanup', which avoids setting them to ErrorTypes, and teaching ExprCleaner to clear out types of VarDecls. This is a hack that will get better once the constraint system type map stuff is further along. Fixes <rdar://problem/33219081>.
Due to a serendipitous confluence of interesting behaviors, Swift 3 allowed you to define a lazy property with an IUO type, and setting the property to nil would 'reset' it, re-evaluating the lazy getter the next time the property was accessed. This was not intended behavior and it no longer works, so add a test that it no longer works. Fixes <rdar://problem/32687168> and <https://bugs.swift.org/browse/SR-5172>.
9365ada
to
a12b3f8
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
Build failed |
There are two "RAII cleaners" here: - CleanupIllFormedExpressionRAII cleans up the Expr in its final state - ExprCleanser walks the Expr before it is mutated and collects sub-expressions, then cleans those up after The subtle difference comes into play if we started to apply the solution (which can fail, leaving the AST in an inconsistent state) or if preCheckExpression() modified the AST. The latter case was causing an ASan failure because we were not cleaning up type variables in new nodes introduced by preCheckExpression(). Fix this by moving the preCheckExpression() call out of solveForExpression(), so that if solveForExpression() is called with TypeCheckExprFlags::SkipApplyingSolution, we don't mutate the AST at all. Sigh... Fixes <rdar://problem/33277279>.
a12b3f8
to
a0d7055
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Build failed |
Description: When type checking an expression without applying the solution, we would set the types of anonymous closure parameters to ErrorType. This resulted in SILGen crashes because of un-typechecked AST when a lazy property was initialized by an expression containing a closure with anonymous parameters.
Origination: Regression from another set of fixes to 'lazy' in 4.0.
Tested: New test added. Also add another test for an odd behavior with 'lazy' that worked in 3.1 but we don't want to allow anymore. This second part is not really necessary for 4.0 branch, but it's just a new test.
Reviewed by: Pavel Yaskevich (first two patches), Mark Lacey (ASan fix)
Radar: rdar://problem/33219081