julia icon indicating copy to clipboard operation
julia copied to clipboard

use `getfield` to access type fields in reflection

Open JeffBezanson opened this issue 4 years ago • 5 comments

Should help avoid issues like #39534. Doesn't get every case of course, but should catch some common ones.

JeffBezanson avatar Feb 08 '21 20:02 JeffBezanson

This seems rather icky, when it should do the same thing but with worse syntax (eventually perhaps we'll have sealed methods, and enforce it on these)

vtjnash avatar Feb 08 '21 20:02 vtjnash

bump. should we triage or close this?

vtjnash avatar Apr 16 '21 18:04 vtjnash

If we're going to do this, I would say we must also define that

getproperty(::Type, ::Symbol) = error("types are opaque")

vtjnash avatar May 27 '21 22:05 vtjnash

Makes sense, that would just be quite breaking. This is not too important though so I'm fine to just leave things as-is.

JeffBezanson avatar May 28 '21 16:05 JeffBezanson

Horribly outdated, but I do think it is in general worth using getfield explicitly in internal code on @nospecialized arguments, as it avoids the extra getproperty dispatch.

Keno avatar Nov 28 '25 06:11 Keno