Can't access method of companion class from companion object

Viewed 13539

I thought that I can access every method of the companion class from my companion object. But I can't?

class EFCriteriaType(tag:String) extends CriteriaType
{
  // implemented method of CriteriaType
  def getTag = this.tag   
}

object EFCriteriaType
{
  var TEXT: CriteriaType = new EFCriteriaType("text")

  override def toString = getTag
}

Compiler error: not found: value getTag

What I'm doing wrong?

4 Answers

follow this example, please:

import scala.math._

case class Circle(radius: Double) {
  import Circle._
  def area: Double = calculateArea(radius)
}

object Circle {
  private def calculateArea(radius: Double): Double = Pi * pow(radius, 2.0)
}

val circle1 = Circle(5.0)

circle1.area
Related