# Overloading \`getproperty\` in a type-stable manner

**URL:** https://discourse.julialang.org/t/overloading-getproperty-in-a-type-stable-manner/36638
**Category:** General Usage
**Tags:** question
**Created:** [March 28, 2020, 2:19pm UTC](https://discourse.julialang.org/t/overloading-getproperty-in-a-type-stable-manner/36638 "2020-03-28T14:19:09Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [March 28, 2020, 6:30pm UTC](https://discourse.julialang.org/t/overloading-getproperty-in-a-type-stable-manner/36638/5 "2020-03-28T18:30:50Z")

</div>

> [@Unexpected type instability with getproperty but not setproperty!](https://discourse.julialang.org/t/unexpected-type-instability-with-getproperty-but-not-setproperty/26975/10):
>
> Constant propagation doesn’t really work with recursion. Use: function Base.getproperty(e::Entry, s::Symbol) if s === :value getfield(e, :data)[getfield(e, :id)] else getfield(e, s) end end

---

_[View the full topic](https://discourse.julialang.org/t/overloading-getproperty-in-a-type-stable-manner/36638)._
