8000 Support reflective access to non-constant expressions for parameter defaults by thekid · Pull Request #259 · xp-framework/core · GitHub
[go: up one dir, main page]

Skip to content

Support reflective access to non-constant expressions for parameter defaults #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

thekid
Copy link
Member
@thekid thekid commented Mar 6, 2021

See xp-framework/compiler#104 (comment), empowers the following when using the XP Compiler:

  #[Test]
  public function parameter_default_reflective_access() {
    $r= $this->run('use lang\ast\unittest\emit\Handle; class <T> {
      public function run($h= new Handle(0)) {
        return typeof($this)->getMethod("run")->getParameter(0)->getDefaultValue();
      }
    }');
    Assert::equals(new Handle(0), $r);
  }

@thekid
Copy link
Member Author
thekid commented Mar 6, 2021

This makes getDefaultValue() slower as it might need to parse the meta information. We can optimize this case though, because we don't want to support this from a XP "userland" perspective, only for the compiler, which eagerly prefills xp::$meta.

@thekid thekid merged commit 7b48674 into xp-framework:master Mar 6, 2021
@thekid thekid deleted the feature/parameter-default-annotation branch March 6, 2021 16:48
thekid added a commit to xp-framework/compiler that referenced this pull request Mar 6, 2021
@thekid
Copy link
Member Author
thekid commented Mar 6, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0