Skip to content

Topic/info transforms #72

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

Closed
wants to merge 5 commits into from
Closed

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 15, 2014

Reworked support for denotation transformers. See last commit message for how to verify usage.

I apologize for the somewhat chaotic commit contents. I tried to reorganize the commits but could not do it with reasonable effort.

odersky added 4 commits March 14, 2014 21:49
This makes naming uniform between trees and types, and also avoids the clash with
transform.TreeTransformer. The idea is that transformers are parts of phases, and
have logic that is phase-specific. In particular, a context is passed around when
transforming a tree. Maps are simpler, they only have a T -> T apply method.
To bring in line with TreeTransformer terminology.
Many small and large changes. Added samplePhase to demonstrate functionality.

To test functioning, run the compiler with args

     tests/pos/uncurry.scala -Ylog:sample,terminal
@odersky
Copy link
Contributor Author

odersky commented Mar 15, 2014

@review by @DarkDimius @gzm0

@@ -22,7 +22,7 @@ class CreateCompanionObjectsTest extends DottyTest {

import tpd._

@Test
//@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you disable those tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A mistake. The tests are now re-enabled again.

CreateCompanionObjectTests were re-enabled. They failed in a previous version but succeed again in the latest commit.
Also uncurry.scala got renamed to curried.scala.

def changeOwner(from: Symbol, to: Symbol)(implicit ctx: Context): ThisTree =
new TreeMapper(ownerMap = (sym => if (sym == from) to else sym)).apply(tree)
new TreeTypeMap(ownerMap = (sym => if (sym == from) to else sym)).apply(tree)
Copy link
Member

Choose a reason for hiding this comment

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

I love the fact that changeOwner is exposed on Tree, rather than on Symbol. We have some terrible bugs in scalac whereby speculative typechecking (e.g names/defaults) changes the owner of a symbol before bailing out, which breaks the immutability of Trees.

Copy link

Choose a reason for hiding this comment

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

How does this work? Does this create new symbols for deftrees whose owners need to be changed?

Copy link
Member

Choose a reason for hiding this comment

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

@DarkDimius
Copy link
Contributor

Just a note for anybody wondering: the question of "what should be done if multiple TreeTransforms in same phase want to register a DenotTransformer?" remains uncovered here.

@@ -515,8 +517,8 @@ object Denotations {
} else {
// not found, cur points to highest existing variant
var startPid = cur.validFor.lastPhaseId + 1
val transformers = ctx.transformersFor(cur)
val transformer = transformers.nextTransformer(startPid)
val transformer = ctx.phases(startPid - 1).asInstanceOf[DenotTransformer]
Copy link
Contributor

Choose a reason for hiding this comment

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

If first phase doesn't implement DenotTransformer this line throws exception

@DarkDimius
Copy link
Contributor

Result of discussion regarding relationships between DenotTransformers and TreeTransformers: every TreeTransform(miniphase) is promoted to a phase in terms of periods: it will have its own period and can register a DenotTransformer.

@DarkDimius
Copy link
Contributor

I will work on implementing this, after factoring out xml

@DarkDimius
Copy link
Contributor

Merged as part of #81

@DarkDimius DarkDimius closed this Mar 20, 2014
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request Mar 19, 2025
Backport "Fix provablyDisjoint handling enum constants with mixins" to 3.3 LTS
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.

5 participants