Skip to content

Commit

Permalink
wip fix inherited fields
Browse files Browse the repository at this point in the history
  • Loading branch information
junkdog committed Nov 11, 2023
1 parent 991c04e commit 20f3b4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions core/src/main/kotlin/sift/core/element/FieldNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class FieldNode private constructor(
private val fn: AsmFieldNode,
private val kprop: KotlinProperty?,
override val annotations: List<AnnotationNode>,
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 {
Expand Down Expand Up @@ -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 }
}

Expand Down
18 changes: 9 additions & 9 deletions core/src/test/kotlin/sift/core/dsl/ScopeInheritedElementsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
)
}
Expand All @@ -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
"""
)
}
Expand Down

0 comments on commit 20f3b4b

Please sign in to comment.