aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/src/dotty/tools/dotc/core/Types.scala7
-rw-r--r--tests/pos/i2051.scala2
2 files changed, 6 insertions, 3 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala
index 639f5d142..271dcda7c 100644
--- a/compiler/src/dotty/tools/dotc/core/Types.scala
+++ b/compiler/src/dotty/tools/dotc/core/Types.scala
@@ -727,8 +727,8 @@ object Types {
/** Is this type a legal type for a member that overrides another
* member of type `that`? This is the same as `<:<`, except that
- * the types ()T and => T are identified, and T is seen as overriding
- * either type.
+ * the types `()T`, `=> T` and `T` are seen as overriding
+ * each other.
*/
final def overrides(that: Type)(implicit ctx: Context) = {
def result(tp: Type): Type = tp match {
@@ -737,7 +737,8 @@ object Types {
}
(this frozen_<:< that) || {
val rthat = result(that)
- (rthat ne that) && (result(this) frozen_<:< rthat)
+ val rthis = result(this)
+ (rthat.ne(that) || rthis.ne(this)) && (rthis frozen_<:< rthat)
}
}
diff --git a/tests/pos/i2051.scala b/tests/pos/i2051.scala
new file mode 100644
index 000000000..d0e9fed0d
--- /dev/null
+++ b/tests/pos/i2051.scala
@@ -0,0 +1,2 @@
+class A[T](val x:T)
+class B[T](override val x:T) extends A[T](x)