This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Return type problem.

No replies
edmondo1984
Joined: 2011-09-14,
User offline. Last seen 28 weeks 3 days ago.

class ComplexCurveSecuritiesCollection[T <: SecurityImpl,X<:TermStructure](private val subcollections: IndexedSeq[GenericCurveSecuritiesCollection[T,X]]) extends CurveSecuritiesCollection[T] {
  type SubType = ComplexCurveSecuritiesCollection[T,X]
  type TermStructureType = X
  def filter(f: (T) => Boolean) = {    val newCollections = subcollections.map(item=>item.filter(f));     new ComplexCurveSecuritiesCollection[T,X](newCollections);  }
}
error: type mismatch;found   : IndexedSeq[com.gottex.gottware.common.datamodels.finance.collections.curves.CurveSecuritiesCollection.GenericCurveSecuritiesCollection[T,X]#SubType] required: IndexedSeq[com.gottex.gottware.common.datamodels.finance.collections.curves.CurveSecuritiesCollection.GenericCurveSecuritiesCollection[T,X]]new ComplexCurveSecuritiesCollection[T,X](newCollections);
where 
trait CurveSecuritiesCollection[T <: SecurityImpl] extends RepriceableAndPublisheableCollection with java.lang.Iterable[T] {
  type SubType <: CurveSecuritiesCollection[T]


  def filter(f: (T) => Boolean): SubType
}
What is wrong in my code?
Best RegardsEdmondo Porcu

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland