-
Notifications
You must be signed in to change notification settings - Fork 200
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
feat(compiler): access modifiers #4133
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Console preview environment is available at https://wing-console-pr-4133.fly.dev 🚀 Updated (UTC): 2023-09-15 18:12 |
yoav-steinberg
commented
Sep 10, 2023
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Closed
yoav-steinberg
added
the
🚧 pr/do-not-merge
PRs with this label will not be automatically merged by mergify.
label
Sep 14, 2023
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
yoav-steinberg
removed
🚧 pr/do-not-merge
PRs with this label will not be automatically merged by mergify.
⚠️ pr/review-mutation
PR has been mutated and will not auto-merge. Clear this label if the changes look good!
labels
Sep 14, 2023
Chriscbr
approved these changes
Sep 15, 2023
Thanks for contributing, @yoav-steinberg! This PR will now be added to the merge queue, or immediately merged if |
14 tasks
Congrats! 🚀 This was released in Wing 0.30.9. |
skorfmann
added a commit
to winglang/examples
that referenced
this pull request
Sep 19, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #108
This PR adds
public
andprotected
support to class members and while doing so makes all other members private by default. It also verifies interface method implementations must bepublic
. It also includes support for JSII access modifiers. To get this working I did the following refactors:SymbolEnv
and instead added akind
field distinguishing between 3 types of environments: a simple code block (Scope
) a function/method/closure environemt (Function
) and an environment used to store members of a type (Type
). This was primarily needed so I can use the result of a symbol env lookup to figure out in what ancestor class a given member was defined. The added benefit was code clarity and sanity checks which, btw, found a non-related bug in super constructor type checking (see below). One piece of such clarity was the long awaited removal ofreturn_type
fromSymbolEnv
.ContextVisitor
which I needed to add to theTypeChecker
. Here I removed the requirement to store theinit_env
inpush_class
which didn't make sense, and is probably a leftover of some iteration on our lifting code. I also cleaned up thepush_method
code to make more sense and now it's a more generalpush_function
stack with a helper for when we're just interested in methods.VisitorWithContext
trait, for easy "push -> do stuff or even return -> pop" pattern. Specifically I needed theTypeChecker
to push function definitions and current statement safely.VisitorContext
inTypeChecker
to track context so I know in what class I am for access modifier checking. This approach also provides a better way of tracking the currentreturn_type
so I could remove it from the env. This also removed all sorts of dirt from theTypeChecker
struct (likein_json
, etc.).type_check_statement
method was getting way to big, so I moved the contents of its match statements into separate methods.SymbolEnv
s detected that we're creating a weird env intype_check_super_constructor_against_parent_initializer
. I removed a large bunch of code there that didn't seem correct to me.get_property_from_class_like
(<= this is where you want to look). This way I avoid cascading errors and "unhydrated" classes. To make this work for all cases I updatedresolve_referece
for static type references to also use this method instead of doing its own thing. I think this is cleaner.Still left and possible candidate for followup PRs:
public
for types (export types from module) -> out of scope, will be handled added by our module system.public
fields: tracking issue consider removing support forpublic
class fields #4180internal
: tracking issueinternal
access modifier #4156Checklist
pr/e2e-full
label if this feature requires end-to-end testingBy submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.