facebook / facebook/hhvm

Final private method in trait overridden by a child class of the using class is not caught by hh_client

Open
#9,046 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

hack
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

After doing some work on this, I kinda think we should ban it on traits too. If we only ban final private methods on classes, hh will still accept this code that HHVM rejects:

trait MyTrait {
  public function foo(): void { $this->bar(); }
  final private function bar(): void {}
}

class MyClass {
  use MyTrait;
}

class MyChild extends MyClass {
  private function bar(): void {}
}

@lexidor do you have any opinions here?

Originally posted by @Wilfred in https://github.com/facebook/hhvm/issues/8805#issuecomment-845579117

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source files or tests. Start by reproducing the trait example with hh_client and HHVM, then trace the existing check for final private methods on classes. Done means the agreed trait behavior is documented by a regression test and hh_client no longer accepts code that HHVM rejects.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.