From 429703a5bfb6c4b952d46085b080641521ec0f8a Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 12 Aug 2024 15:53:12 +0200 Subject: [PATCH] Use default self type more often We now also use cap as the default for the self type's capture set if a base class has an explicit self type, but that type's capture set is universal. This requires fewer self type annotations. --- compiler/src/dotty/tools/dotc/cc/Setup.scala | 2 +- scala2-library-cc/src/scala/collection/IndexedSeqView.scala | 5 +---- scala2-library-cc/src/scala/collection/SeqView.scala | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/cc/Setup.scala b/compiler/src/dotty/tools/dotc/cc/Setup.scala index 25d50052f107..c0b0d53910fd 100644 --- a/compiler/src/dotty/tools/dotc/cc/Setup.scala +++ b/compiler/src/dotty/tools/dotc/cc/Setup.scala @@ -572,7 +572,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