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

Enable -Ycheck-init on community projects and CI #11385

Merged
merged 16 commits into from
Feb 25, 2021

Conversation

liufengyun
Copy link
Contributor

  • Enable -Ycheck-init on community projects and CI
  • Code refactorying

Cherry-picked from #10627

@liufengyun
Copy link
Contributor Author

liufengyun commented Feb 12, 2021

@nicolasstucki Could you have a look at the last commit a98d42a?

@liufengyun liufengyun force-pushed the safe-object-init3 branch 3 times, most recently from ec47a70 to 3ee75fb Compare February 12, 2021 20:20
}
else {
state.visited = state.visited + eff
val state2: State = state.copy(path = state.path :+ eff.source)
Copy link
Contributor

Choose a reason for hiding this comment

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

In Scala when you copy are the mutable.Sets shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the other fields take previous values, so they are shared.

@@ -163,26 +155,29 @@ object Potentials {

extension (pot: Potential) def toPots: Potentials = Potentials.empty + pot

extension (ps: Potentials) def select (symbol: Symbol, source: Tree)(using Context): Summary =
ps.foldLeft(Summary.empty) { case ((pots, effs), pot) =>
extension (ps: Potentials) def select (symbol: Symbol, source: Tree, selectEffect: Boolean = true)(using Context): Summary =
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really get selectEffect's purpose... :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed we need a better name for that and add some documentation. It's used in potential expansion (selectEffect = false), where we don't want to trigger a duplicate method call or field access effect.

assert(member.owner == currentClass, "owner = " + member.owner.show + ", current = " + currentClass.show)
summaryCache(member) = summary
}
case class Summary(pots: Potentials, effs: Effects) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between object and case class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we use explicit class for Summary, instead of putting them in a tuple (Potentials, Effects). The former is expected to be more maintainable.

@natsukagami
Copy link
Contributor

natsukagami commented Feb 16, 2021

I think the rest are just converting from old code to new structure, so nothing much I could say...

@liufengyun
Copy link
Contributor Author

test performance please

@dottybot
Copy link
Member

performance test scheduled: 2 job(s) in queue, 1 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/11385/ to see the changes.

Benchmarks is based on merging with master (4d08ccd)

@liufengyun
Copy link
Contributor Author

liufengyun commented Feb 23, 2021

@natsukagami I've addressed your comments. If it looks good to you, please approve so that we can move forward (unfortunately I cannot approve my own PR).

- Make summary a proper class
- Rename isInternal to hasSource
- Refactor: remove useless parameter
- Split effect check into multiple methods
- Refactor ignored methods handling
  Ignore constructor call on Any, Object and AnyVal
- Fix missing return
Handle NoPrefix properly
Otherwise, looking up members will crash the compiler
The owners are different for the patches, and they are always safe.
Shapeless enabled `-Xfatal-warings`, the warnings make the CI fail.
In the following test:

- tests/pos/i3130b.scala

If we add `transparent`, then everything is OK.
The reason is that we set `Symbol.defTree` systematically
in PostTyper. Now the inlining happens after PostTyper,
thus `defTree` is not properly set for inlined definitions.

To compensate, we ensure that `defTree` is set in the ReTyper.
The IninerTyper extends ReTyper, thus it fixes the problem.
Doing the fix directly in InlinerTyper, however, does not pass
the CI. The reason is that `-Ycheck:all` will run `TreeChecker`
which will make tree bindings get lost.
cats enables -Xfatal-warnings and we don't want to change the library
to create conflicts with upstream.
To avoid unnecessary conflicts, we disable -Ycheck-init on shapeless.
@liufengyun
Copy link
Contributor Author

rebased due to conflicts in project.scala.

@liufengyun
Copy link
Contributor Author

Merge now to avoid conflicts and make it easier for the work on initialization.
We will address the Symbol.defTree in another PR if there is a better way.

@liufengyun liufengyun merged commit 79ba06c into scala:master Feb 25, 2021
@liufengyun liufengyun deleted the safe-object-init3 branch February 25, 2021 16:19
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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

6 participants