Description
Just noticed a likely bug in the SLS 3.5.2 on conformance, possibly relevant to #7278 — it says that
A type projection T#t conforms to U#t if T conforms to U.
and that looks incorrect.
That's only correct for nested classes in an inheritance relation (scala/scala3#4361 (comment)), as when you emulate virtual classes in Scala; but it's wrong for nested classes in general, and it appears incorrect even for abstract types.
Take T <: U
and T#t <: U#t
, then we can have U#t >: S <: U1
and T#t = U1
, which leads us to the false conclusion that U1 <: U#t
.
What is true is that T#t
's bounds must be at least as restrictive than U#t
's, or, borrowing @sstucki's terminology, T#t
must have a interval kind that is a (non-strict) subkind of U#t
's kind. That seems analogue to the rule for term-level members, after you shift one level up everything: the type of term member T.method
must be a (non-strict) subtype of U.method
's type.
Proposed replacement
Quoting myself in scala/scala3#4583 (comment):
Proposed new clauses:
SLS 3.5.1:
A type projection T#t is equivalent to U#t if T is equivalent to U.
SLS 3.5.2:
A type projection T#t conforms to U#t if T is equivalent to U. [not if T conforms to U].