I was surprised to see the `KSDeclaration.getVisib...
# ksp
e
I was surprised to see the
KSDeclaration.getVisibility()
returns the visibility of the original declaration by looking up the overridee if the declaration is an override. I was expecting, and hoping, to get the visibility of an overridden function and was pretty confused by this behavior. Why was this approach chosen? It seems like a strange default. I suppose we can check modifiers directly to get visibility of a overridden declaration but it’s not ideal imo
@yigit because of this I think XHasModifiers implementation of
isProtected
and
isPublic
cannot show overridden visibility, and since modifiers are not exposed it doesn’t seem possible with XProcessing to get the visibility of overridden functions right now
y
hmm interesting. Lets see what the KSP folks think. There is probably a reason to look for overides
j
it is necessary to look up to overridee when there is no visibility specified by overrider.
I think there is something missing here, overrider can increase the visibility, so I think I need to adjust the check to take the maximum visibility of the overrider and overridee.
the reason we need to look up: https://kotlinlang.org/docs/visibility-modifiers.html#classes-and-interfaces
If you override a 
protected
 member and do not specify the visibility explicitly, the overriding member will also have 
protected
 visibility.
without this it will make sense to just look at the overrider for visibility, since default is
public
and is the maximum possible visibility, and
internal
and
protected
is not compatible to each other therefore you can’t change it from one to another at override site.
actually no, default visibility does not apply for override. Say if you override an internal member with no visibility modifier, the visibility is still
internal
, you need to use
public override
to make it public. So look up is also needed for
internal
overridee. Somehow this is not documented in the aforementioned doc.
I will fix the visibility for
public override
, otherwise it is still needed to look up for overridee.
e
makes sense, thank you!