diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 7bb942e9ab6a..c1d0d2faaeb2 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -306,7 +306,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling } compareWild case tp2: LazyRef => - !tp2.evaluating && recur(tp1, tp2.ref) + isBottom(tp1) || !tp2.evaluating && recur(tp1, tp2.ref) case tp2: AnnotatedType if !tp2.isRefining => recur(tp1, tp2.parent) case tp2: ThisType => @@ -373,7 +373,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling if (recur(info1.alias, tp2)) return true if (tp1.prefix.isStable) return tryLiftedToThis1 case _ => - if (tp1 eq NothingType) return true + if (tp1 eq NothingType) || isBottom(tp1) then return true } thirdTry case tp1: TypeParamRef => @@ -420,7 +420,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling // If `tp1` is in train of being evaluated, don't force it // because that would cause an assertionError. Return false instead. // See i859.scala for an example where we hit this case. - !tp1.evaluating && recur(tp1.ref, tp2) + tp2.isRef(AnyClass, skipRefined = false) + || !tp1.evaluating && recur(tp1.ref, tp2) case tp1: AnnotatedType if !tp1.isRefining => recur(tp1.parent, tp2) case AndType(tp11, tp12) => diff --git a/tests/neg-custom-args/allow-deep-subtypes/i11064.scala b/tests/neg-custom-args/allow-deep-subtypes/i11064.scala new file mode 100644 index 000000000000..7cfab64d0e04 --- /dev/null +++ b/tests/neg-custom-args/allow-deep-subtypes/i11064.scala @@ -0,0 +1,9 @@ +trait TypedArray[T, Repr] + +trait Ops[T <: TypedArray[_, T]] { + def typedArray(): T +} + +object Test { + def test(ops: Ops[_ <: TypedArray[_ <: AnyRef, _]]) = ops.typedArray() // error: Recursion limit exceeded. +} \ No newline at end of file diff --git a/tests/neg/i6225.scala b/tests/neg/i6225.scala index 6d2f7943a394..148a484fd0f1 100644 --- a/tests/neg/i6225.scala +++ b/tests/neg/i6225.scala @@ -1,11 +1,11 @@ -object O1 { // error: cannot be instantiated +object O1 { type A[X] = X opaque type T = A // error: opaque type alias must be fully applied } object O2 { opaque type A[X] = X - object A { // error: cannot be instantiated + object A { opaque type T = A // error: opaque type alias must be fully applied } } diff --git a/tests/pos/i11064.scala b/tests/pos/i11064.scala new file mode 100644 index 000000000000..286b3d8dcc07 --- /dev/null +++ b/tests/pos/i11064.scala @@ -0,0 +1,9 @@ +trait TypedArray[T, Repr] + +trait Ops[T <: TypedArray[_, T]] { + def typedArray(): T +} + +object Test { + def test(ops: Ops[_ <: TypedArray[_, _]]) = ops.typedArray() +} \ No newline at end of file