diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala b/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala index 9b7d2b90ed1a..29c6528e36de 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureOps.scala @@ -528,9 +528,11 @@ extension (cls: ClassSymbol) // and err on the side of impure. && selfType.exists && selfType.captureSet.isAlwaysEmpty - def baseClassHasExplicitSelfType(using Context): Boolean = + def baseClassHasExplicitNonUniversalSelfType(using Context): Boolean = cls.baseClasses.exists: bc => - bc.is(CaptureChecked) && bc.givenSelfType.exists + bc.is(CaptureChecked) + && bc.givenSelfType.exists + && !bc.givenSelfType.captureSet.isUniversal def matchesExplicitRefsInBaseClass(refs: CaptureSet)(using Context): Boolean = cls.baseClasses.tail.exists: bc => diff --git a/compiler/src/dotty/tools/dotc/cc/Setup.scala b/compiler/src/dotty/tools/dotc/cc/Setup.scala index 91671d7d7776..f578d10702e9 100644 --- a/compiler/src/dotty/tools/dotc/cc/Setup.scala +++ b/compiler/src/dotty/tools/dotc/cc/Setup.scala @@ -570,7 +570,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI: else if cls.isPureClass then // is cls is known to be pure, nothing needs to be added to self type selfInfo - else if !cls.isEffectivelySealed && !cls.baseClassHasExplicitSelfType then + else if !cls.isEffectivelySealed && !cls.baseClassHasExplicitNonUniversalSelfType then // assume {cap} for completely unconstrained self types of publicly extensible classes CapturingType(cinfo.selfType, CaptureSet.universal) else diff --git a/scala2-library-cc/src/scala/collection/IndexedSeqView.scala b/scala2-library-cc/src/scala/collection/IndexedSeqView.scala index 0b6f1bc8e64e..78f8abb8e327 100644 --- a/scala2-library-cc/src/scala/collection/IndexedSeqView.scala +++ b/scala2-library-cc/src/scala/collection/IndexedSeqView.scala @@ -16,13 +16,10 @@ package collection import scala.annotation.nowarn import language.experimental.captureChecking -trait IndexedSeqViewOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { - self: IndexedSeqViewOps[A, CC, C]^ => -} +trait IndexedSeqViewOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] /** View defined in terms of indexing a range */ trait IndexedSeqView[+A] extends IndexedSeqViewOps[A, View, View[A]] with SeqView[A] { - self: IndexedSeqView[A]^ => override def view: IndexedSeqView[A]^{this} = this diff --git a/scala2-library-cc/src/scala/collection/SeqView.scala b/scala2-library-cc/src/scala/collection/SeqView.scala index c7af0077ce1a..292dc61ddaa8 100644 --- a/scala2-library-cc/src/scala/collection/SeqView.scala +++ b/scala2-library-cc/src/scala/collection/SeqView.scala @@ -25,7 +25,6 @@ import scala.annotation.unchecked.uncheckedCaptures * mapping a SeqView with an impure function gives an impure view). */ trait SeqViewOps[+A, +CC[_], +C] extends Any with IterableOps[A, CC, C] { - self: SeqViewOps[A, CC, C]^ => def length: Int def apply(x: Int): A @@ -75,7 +74,6 @@ trait SeqViewOps[+A, +CC[_], +C] extends Any with IterableOps[A, CC, C] { } trait SeqView[+A] extends SeqViewOps[A, View, View[A]] with View[A] { - self: SeqView[A]^ => override def view: SeqView[A]^{this} = this