From 20f3b4b74bd160222db1aa97b54cfbb62af03385 Mon Sep 17 00:00:00 2001 From: Adrian Papari Date: Sat, 11 Nov 2023 15:01:57 +0100 Subject: [PATCH] wip fix inherited fields --- .../main/kotlin/sift/core/element/FieldNode.kt | 5 +++-- .../core/dsl/ScopeInheritedElementsTest.kt | 18 +++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/src/main/kotlin/sift/core/element/FieldNode.kt b/core/src/main/kotlin/sift/core/element/FieldNode.kt index ab0063e..81284f9 100644 --- a/core/src/main/kotlin/sift/core/element/FieldNode.kt +++ b/core/src/main/kotlin/sift/core/element/FieldNode.kt @@ -15,7 +15,8 @@ class FieldNode private constructor( private val fn: AsmFieldNode, private val kprop: KotlinProperty?, override val annotations: List, - internal val signature: FieldSignatureNode? = fn.signature(cn.signature?.formalParameters ?: listOf()) + internal val signature: FieldSignatureNode? = fn.signature(cn.signature?.formalParameters ?: listOf()), + private val originalCn: ClassNode? = null, // when field is inherited ) : Element(), Trait.HasType { init { @@ -64,7 +65,7 @@ class FieldNode private constructor( override fun toString(): String = "$cn.$name" internal fun copyWithOwner(cn: ClassNode): FieldNode { - return FieldNode(cn, fn, kprop, annotations, signature) + return FieldNode(cn, fn, kprop, annotations, signature, this.cn) .also { fn -> fn.id = -1 } } diff --git a/core/src/test/kotlin/sift/core/dsl/ScopeInheritedElementsTest.kt b/core/src/test/kotlin/sift/core/dsl/ScopeInheritedElementsTest.kt index f1eeb9f..0893c26 100644 --- a/core/src/test/kotlin/sift/core/dsl/ScopeInheritedElementsTest.kt +++ b/core/src/test/kotlin/sift/core/dsl/ScopeInheritedElementsTest.kt @@ -43,12 +43,12 @@ class ScopeInheritedElementsTest { ├─ Base │ └─ Base.baseField ├─ BaseCore - │ ├─ Base.baseField + │ ├─ BaseCore.baseField │ └─ BaseCore.coreField └─ Concrete - ├─ Base.baseField - ├─ BaseCore.coreField - └─ Concrete.concreteField + ├─ Concrete.baseField + ├─ Concrete.concreteField + └─ Concrete.coreField """ ) } @@ -73,14 +73,14 @@ class ScopeInheritedElementsTest { ── class └─ Concrete ├─ Concrete::base - │ └─ Base.baseField + │ └─ Concrete.baseField ├─ Concrete::concrete - │ ├─ Base.baseField - │ ├─ BaseCore.coreField + │ ├─ Concrete.baseField + │ ├─ Concrete.coreField │ └─ Concrete.concreteField └─ Concrete::fooCore - ├─ Base.baseField - └─ BaseCore.coreField + ├─ Concrete.baseField + └─ Concrete.coreField """ ) }