Skip to content

inconsistent printing of types #5941

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
scabug opened this issue Jun 18, 2012 · 6 comments
Closed

inconsistent printing of types #5941

scabug opened this issue Jun 18, 2012 · 6 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jun 18, 2012

In my opinion some types have an inconsistent implementation of toString. Some types return only their short names. scala.Product for example returns "Product" instead of "scala.Product".

scala> u.typeOf[scala.Product] 
res31: reflect.runtime.universe.Type = Product // wrong? 

scala> u.typeOf[java.lang.Object] 
res32: reflect.runtime.universe.Type = Object  // wrong? 

scala> u.typeOf[scala.Function1[_,_]] 
res33: reflect.runtime.universe.Type = scala.Function1[_, _] // correct? 
@scabug
Copy link
Author

scabug commented Jun 18, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5941?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Jun 18, 2012

@scabug
Copy link
Author

scabug commented Jun 30, 2012

@xeno-by said:
The problem is actually not as minor as it looks. This happens because sometimes we get ScalaPackage from the root mirror and it gets stripped off when printing, and sometimes we get ScalaPackage from a child mirror. This begs for additional investigation.

@scabug
Copy link
Author

scabug commented Aug 15, 2013

@retronym said:
Linking this to a code comment:

    // Modules whose members are in the default namespace
    // SI-5941: ScalaPackage and JavaLangPackage are never ever shared between mirrors
    // as a result, `Int` becomes `scala.Int` and `String` becomes `java.lang.String`
    // I could just change `isOmittablePrefix`, but there's more to it, so I'm leaving this as a todo for now
    lazy val UnqualifiedModules = List(PredefModule, ScalaPackage, JavaLangPackage)
    // Those modules and their module classes
    lazy val UnqualifiedOwners  = UnqualifiedModules.toSet ++ UnqualifiedModules.map(_.moduleClass)

And a design doc on reflection:

https://docs.google.com/document/d/1nAwSw4TmMplsIlzh2shYLUJ5mVh3wndDa1Zm1H6an9A/edit#

And a related report from the mailing lists:

https://groups.google.com/forum/#!msg/scala-language/6TyLTfk4E-I/sg33aLe_-40J

On Wed, May 1, 2013 at 7:59 AM, Ryan Hendrickson <Ryan[email protected]> wrote:
Any ideas as to why?

Classloaders, somehow. I get the same ## result with "scala" but different results with "scala -nobootcp".

% scala210_1 -nobootcp
Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import reflect.runtime.universe._
import reflect.runtime.universe._

scala>  (typeOf[String].normalize.##, typeOf[java.lang.String].normalize.##)
res0: (Int, Int) = (1712057924,559543568)

@scabug
Copy link
Author

scabug commented Dec 11, 2013

@xeno-by said:
Also see #6079

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@retronym retronym self-assigned this Dec 4, 2017
@retronym retronym modified the milestones: Backlog, 2.13.0-M4 Dec 4, 2017
@retronym
Copy link
Member

retronym commented Dec 4, 2017

WIP: https://github.com/scala/scala/compare/2.13.x...retronym:ticket/5941?expand=1

This blocks scala/scala-partest#75, so I'm going to try to get a fix into 2.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants