Skip to content

Drop modifiers #1539

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 4 commits into from
Sep 30, 2016
Merged

Drop modifiers #1539

merged 4 commits into from
Sep 30, 2016

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 26, 2016

The end goal of this PR is to get rid of the Modifiers structure and to represent each modifier as a tree of its own. This is more IDE friendly and simplifies treatment of trees.

@DarkDimius can you comment on this? Also, have a look at my comments in BackendInterface which require action.

Prefer to access directly via symbol.
@@ -944,7 +944,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
}

object ValDef extends ValDefDeconstructor {
def _1: Modifiers = field.mods
def _1: Modifiers = tpd.Modifiers(field.symbol)
Copy link
Contributor Author

@odersky odersky Sep 26, 2016

Choose a reason for hiding this comment

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

@DarkDimius Note that modifiers will be re-created as a new object everytime _1 is called. Is it possible to split the _1 accessor into two accessors, one for flags and another for annotations? If not, an alternative would be to let Symbol inherit from Modifiers.

Copy link

Choose a reason for hiding this comment

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

Do you also plan to retain original positions of modifiers as written in the source file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the parse-trees yes. But these are not preserved in typed trees or TASTY.

Copy link
Contributor

Choose a reason for hiding this comment

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

Grepping the source code it seems that _1 is never used. Try returning null to ensure it?

@@ -249,17 +249,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
/** Is this case guarded? */
def isGuardedCase(cdef: CaseDef) = cdef.guard ne EmptyTree

/** True iff definition is a val or def with no right-hand-side, or it
* is an abstract typoe declaration
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function was unused, superseded by NavigateAST.

Backend does not need them after all, can just use nulls there.
So the functionality is only used for printing, and it makes
sense to move everything there.
@odersky
Copy link
Contributor Author

odersky commented Sep 26, 2016

/rebuild

The typed variant is no longer needed. This means modifiers can safely be
ignored in typed trees if we so choose.
That way it can be accessed by other parts which deal with
error messages.
@felixmulder
Copy link
Contributor

/rebuild

@felixmulder
Copy link
Contributor

I tried this locally and everything seems to be fine. I'll try to rebuild this again.

@felixmulder
Copy link
Contributor

/rebuild

@DarkDimius
Copy link
Contributor

LGTM

@DarkDimius DarkDimius merged commit 93d4c8c into scala:master Sep 30, 2016
@allanrenucci allanrenucci deleted the drop-modifiers branch December 14, 2017 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants