diff --git a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/MutDescriptor.scala b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/MutDescriptor.scala index 3f0ff9e9..ff83c53a 100644 --- a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/MutDescriptor.scala +++ b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/MutDescriptor.scala @@ -31,9 +31,6 @@ final class MutDescriptor private ( final override type D = MutDescriptor - final override def self: MutDescriptor = - this - final override def readOnly: Boolean = this.map.definitelyReadOnly diff --git a/mcas/shared/src/main/scala/dev/tauri/choam/internal/mcas/AbstractDescriptor.scala b/mcas/shared/src/main/scala/dev/tauri/choam/internal/mcas/AbstractDescriptor.scala index d42f12a7..b1dc8466 100644 --- a/mcas/shared/src/main/scala/dev/tauri/choam/internal/mcas/AbstractDescriptor.scala +++ b/mcas/shared/src/main/scala/dev/tauri/choam/internal/mcas/AbstractDescriptor.scala @@ -30,8 +30,6 @@ abstract class AbstractDescriptor extends AbstractDescriptorPlatform { type D <: AbstractDescriptor - def self: D - def readOnly: Boolean def validTs: Long diff --git a/mcas/shared/src/main/scala/dev/tauri/choam/internal/mcas/Descriptor.scala b/mcas/shared/src/main/scala/dev/tauri/choam/internal/mcas/Descriptor.scala index 87013544..c13688f4 100644 --- a/mcas/shared/src/main/scala/dev/tauri/choam/internal/mcas/Descriptor.scala +++ b/mcas/shared/src/main/scala/dev/tauri/choam/internal/mcas/Descriptor.scala @@ -34,9 +34,6 @@ final class Descriptor private ( final override type D = Descriptor - final override def self: D = - this - final override val readOnly: Boolean = this.map.definitelyReadOnly && (!this.hasVersionCas) @@ -332,8 +329,17 @@ object Descriptor { } if (needToExtend) { merged = ctx.validateAndTryExtend(merged, hwd = null) match { - case null => null // couldn't extend - case extended => extended.self // TODO: can we avoid `.self` here? + case null => + // couldn't extend: + null + case extended => + // we know it's immutable here + // (so `toImmutable` is a NOP), + // we just need to convince scalac + // that it's type is `Descriptor`: + val r = extended.toImmutable + assert(r eq extended) + r } } merged