Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overloaded method value with alternatives

I have the following:

def calc(dir: File): Option[Group] = {
 calcModel(dir) match {
  case Some(model: Model) => calcUI(model, centerpane.getWidth, centerpane.getHeight, 5, MAX_LEVEL)
  case None =>               None
 }
}

def calcUI(model: Model, availableWidth: Double, availableHeight: Double, maxLevel: Int): Option[Group] = {
}

def calcUI(model: Model, posX: Double, posY: Double, availableWidth: Double, availableHeight: Double, horizontally: Boolean, startLevel: Int, maxLevel: Int): Option[Group] = {
}

protected def calcUI(node: Node, posX: Double, posY: Double, availableWidth: Double, availableHeight: Double, horizontally: Boolean, level: Int, maxLevel: Int): Group = {
}

def calcModel(dir: File): Option[Model] = {
}

(Remark: Model does NOT derive from Node)

and get the following compiler error message:

Error:(88, 27) overloaded method value calcUI with alternatives:
  (node: org.rob.spaceview.modell.Node,posX: Double,posY: Double,availableWidth: Double,availableHeight: Double,horizontally: Boolean,level: Int,maxLevel: Int)javafx.scene.Group <and>
  (model: org.rob.spaceview.modell.Model,posX: Double,posY: Double,availableWidth: Double,availableHeight: Double,horizontally: Boolean,startLevel: Int,maxLevel: Int)Option[javafx.scene.Group] <and>
  (model: org.rob.spaceview.modell.Model,availableWidth: Double,availableHeight: Double,maxLevel: Int)Option[javafx.scene.Group]
 cannot be applied to (org.rob.spaceview.modell.Model, Double, Double, Int, Int)
      case Some(model) => calcUI(model, centerpane.getWidth, centerpane.getHeight, 5, MAX_LEVEL)
                      ^

I do not get it. All calcUI functions are different by parameters.

I know this error and most of the time I get it and fix it. But here, no clue.

Hopefully somebody enlights me. Thanks.

like image 568
Rob Avatar asked Mar 14 '14 08:03

Rob


1 Answers

Actually, the given parameters in the call

case Some(model) => calcUI(model, centerpane.getWidth, centerpane.getHeight, 5, MAX_LEVEL)

don't correspond to any defined calcUI method. For example for the following definition

def calcUI(model: Model, availableWidth: Double, availableHeight: Double, maxLevel: Int): Option[Group]

you have one more argument than needed.

like image 63
Lomig Mégard Avatar answered Nov 04 '22 16:11

Lomig Mégard