Skip to content
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

InternalTrees: require origin dialect in tokens #3498

Merged
merged 1 commit into from Jan 15, 2024

Conversation

kitbellew
Copy link
Contributor

That way, we will not incur hidden syntax-generation and tokenization costs implicitly; for that, we have the tokenizeFor method.

@kitbellew
Copy link
Contributor Author

@tgodzik @bjaglin this change removes the implicit dialect parameter from the Tree.tokens call, so it seems to be source-compatible even if not binary, and should be a reasonable change to include when updating the minor version.

@@ -15,7 +15,7 @@ import scala.{meta => sm}
def children: List[Tree]

def pos: Position
def tokens(implicit dialect: Dialect): Tokens
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could cause issues still, so maybe instead we should just ignore the dialect and deprecate the method? We could have a separate parameterless one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

meaning, still keep the parameter but throw it origin doesn't have it?

what issues could be caused, btw?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we have a library depending on a certain version of Scalameta (for example Ammonite) and someone brings in the newest one then in case someone uses tokens method it will throw since the earlier version of the method doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but then if we're planning to increment the minor version of scalameta, aren't we allowed to make binary-incompatible changes as long as they are source-compatible? wouldn't that hypothetical library be expected to be updated for newer scalameta? there must be some process to make these changes occasionally.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it source compatible? If the parameter is set explicitly then it will break users code. I also don't think we semantic versioning says anything about source or binary.

there must be some process to make these changes occasionally.

Some libraries just do a lot of major versions, but it's problematic in case of scalameta.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting enough I can't find anything about scalameta usage in Ammonite anymore, so maybe changing tokens would ok?

Anyway, I am just being super cautious here, might not be worth the trouble to keep tokens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now, did you what you suggested. if you find that dropping the parameter is also ok, we'll include that in a subsequent pr.

didn't understand your point about "not worth the trouble to keep tokens".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as to passing dialect as parameter: i did this search: https://github.com/search?q=%22.tokens%28%22++language%3AScala+%22scala.meta%22+NOT+is%3Afork&type=code

i saw two or three cases. i guess i need to add the method without that parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for checking!

not worth the trouble to keep tokens

Ignore me, I hadn't had too much sleep at that point in time 😅

For now, keep the implicit dialect parameter for backwards-compatibility
but ignore it. Throw if no dialect is available through origin.

That way, we will not incur hidden syntax-generation and tokenization
costs implicitly; for that, we have the `tokenizeFor` method.
@kitbellew kitbellew merged commit c5bf437 into scalameta:main Jan 15, 2024
24 checks passed
@kitbellew kitbellew deleted the 3498 branch January 15, 2024 21:32
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.

None yet

2 participants