Skip to content
Create a gist now

Instantly share code, notes, and snippets.

import scala.reflect.runtime.universe._
import scala.reflect.runtime.{currentMirror => cm}
trait Base {
def companion: MetaBase = {
val classSymbol = cm.classSymbol(getClass)
val moduleSymbol = classSymbol.companionSymbol.asModule
val moduleMirror = cm.reflectModule(moduleSymbol)
trait MetaBase {
// stuff
object Test extends App {
class Foo extends Base
object Foo extends MetaBase
println(new Foo().companion)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.