Skip to content
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

Review scala.collection public members #11433

Open
lrytz opened this Issue Feb 5, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@lrytz
Copy link
Member

lrytz commented Feb 5, 2018

At some point before shipping we should review public types / methods in the collection package. The following can be pasted in the repl:

:power

import symtab.Flags

def packagesIn(p: Symbol): List[Symbol] = {
  val ps = p.info.membersBasedOnFlags(0, Flags.PACKAGE).toList
  ps ::: ps.flatMap(packagesIn)
}

val collP = rootMirror.getPackage(TermName("scala.collection"))
val allPackages = collP :: packagesIn(collP)

def packageMembers(p: Symbol) = {
  // removes non-existing members from the scope (List$)
  p.info.members.foreach(_.initialize)
  p.info.members.toList.filter(m => !m.isPackage)
}


val msInPackages = allPackages.map(p => (p, {
  val ms = packageMembers(p)
  ms.groupMap(m => m.accessString)(m => {
    val typeMs = m.info.decls.toList.filter(m => !m.isSynthetic)
    (m, typeMs.groupBy(m => m.accessString))
  })
}))

for ((p, packageMsByAccess) <- msInPackages) {
  println(s"${p.fullNameString}:")
  for ((pa, pms) <- packageMsByAccess) {
    val paa = if (pa.isEmpty) "<public>" else pa
    println(s"  $paa:")
    for ((m, typeMsByAccess) <- pms) {
      println(s"    $m:")
      for ((ta, tms) <- typeMsByAccess) {
        val taa = if (ta.isEmpty) "<public>" else ta
        println(s"      $taa:")
        println(tms.mkString("        ", "\n        ", ""))
      }
    }
  }
}

Example output: https://gist.github.com/lrytz/54a920d0025913aec4c544862dd74ea0 - can be improved :)

@lrytz

This comment has been minimized.

Copy link
Member Author

lrytz commented Feb 5, 2018

We should also convert the above code to a partest test to make sure no public members are added accidentially.

@SethTisue SethTisue self-assigned this Nov 16, 2018

@SethTisue SethTisue transferred this issue from scala/collection-strawman Feb 20, 2019

@adriaanm adriaanm transferred this issue from scala/scala-dev Mar 13, 2019

@adriaanm adriaanm changed the title Review public members Review scala.collection public members Mar 13, 2019

@adriaanm adriaanm added this to the 2.13.0-RC1 milestone Mar 13, 2019

@joshlemer

This comment has been minimized.

Copy link
Member

joshlemer commented Mar 15, 2019

It would also be handy to include the exposed type of each member, so that nobody accidentally exposes/commits to a return type that's more specific than it should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.