Aladdin - Scala Bugtracking
[#612] project: specification priority: low category: missing feature
submitter assigned to status date submitted
Sean Martin open 2006-05-19 17:09:23.0
subject requires only applies to this???
code
package test2;

abstract class Test {
  type A <: Ax;
  def foo(a : A) : Unit;
  def ax : Ax;
  abstract class Ax requires A {
    foo(this);
  }
  foo(ax);
}
what happened
The first call to foo (foo(this)) passes type checking, the second call to foo (foo(ax)) does not:

type mismatch;
 found   : Test.this.Ax
 required: Test.this.A	test/src/test2	Test.scala	
what expected I would exect that if Ax.this is a subtype of A, then any value of type Ax is also a subtype of A.
[back to overview]
Changes of this bug report
Martin  edited on  2006-05-27 11:16:09.0
`requires' currently does not affect subtyping, nor member access from outside an object. It is an open question whether it should. Compare also with bug 511.
Burak  edited on  2006-05-28 22:29:15.0
As I argued under Expressivity for free! `requires' is then more obviously a way of splitting a class into different parts, which is nice for modularity.
Burak  edited on  2006-05-28 22:31:02.0
sorry, trying again: As I argued under [bug #511]every Ax is an A, so it would make sense to treat it Ax as a subtype of A. The spec does not say too much on 'requires', but I think we all agree that all instances of Ax are also instances of A, due to the `require'. By "extension, this is just another way of saying that they are in the subtyping relation. >
Expressivity for free! `requires' is then more obviously a way of splitting a class into different parts, which is nice for modularity.
Martin  edited on  2006-08-20 18:42:22.0
The spec says otherwise. It's open to review, though.