Skip to content

Apply refactorings blocked previously #6791

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

Merged
merged 9 commits into from
Jul 4, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 2, 2019

Apply refactorings that were not possible before because bootstrap compiler
had problems with them.

odersky added 7 commits July 2, 2019 16:57
Apply refactorings that were not possible before because bootstrap compiler
had problems with them.
This is necessary so that enum constants come with the class not the companion object
which was in turn necessary to let the bootstrapped build pass.

Two questions:
1) It seems the bootstrapped build got confused. It seemed it compiled against the
previous ErrorMesssageID.java and ran against the ErrorMessageID.scala.
2) In any case, it would be good if enum constants were always generated at the
same place, no matter whether we extend java.lang.Enum or not.
Allow use of `result` instead of having to pass a lambda.
// DOTTY TODO: replace previous 2 lines with
// export opaques.FlagSet
// once 0.17 is released and #6721 is in the bootstrap
export opaques.FlagSet

type Flag = opaques.Flag
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this also be exported?

Copy link
Contributor Author

@odersky odersky Jul 4, 2019

Choose a reason for hiding this comment

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

export opaques.Flag would also export the def Flag, rendering it public. This is not what we want.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that method not defined as private? What happens when you export a private method?

Copy link
Contributor

Choose a reason for hiding this comment

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

Even though it is private[Flags] and is exported into Flags object, this is technically fine with the contract of the private[Flags](namely that it should not be exposed outside Flags). If we don't want it in Flags either, shouldn't it be private[opaques]?

Copy link
Contributor

Choose a reason for hiding this comment

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

(except that we're using it in Flags, e.g. in newFlags:

opaques.Flag(KINDFLAGS | bits), opaques.Flag(TERMS | bits), opaques.Flag(TYPES | bits)

This would have been simplified if we exported the method)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An exported member is always public.

Copy link
Contributor

Choose a reason for hiding this comment

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

That does create problems when doing export x._. It can well become an antipattern as you must now be concerned with the private details of the implementation of x to do the export correctly. I don't know of any other case where this insight into private members would be required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An export only exports members that are visible at the point of export. But then the forwarders become public. I think that's the right tradeoff.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that makes sense

odersky added 2 commits July 4, 2019 16:31
We can't have WrappedResult in tools itself, since that gives a CyclicReference
error in some situations. Specifically, if tools.WrappedResult is compiled first,
we complete its paackage,
which means we complete tools/package.scala
which means we enter its members
which means we process the WrappedResult export
which means we complete WrappedResult
which gives a CyclicReference

An alternative fix would be to avoid the export and use explicit forwarders instead.
This allows us to put WrappedResult directly in the tools package object.
@odersky odersky merged commit cbc69fd into scala:master Jul 4, 2019
@liufengyun liufengyun deleted the refactor-dotc branch July 4, 2019 22:43
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