-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[SR-9795] Cannot use super
in lazy property: 'super' cannot be used outside of class members
#52220
Comments
Hm, I guess not. @slavapestov, can you think of a reason this would be disallowed after we allowed |
It's just not implemented yet. Should be easy to fix; I suspect there's just an "is self of class method" check somewhere we need to generalize. Tagging as a starter bug |
It seems to be happening inside `getImplicitSelfDeclForSuperContext()` because the `getInnermostMethodContext` returns nil (makes sense because the inner most context seems to be an `AbstractClosureExpr`). If you try dumping the decl context, it crashes. I've sort of got it working by creating an implicit self decl from the innermost type context, but it crashes in CSGen, maybe because of the same reason it crashes in the parser. |
The lazy initializer is type checked inside an Initializer context. It already has a self decl. |
See `PatternBindingInitializer::getImplicitSelfDecl()` |
Yes, I was trying to creating a `PatternBindingInitializer` earlier but ` getImplicitSelfDecl()` actually causes a crash in `getNumPatternEntries`. |
Where'd you leave off with this one, @theblixguy? |
Might be worth giving this another shot – the lazy lowering code is a bit cleaner now, and things happen in requests so at least in theory it should be easier to get the ordering dependencies sorted out. |
IIRC ` getImplicitSelfDecl` didn't work in that context so had to synthesise one and then tweak the constraint solver, but ended up with a crash in SILGen. I'll give it another try and put up a PR - maybe things have improved now. |
It shouldn't require synthesizing anything new. 'super' is just a different way of writing 'self' and the fact that it doesn't work in all the places that 'self' works indicates there is some simplification that can be done. |
Hello. Is this issue available to be picked up? Where do i start with it? :) |
I am also have the same question. Because I could not understand the first
tour. Who or where could I ask for helping on dropping "dxxplet" and "land
safely"?
The biggest issue for me is the communication /connection seems offline?
「Alexey Ivashko ***@***.***>」在 2022年5月11日 週三,19:25 寫道:
Hello. Is this issue available to be picked up? Where do i start with it?
:)
—
Reply to this email directly, view it on GitHub
<#52220 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/APHMPZSGS7LBTA2BGXFENHTVJOKIZANCNFSM5VUSYQGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
<Sent from ***@***.***>
|
Environment
Tested with Swift 4.2.1 (Xcode 10.1) and Swift 5 from Xcode 10.2 beta (swiftlang-1001.0.45.7 clang-1001.0.37.7).
Additional Detail from JIRA
md5: 75741cacf781b9db21044152b379d272
Issue Description:
I’m not sure this is a bug or if this works as expected:
Is there a good reason why
super
isn’t permitted here? Replacingsuper
withself
works fine, as I’d expect because the instance must be fully initialized whenlazy
properties are accessed.The text was updated successfully, but these errors were encountered: