From 8f101c5cd0b60af6f9df527f5b9c545bc304de04 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 1 Feb 2021 12:34:30 +0300 Subject: [PATCH] Fix symbol delegate after build work-around for https://youtrack.jetbrains.com/issue/KT-4012 --- kmath-core/api/kmath-core.api | 6 ------ .../kscience/kmath/expressions/Expression.kt | 14 +++----------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/kmath-core/api/kmath-core.api b/kmath-core/api/kmath-core.api index ab0555932..92165f795 100644 --- a/kmath-core/api/kmath-core.api +++ b/kmath-core/api/kmath-core.api @@ -488,15 +488,9 @@ public final class kscience/kmath/expressions/StringSymbol : kscience/kmath/expr } public abstract interface class kscience/kmath/expressions/Symbol { - public static final field Companion Lkscience/kmath/expressions/Symbol$Companion; public abstract fun getIdentity ()Ljava/lang/String; } -public final class kscience/kmath/expressions/Symbol$Companion : kotlin/properties/ReadOnlyProperty { - public synthetic fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Ljava/lang/Object; - public fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Lkscience/kmath/expressions/Symbol; -} - public abstract interface class kscience/kmath/expressions/SymbolIndexer { public abstract fun get (Ljava/util/List;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; public abstract fun get (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/expressions/Symbol;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/Expression.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/Expression.kt index 63bbc9312..c53d64871 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/Expression.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/Expression.kt @@ -3,7 +3,6 @@ package kscience.kmath.expressions import kscience.kmath.operations.Algebra import kotlin.jvm.JvmName import kotlin.properties.ReadOnlyProperty -import kotlin.reflect.KProperty /** * A marker interface for a symbol. A symbol mus have an identity @@ -13,13 +12,6 @@ public interface Symbol { * Identity object for the symbol. Two symbols with the same identity are considered to be the same symbol. */ public val identity: String - - public companion object : ReadOnlyProperty { - //TODO deprecate and replace by top level function after fix of https://youtrack.jetbrains.com/issue/KT-40121 - override fun getValue(thisRef: Any?, property: KProperty<*>): Symbol { - return StringSymbol(property.name) - } - } } /** @@ -103,9 +95,9 @@ public fun ExpressionAlgebra.bind(symbol: Symbol): E = /** * A delegate to create a symbol with a string identity in this scope */ -public val symbol: ReadOnlyProperty get() = Symbol -//TODO does not work directly on native due to https://youtrack.jetbrains.com/issue/KT-40121 - +public val symbol: ReadOnlyProperty = ReadOnlyProperty { thisRef, property -> + StringSymbol(property.name) +} /** * Bind a symbol by name inside the [ExpressionAlgebra]