Skip to content

Replace Reflect Context with Owner #9712

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

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Sep 2, 2020

Replace Reflect.Context with Reflec.Owner and remove it from where it is not needed. The name is changed to be explicit on what this parameter is tracking and to disambiguate with QuoteContext.

Migration tips
Update signatures in TreeMap, TreeAcumulator and TreeTraverser

- override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = {
+ override def traverseTree(tree: Tree)(using Owner): Unit = {

Get the current owner

- Symbol.currentOwner
+ Owner.current.symbol

Update the current owner explicitly in a TreeMap, TreeAcumulator and TreeTraverser

- def localCtx(definition: Definition): Context = definition.symbol.localContext
      ...
      case tree: ValDef =>
-       val ctx = localCtx(tree)
-       given Context = ctx
+       given Owner = Owner.fromSymbol(tree.symbol)
        val tpt1 = transformTypeTree(tree.tpt)
        val rhs1 = tree.rhs.map(x => transformTerm(x))
        ValDef.copy(tree)(tree.name, tpt1, rhs1)

@nicolasstucki nicolasstucki self-assigned this Sep 2, 2020
@nicolasstucki nicolasstucki force-pushed the replace-reflect-contex-with-owner branch from d6388cd to 05d2929 Compare September 3, 2020 08:35
@nicolasstucki
Copy link
Contributor Author

test performance with #quotes please

@dottybot
Copy link
Member

dottybot commented Sep 3, 2020

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

@dottybot
Copy link
Member

dottybot commented Sep 3, 2020

Performance test finished successfully:

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

Benchmarks is based on merging with master (5ea8694)

@nicolasstucki nicolasstucki force-pushed the replace-reflect-contex-with-owner branch 4 times, most recently from ae76553 to 5d0950f Compare September 7, 2020 07:51
@nicolasstucki
Copy link
Contributor Author

test performance with #quotes please

@nicolasstucki nicolasstucki marked this pull request as ready for review September 7, 2020 12:05
@dottybot
Copy link
Member

dottybot commented Sep 7, 2020

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

@dottybot
Copy link
Member

dottybot commented Sep 7, 2020

Performance test finished successfully:

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

Benchmarks is based on merging with master (d11e137)

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

I'm not sure about Owner as a type on its own. Conceptually, ownership is a relation, not an entity. There is a worry that we create entities unnecessarily (Occam's razor).

@nicolasstucki
Copy link
Contributor Author

What name would you suggest?

@liufengyun
Copy link
Contributor

Can it just be Context or QuoteContext? For extensibility, Context seems to be much better than Owner: we can always add more things in a context, but not in Owner.

@nicolasstucki
Copy link
Contributor Author

The issue is that this is not the context, the QuoteContex is the context.

@nicolasstucki nicolasstucki force-pushed the replace-reflect-contex-with-owner branch from 5d0950f to b99adbc Compare September 14, 2020 07: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.

3 participants