title: Scala type bounds behaviour (method vs class)
body: <p>Probably an easy one for Scala gurus. I'm reading up on type bound constraints and wondering if I'm missing something, as I'm seeing a slightly unexpected behaviour. Let's say we have three types A,B,C in a hierarchy like this, for which we're experimenting with type bounds:</p>
  
  <pre><code>class A {
  }
  
  class B extends A {
  }
  
  class C extends B {
  }
  
  class MyList1 { // T super B
    def add[T &gt;: B](a: T): Unit = {}
  }
  
  class MyList2 { // T extends B
    def add[T &lt;: B](a: T): Unit = {}
  }
  
  class MyList3[T &gt;: B] { // T super B
    def add(a: T): Unit = {}
  }
  
  class MyList4[T &lt;: B] { // T extends B
    def add(a: T): Unit = {}
  }
  
  object BoundsClass {
  
    def main(args: Array[String]) {
      val l1 = new MyList1
      l1.add(new A) 
      l1.add(new B)
      l1.add(new C) // why is this allowed??
  
      val l2 = new MyList2
      // l2.add(new A) // not allowed (OK)
      l2.add(new B)
      l2.add(new C)
  
      val l3a = new MyList3[A]
      val l3b = new MyList3[B]
      // val l3c = new MyList3[C] // not allowed (OK)
  
      // val l4a = new MyList4[A] // not allowed (OK)
      val l4b = new MyList4[B]
      val l4c = new MyList4[C]
    }
  
  }
  </code></pre>
  
  <p>The collections are behaving as expected for all except one case, see l1.add(new C); not causing a compilation error. Why is this allowed?</p>
  
  <p>Thanks!</p>