title: Scala type mismatch: required _$1 where type _$1 <:
body: <p>I'm a newbie to Scala and I'm facing an issue I can't understand and solve. I have written a generic <code>trait</code> which is this one:</p>
  
  <pre><code>trait DistanceMeasure[P&lt;:DbScanPoint] {
    def distance(p1:P, p2:P):Double
  }
  </code></pre>
  
  <p>where <code>DbScanPoint</code> is simply:</p>
  
  <pre><code>trait DbScanPoint extends Serializable {}
  </code></pre>
  
  <p>Then I have the following two classes extending them:</p>
  
  <pre><code>class Point2d (id:Int, x:Double, y:Double) extends DbScanPoint {
     def getId() = id
     def getX() = x
     def getY() = y
  }
  
  class EuclideanDistance extends DistanceMeasure[Point2d] with Serializable {
  
     override def distance(p1:Point2d,p2:Point2d) = {
        (p1.getX()-p2.getX())*(p1.getX()-p2.getX()) + (p1.getY()-p2.getY()) * (p1.getY()-p2.getY())
    }
  }
  </code></pre>
  
  <p>And at the end I have this class:</p>
  
  <pre><code>class DBScanSettings {
  
     var distanceMeasure:DistanceMeasure[_&lt;:DbScanPoint] = new EuclideanDistance
     //...
  }
  </code></pre>
  
  <p>My problem is that if that when I write in my test main this:</p>
  
  <pre><code> val dbScanSettings = new DBScanSettings()
   dbScanSettings.distanceMeasure.distance(new Point2d(1,1,1), new Point2d(2,2,2))
  </code></pre>
  
  <p>I get the following compiling error:</p>
  
  <pre><code> type mismatch;
   [error]  found   : it.polito.dbdmg.ontic.point.Point2d
   [error]  required: _$1 where type _$1 &lt;: it.polito.dbdmg.ontic.point.DbScanPoint
  </code></pre>
  
  <p>I can't understand which is the problem. I have done a very similar thing with other classes and I got no error, so the reason of this error is quite obscure to me.</p>
  
  <p>May somebody help me?</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I managed to do what I needed by changing the code to:</p>
  
  <pre><code>trait DistanceMeasure {
    def distance(p1:DbScanPoint, p2:DbScanPoint):Double
  }
  </code></pre>
  
  <p>And obviously making all the related changes.</p>