@@ -769,21 +769,23 @@ object Types {
769769 def relaxed_<:< (that : Type )(implicit ctx : Context ) =
770770 (this <:< that) || (this isValueSubType that)
771771
772- /** Is this type a legal type for a member that overrides another
773- * member of type `that`? This is the same as `<:<`, except that
774- * the types `()T`, ` => T` and `T` are seen as overriding
775- * each other.
772+ /** Is this type a legal type for member `sym1` that overrides another
773+ * member `sym2` of type `that`? This is the same as `<:<`, except that
774+ * if `matchLoosely` evaluates to true the types `=> T` and `() T` are seen
775+ * as overriding each other.
776776 */
777- final def overrides (that : Type )(implicit ctx : Context ) = {
778- def result (tp : Type ): Type = tp match {
779- case ExprType (_) | MethodType (Nil ) => tp.resultType
777+ final def overrides (that : Type , matchLoosely : => Boolean )(implicit ctx : Context ): Boolean = {
778+ def widenNullary (tp : Type ) = tp match {
779+ case tp @ MethodType (Nil ) => tp.resultType
780780 case _ => tp
781781 }
782- (this frozen_<:< that) || {
783- val rthat = result(that)
784- val rthis = result(this )
785- (rthat.ne(that) || rthis.ne(this )) && (rthis frozen_<:< rthat)
786- }
782+ ((this .widenExpr frozen_<:< that.widenExpr) ||
783+ matchLoosely && {
784+ val this1 = widenNullary(this )
785+ val that1 = widenNullary(that)
786+ ((this1 `ne` this ) || (that1 `ne` that)) && this1.overrides(this1, matchLoosely = false )
787+ }
788+ )
787789 }
788790
789791 /** Is this type close enough to that type so that members
0 commit comments