Skip to content

Conversation

@slavapestov
Copy link
Contributor

Builds upon #34226.

@slavapestov slavapestov force-pushed the misc-astscope-cleanups branch from b38f7f4 to 09fa595 Compare October 8, 2020 03:33
Copy link
Contributor

@davidungar davidungar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Worth landing ASAP. Take my comments as fodder for any subsequent PRs you want to do.

Comment on lines 821 to 875
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see the assertion here! A couple of thoughts:

  1. A lambda inside the function vs a separate function:
    In favor of the lambda is that it is only called here. In favor of a separate function is that addMemberSilently would be a bit more readable without the lambda in the middle. Also the data flow into checkSourceRange gets clearer when forced to pass in data explicitly. (Obviously I lean towards the latter.)

  2. Does it make sense to generalize the order checking to any Decl? The details would be different for brace statements, but it would be nice to reify the commonality of needing source ranges to be ordered.

BTW, great to check the invariant right at the insertion point!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think some "why" comments could help here. Why check the ranges? Why skip over vars, enums, etc.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add some more comments, thanks.

I'll also see about adding a similar assertion to SourceFile::addTopLevelDecl() and BraceStmt::setBody() (and hopefully share code), but I'll do that in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you.

@slavapestov slavapestov force-pushed the misc-astscope-cleanups branch from 09fa595 to 4b0d39c Compare October 8, 2020 20:17
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test Linux

@slavapestov
Copy link
Contributor Author

@swift-ci Please clean smoke test Linux

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test Linux

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit b13ce50 into swiftlang:main Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants