How to reference a same name instance in an extension class from top level hierarchy?

Hello,

I am using an extended class which defines an instance with the same name as the parent class. In the extended class, we can reference the instance with super or this key word, I am wondering how to reference these same name instance from the UVM top level hierarchy. Thanks.

Regards,
Wenkai

In reply to wenkai_tang:

It would help to show a small example of what you are taking about. And please see this comment about parent/child terminology

In reply to dave_59:

Thanks a lot, dave_59 for the response.

An example of this issue is,

The class A contain an instance name I1 of a class, class B extends A and defines an instance with same name I1 of the same class. In B, the I1 can be referenced as this.I1 or super.I1.

When class B is instantiated in class C, how to reference this.I1 or super.I1 in B from C level?

Regards,
Wenkai

In reply to wenkai_tang:

First of all, this is a poor programming practice.

From B, you can refer to super.I1, or or more specifically A::I1. “super.” means start searching from the class that got extended.

From outside of B, you must upcast the instance of class B to an A class variable. Then you can reference a.I1.

In reply to dave_59:

Thanks a lot, dave_59.

I will adopt this upcast solution.

Regards,
wenkai