Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3617306
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:36:27+00:00 2026-05-18T22:36:27+00:00

The scalap library has functionality for parsing Scala-specific information out of classfiles. For a

  • 0

The scalap library has functionality for parsing Scala-specific information out of classfiles. For a regular class, I can obtain information as such:

scala> ScalaSigParser.parse(classOf[BasicCase])
res46: Option[scala.tools.scalap.scalax.rules.scalasig.ScalaSig] = 
Some(ScalaSig version 5.0
0: ClassSymbol(BasicCase, owner=<empty>, flags=40000040, info=5 ,None)
1: BasicCase
2: <empty>
3: <empty>
4: NoSymbol
5: ClassInfoType(ClassSymbol(BasicCase, owner=<empty>, flags=40000040, info=5 ,None),List(TypeRefType(ThisType(java.lang),java.lang.Object,List()), TypeRefType(ThisType(scala),scala.ScalaObject,List()), TypeRefType(ThisType(scala),scala.Product,List())))
6: TypeRefType(ThisType(java.lang),java.lang.Object,List())
7: ThisType(java.lang)
8: java.lang
9: lang
10: java
11: java
12: java.lang.Object
13: Object
14: TypeRefType(ThisType(scala),scala.ScalaObject,List())
15: ThisType(scala)
16: scala
17: scala
18: scala.ScalaObject
19: ScalaObject
20: TypeRefType(ThisType(scala),scala.Pr...
scala> 

…and from there get all sorts of goodies about the internals. But for the companion object:

scala> ScalaSigParser.parse(classOf[BasicCase$])
res47: Option[scala.tools.scalap.scalax.rules.scalasig.ScalaSig] = None

…I get nothing. However, Scalap will work on the companion object class:

scalap -cp . BasicCase$
package BasicCase$;
final class BasicCase$ extends scala.runtime.AbstractFunction3 with java.io.Serializable with scala.ScalaObject {
  def this(): scala.Unit;
  def apply(scala.Any, scala.Any, scala.Any): scala.Any;
  def readResolve(): scala.Any;
  def apply(scala.Int, java.lang.String, scala.Option): BasicCase;
  def unapply(BasicCase): scala.Option;
}
object BasicCase$ {
  final val MODULE$: BasicCase$;
}

So there must be a way, I just haven’t been able to find it. Anyone have any ideas?

EDIT: I found it, but still need more:

scala> bcSig.topLevelObjects
res59: List[scala.tools.scalap.scalax.rules.scalasig.ObjectSymbol] = List(ObjectSymbol(BasicCase, owner=<empty>, flags=200402, info=124 ))

scala> bcSig.topLevelObjects.head
res60: scala.tools.scalap.scalax.rules.scalasig.ObjectSymbol = ObjectSymbol(BasicCase, owner=<empty>, flags=200402, info=124 )

Unfortunately the children method doesn’t seem to give me methods:

scala> res60.children                          
res70: Seq[scala.tools.scalap.scalax.rules.scalasig.Symbol] = List()

Unlike with the regular class:

scala> bcSym.children
res71: Seq[scala.tools.scalap.scalax.rules.scalasig.Symbol] = List(MethodSymbol(id, owner=0, flags=29400200, info=25 ,None), MethodSymbol(id , owner=0, flags=21080004, info=26 ,None), MethodSymbol(name, owner=0, flags=29400200, info=33 ,None), MethodSymbol(name , owner=0, flags=21080004, info=34 ,None), MethodSymbol(data, owner=0, flags=29400200, info=45 ,None), MethodSymbol(data , owner=0, flags=21080004, info=46 ,None), MethodSymbol(<init>, owner=0, flags=200, info=53 ,None), MethodSymbol(copy, owner=0, flags=200200, info=61 ,None), MethodSymbol(copy$default$1, owner=0, flags=2200200, info=67 ,None), MethodSymbol(copy$default$2, owner=0, flags=2200200, info=80 ,None), MethodSymbol(copy$default$3, owner=0, flags=2200200, info=84 ,None), MethodSymbol(hashCode, owner=0, flags=40000220, i...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:36:28+00:00Added an answer on May 18, 2026 at 10:36 pm

    I think could get the companion’s methods using the infoType, I used List as my sample and res17 is equivalent to your res60 :

        scala> res17
        res23: scala.tools.scalap.scalax.rules.scalasig.ObjectSymbol = 
    ObjectSymbol(List, owner=scala.collection.immutable, flags=402, info=273 )
    
        scala> res17.infoType.asInstanceOf[TypeRefType].symbol.children
        res22: Seq[scala.tools.scalap.scalax.rules.scalasig.Symbol] = List(
        MethodSymbol(<init>, owner=274, flags=200, info=280 ,None), 
        MethodSymbol(canBuildFrom, owner=274, flags=201, info=283 ,None), 
        MethodSymbol(newBuilder, owner=274, flags=200, info=294 ,None), 
        MethodSymbol(empty, owner=274, flags=220, info=306 ,None), 
        MethodSymbol(apply, owner=274, flags=220, info=312 ,None), 
        MethodSymbol(range, owner=274, flags=200, info=324 ,None), 
        MethodSymbol(make, owner=274, flags=200, info=336 ,None), 
        MethodSymbol(flatten, owner=274, flags=200, info=348 ,None), 
        MethodSymbol(unzip, owner=274, flags=200, info=361 ,None), 
        MethodSymbol(unzip, owner=274, flags=200, info=377 ,None), 
        MethodSymbol(lefts, owner=274, flags=200, info=394 ,None), 
        MethodSymbol(rights, owner=274, flags=200, info=412 ,None)...
    

    Note the lefts and rights methods, which don’t exist in List class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a library that needs reflection, and needs Scala-specific information as opposed
I have a library which has root package scala, and now I have a
scala> val l = List((1,2), (2,3)) l: List[(Int, Int)] = List((1,2), (2,3)) I can
In Scala, if I have a simple class as follows: val calc = actor
Does Scala have a version of Rubys' each_slice from the Array class?
Those anyone know of a Scala Library for Graphs / Charts or an implementation
Is there a way to tell sbt to package all needed libraries (scala-library.jar) into
I have just started to look at the Scala collections library re-implementation which is
Is there a Scala library that parses Scala and creates an Abstract Syntax Tree
I'm trying to create types Tuple equivalent to the ones in the Scala library,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.