Skip to content

Generalize RefTypes #3087

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 146 commits into from
Sep 22, 2017
Merged

Generalize RefTypes #3087

merged 146 commits into from
Sep 22, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 8, 2017

Based on #3061.

The aim of this PR is to eliminate the various subtypes of TermRef and TypeRef and replace them by generalizing Name Name/Signature and Symbol to a new concept of Designator.

The expected benefits of doing this are:

  • Drop the kludgey way we deal with "shadowed names" by making all private references symbolic
  • Allow to eliminate TypeArgRefs

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Commit Messages

We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).

Please stick to these guidelines for commit messages:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Added" instead of "Add")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

@odersky odersky force-pushed the change-termref branch 8 times, most recently from 48231de to 0b4b689 Compare September 13, 2017 09:22
@odersky
Copy link
Contributor Author

odersky commented Sep 13, 2017

test performance please

@dottybot
Copy link
Member

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

@dottybot
Copy link
Member

performance test failed:

[check /data/workspace/bench/logs/pull-3087-09-13-14.05.out for more information]

@odersky
Copy link
Contributor Author

odersky commented Sep 13, 2017

test performance please

@dottybot
Copy link
Member

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

@liufengyun
Copy link
Contributor

@odersky I just checked the logs, compiling of dotty project succeeds, but compilation of the scala-library project throws exception.

@smarter
Copy link
Member

smarter commented Sep 13, 2017

@lihaoyi Oh, the scala-library in the benchmarks is not the same as the one from the submodule? I think that would make more sense.

@dottybot
Copy link
Member

performance test failed:

[check /data/workspace/bench/logs/pull-3087-09-13-16.55.out for more information]

@liufengyun
Copy link
Contributor

@smarter Exactly, it's not the same scala-library in the Dotty repo. It's intentionally made to be not the same, as the Dotty scala-library is growing, and we want a subset of stdlib that could be compiled since last october.

@odersky
Copy link
Contributor Author

odersky commented Sep 14, 2017

test performance please

@dottybot
Copy link
Member

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

@dottybot
Copy link
Member

Performance test finished successfully:

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

Benchmarks is based on merge(s) with master

AppliedType will be used for all type applications, higher-kinded
or not. That is, eventually, it will replace HKApply and also the
encodings of type applications as refined types.

This commit introduces AppliedType and adapts baseType computations
to take it into account. AppliedType is not yet constructed anywhere,
however.
So far, everything up to parents is adapted to new scheme. Parents is half done;
needs more work once we change layour of ClassInfo.
Simplifies usage and removes some obscure code in Types
Systematically introduce handlers for AppliedTypes where there
was a handler for HKApply.
Also, change asSeenFrom to use it for arguments
    withfixedSym -> apply

It's just apply with a different designator

    apply(Type, Symbol) -> withSym

This one contains special cases.
Make nonMemberTermRef redundant by marking local dummies
and import symbols as Fresh (i.e. they are non-members).
Also

 - rename Fresh flag to NonMember
 - update criterion for phases where refs are symbolic. This used
   to be just before erasure (at resolveSuper) but then other phases
   were inserted after resolveSuper and the test became outdated. It's
   more robust now.
 - drop withSym
 - rename withSymAndName to another apply
 - streamline select methods
To do this, we needed a more robust version of Symbol#signature.
Also, drop signature parameter in TermRef.withSigAndDenot
Also, drop signature parameter in TermRef.withSigAndDenot
The exception previously made for Scala2 innner classes causes the benchmark
library project to fail with in the tree type map FullParameterization when
called from LinkScala2Impl. It's not necessary to make the special case there
because the Scalq2Unpickler will create anyway symbolic references to such
inner classes.
import Names._

/** Defines a common superclass of Name and Symbol and its Term/Type variants
* Designators are used in reference type to identity what is referred to.
Copy link
Member

Choose a reason for hiding this comment

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

typo: identity -> identify

Here _lifting_ a type `S` means replacing all references to abstract types
in covariant positions of `S` by their upper bound, and to replacing
all refinement types in in covariant positions of `S` by their parent.
The purpose if lifte
Copy link
Member

Choose a reason for hiding this comment

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

Sentence wasn't finished.

It allows us to drop the additional name field in most cases and
the methods become easier to discover.
@@ -1921,7 +1919,10 @@ object Types {
* the public name.
*/
def shadowed(implicit ctx: Context): NamedType =
NamedType(prefix, designatorName.derived(ShadowedName))
designator match {
case designator: Symbol => this
Copy link
Member

Choose a reason for hiding this comment

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

Is this case ever reached? It doesn't really seem to make sense.

}
else if (tpe.hasFixedSym) {
assert(tpe.symbol.isClass && tpe.symbol.is(Flags.Scala2x), tpe.symbol.showLocated)
writeByte(TYPEREF) // should be changed to a new entry that keeps track of prefix, symbol & owner
Copy link
Member

Choose a reason for hiding this comment

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

Is this still a TODO?

@odersky
Copy link
Contributor Author

odersky commented Sep 21, 2017

Withdrawn in favor of #3147

@odersky odersky closed this Sep 21, 2017
@odersky odersky mentioned this pull request Sep 22, 2017
@odersky odersky reopened this Sep 22, 2017
@odersky odersky changed the title [WIP] Generalize RefTypes Generalize RefTypes Sep 22, 2017
@odersky odersky merged commit 78e80c8 into scala:master Sep 22, 2017
@allanrenucci allanrenucci deleted the change-termref 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants