From e3d26fce0986538394e6588cb958ac3f23737edd Mon Sep 17 00:00:00 2001 From: Daniel Urban Date: Sat, 11 May 2024 13:56:45 +0200 Subject: [PATCH] Cleanup --- .../choam/internal/mcas/MutDescriptor.scala | 3 --- .../choam/internal/mcas/AbstractDescriptor.scala | 2 -- .../tauri/choam/internal/mcas/Descriptor.scala | 16 +++++++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) 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