public function getCheckedRef($requiredClass, $dataTypeName)
    {
        if (!$this->checked) {
            // should be in stack
            $stk = [];
            $stk[] = $this;
            $this->dieOnCircularReference($stk, $this->getProject());
        }

        $o = $this->ref->getReferencedObject($this->getProject());
        if (!($o instanceof $requiredClass)) {
            throw new BuildException($this->ref->getRefId() . " doesn't denote a " . $dataTypeName);
        } else {
            return $o;
        }
    }