Consider the following program:
class myClass {
def property[T](name: Symbol)(f: T => Boolean): Unit = {
// do something
}
def property1[T](name: Symbol)(f: T => List[Int]): Unit = {
// do something
}
}
object spamDataModel extends myClass {
property[Int]('myBoolean) {
x:Int=> true
}
}
Suppose I want to change the name of the method property1
to property
whole keeping both of them. Due to type erasure this is not possible, unless I do some tricks.
Wish suggestions from here I tried adding DummyImplicit
s:
class myClass {
def property[T](name: Symbol)(f: T => Boolean)(): Unit = {
// do something
}
def property[T](name: Symbol)(f: T => List[Int])(implicit d: DummyImplicit): Unit = {
// do something
}
}
object spamDataModel extends myClass {
property[Int]('myBoolean) {
x:Int=> true
}
}
But the moment that I add DummyImplcit
s, it starts to have errors (the second program):
[error] /Users/i-danielk/ideaProjects/saul/saul-core/src/main/scala/edu/illinois/cs/cogcomp/saul/datamodel/DataModel.scala:261: ambiguous reference to overloaded definition,
[error] both method property in class myClass of type (name: Symbol)(f: Int => List[Int])Unit
[error] and method property in class myClass of type (name: Symbol)(f: Int => Boolean)(implicit d1: DummyImplicit)Unit
[error] match argument types (Symbol)
[error] property[Int]('myBoolean) {
[error] ^
[warn] two warnings found
[error] one error found