Skip to content

Commit

Permalink
Unpickle package-private from TASTy
Browse files Browse the repository at this point in the history
Meaning package private things will be automatically filtered.
  • Loading branch information
dwijnand committed Jan 25, 2022
1 parent 1bc783e commit c47aa70
Show file tree
Hide file tree
Showing 32 changed files with 197 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ private[mima] sealed abstract class ClassInfo(val owner: PackageInfo) extends In
final def isInterface: Boolean = ClassfileParser.isInterface(flags) // java interface or trait w/o impl methods
final def isClass: Boolean = !isTrait && !isInterface // class, object or trait's impl class

final def accessModifier: String = if (isProtected) "protected" else if (isPrivate) "private" else ""
final def scopedPrivateSuff: String = if (isScopedPrivate) "[..]" else ""
final def accessModifier: String = if (isProtected) s"protected$scopedPrivateSuff" else if (isPrivate) s"private$scopedPrivateSuff" else ""
final def declarationPrefix: String = if (isModuleClass) "object" else if (isTrait) "trait" else if (isInterface) "interface" else "class"
final lazy val fullName: String = if (owner.isRoot) bytecodeName else s"${owner.fullName}.$bytecodeName"
final def formattedFullName: String = formatClassName(if (isModuleClass) fullName.init else fullName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sealed abstract class MemberInfo(val owner: ClassInfo, val bytecodeName: String,

final def fullName: String = s"${owner.formattedFullName}.$decodedName"
final def abstractPrefix = if (isDeferred && !owner.isTrait) "abstract " else ""
final def scopedPrivatePrefix = if (scopedPrivate) "private[..] " else ""
final def staticPrefix: String = if (isStatic) "static " else ""
final def tpe: Type = owner.owner.definitions.fromDescriptor(descriptor)
final def hasSyntheticName: Boolean = decodedName.contains('$')
Expand Down Expand Up @@ -43,7 +44,7 @@ private[mima] final class MethodInfo(owner: ClassInfo, bytecodeName: String, fla
def shortMethodString: String = {
val prefix = if (hasSyntheticName) if (isExtensionMethod) "extension " else "synthetic " else ""
val deprecated = if (isDeprecated) "deprecated " else ""
s"${abstractPrefix}$prefix${deprecated}${staticPrefix}method $decodedName$tpe"
s"${scopedPrivatePrefix}${abstractPrefix}$prefix${deprecated}${staticPrefix}method $decodedName$tpe"
}

lazy val paramsCount: Int = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ object MimaUnpickler {
val index = buf.createIndex
val entries = new Array[Entry](index.length)
val classes = new scala.collection.mutable.HashMap[SymInfo, ClassInfo]
def nnSyms = entries.iterator.collect { case s: SymbolInfo => s }
def defnSyms = nnSyms.filter(sym => sym.tag == CLASSsym || sym.tag == MODULEsym)
def methSyms = nnSyms.filter(sym => sym.tag == VALsym)
def syms = entries.iterator.collect { case s: SymbolInfo => s }
def defnSyms = syms.filter(sym => sym.tag == CLASSsym || sym.tag == MODULEsym)
def methSyms = syms.filter(sym => sym.tag == VALsym)

def until[T](end: Int, op: () => T): List[T] =
if (buf.readIndex == end) Nil else op() :: until(end, op)
Expand Down Expand Up @@ -177,7 +177,7 @@ object MimaUnpickler {
.filter(_.name.value != CONSTRUCTOR) // TODO support package private constructors
.toSeq.groupBy(_.name).foreach { case (name, pickleMethods) =>
doMethodOverloads(clazz, name, pickleMethods)
}
}
}

def doMethodOverloads(clazz: ClassInfo, name: Name, pickleMethods: Seq[SymbolInfo]) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,14 @@ object TastyFormat {
* ANNOTATEDtype Length underlying_Type annotation_Term -- underlying @ annotation
* ANDtype Length left_Type right_Type -- left & right
* ORtype Length left_Type right_Type -- lefgt | right
* MATCHtype Length bound_Type sel_Type case_Type* -- sel match {cases} with optional upper `bound`
* MATCHtype Length bound_Type sel_Type case_Type* -- sel match {cases} with optional upper `bound`
* MATCHCASEtype Length pat_type rhs_Type -- match cases are MATCHCASEtypes or TYPELAMBDAtypes over MATCHCASEtypes
* BIND Length boundName_NameRef bounds_Type Modifier* -- boundName @ bounds, for type-variables defined in a type pattern
* BYNAMEtype underlying_Type -- => underlying
* PARAMtype Length binder_ASTRef paramNum_Nat -- A reference to parameter # paramNum in lambda type `binder`
* POLYtype Length result_Type TypesNames -- A polymorphic method type `[TypesNames]result`, used in refinements
* METHODtype Length result_Type TypesNames Modifier* -- A method type `(Modifier* TypesNames)result`, needed for refinements, with optional modifiers for the parameters
* TYPELAMBDAtype Length result_Type TypesNames -- A type lambda `[TypesNames] => result`
* SHAREDtype type_ASTRef -- link to previously serialized type
* TypesNames = TypeName*
* TypeName = typeOrBounds_ASTRef paramName_NameRef -- (`termName`: `type`) or (`typeName` `bounds`)
*
Expand Down
Loading

0 comments on commit c47aa70

Please sign in to comment.