Skip to content

REPL: do not dealias before printing types #3566

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 2 commits into from
Nov 30, 2017

Conversation

smarter
Copy link
Member

@smarter smarter commented Nov 27, 2017

Also simplify the mechanism used to avoid printing prefixes. This is now
handled in the PlainPrinter and limited to List, Map, Set, Seq.

@smarter smarter requested a review from odersky November 27, 2017 16:47
@smarter smarter force-pushed the fix-repl-alias branch 2 times, most recently from 471711c to 4daf3a0 Compare November 27, 2017 17:37
scala> Seq('a','b')
val res2: Seq[Char] = List(a, b)
scala> Set(4, 5)
val res6: Set[Int] = Set(4, 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be res3

@smarter smarter force-pushed the fix-repl-alias branch 2 times, most recently from 5968d96 to 0c13af0 Compare November 27, 2017 22:26
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Otherwise looks good.

@@ -357,9 +357,16 @@ class Definitions {
def newGenericArrayMethod(implicit ctx: Context) = DottyArraysModule.requiredMethod("newGenericArray")
def newArrayMethod(implicit ctx: Context) = DottyArraysModule.requiredMethod("newArray")

lazy val ListType = ctx.requiredClassRef("scala.collection.immutable.List")
def ListClass = ListType.symbol.asClass
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks wrong. Don't we need to pass a context to ListClass, like we do everywhere else? (same for the other new definitions)

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, fixed.

@@ -147,7 +152,12 @@ class PlainPrinter(_ctx: Context) extends Printer {
case tp: TermRef if tp.denot.isOverloaded =>
"<overloaded " ~ toTextRef(tp) ~ ">"
case tp: TypeRef =>
toTextPrefix(tp.prefix) ~ selectionString(tp)
printWithoutPrefix.find(sym => tp.isDirectRef(sym)) match {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer not to hard-code these. Can't we instead check when printing whether a class has an alias in Predef or scala with the same name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly, but that would be more expensive and may require forcing things.

@smarter smarter force-pushed the fix-repl-alias branch 3 times, most recently from db6d057 to 18c55d3 Compare November 30, 2017 14:14
@smarter
Copy link
Member Author

smarter commented Nov 30, 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/3566/ to see the changes.

Benchmarks is based on merging with master (d929fc9)

Also simplify the mechanism used to avoid printing prefixes. This is now
handled in the PlainPrinter and limited to List, Map, Set, Seq.
…la.Predef

In the previous commit, this was limited to a hardcoded subset of these types.
@smarter smarter merged commit eb2472d into scala:master Nov 30, 2017
@allanrenucci allanrenucci deleted the fix-repl-alias branch December 14, 2017 19:21
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