metagen: processDerivedClassRefs converts ancestor methods to properties using subclass selectors (phantom accessors in emitted metadata)

オープン
#106 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, objective-c
領域
tooling

調査の方向性

Start in metadata-generator/src/IR/Class.cpp with processDerivedClassRefs, which calls convertMethodToPropertyIfNeeded in the wrong direction, and trace how ClassDecl::postProcessMembers invokes it. Confirm that an ancestor method record can be rewritten with a descendant's getter and setter selectors. Done means the ancestor keeps its own method record, such as NSView.autoscroll not gaining isAutoscroll, while superclass-to-subclass property propagation still works.

索引モデルが issue の本文から書いたものです。

説明

Summary

processDerivedClassRefs in metadata-generator/src/IR/Class.cpp calls convertMethodToPropertyIfNeeded in the wrong direction: it rewrites an ancestor class's method record into a property using the derived class's getter/setter selectors. Generated metadata then declares members on classes that never implement those selectors.

ClassDecl::postProcessMembers iterates members of a class, then runs processDerivedClassRefs(member, derivedClassRefs), which invokes convertMethodToPropertyIfNeeded(member /* ancestor member */, cls->getMemberNamed(member.name) /* derived member */, false). Inside, when memberInSuperclass->kind == kMemberProperty — i.e. the derived class declared a property — the ancestor's method is converted to a property that copies memberInSuperclass->getterSelector/setterSelector, selectors that belong to the subclass and that the ancestor does not implement.

Observed in metadata.macos.arm64.nsmd (generated for the macosx SDK): a census found 213 phantom getters and 212 phantom setters. Example: NSView.autoscroll/NSClipView.autoscroll carry NSMatrix's isAutoscroll/setAutoscroll: — messaging a stock NSView with isAutoscroll raises -[NSView isAutoscroll]: unrecognized selector sent to instance.

Expected

A derived class's member declarations should not mutate the ancestor's member record; the property conversion should only flow superclass → subclass (which the postProcessMembers superclass walk already handles). Either drop the processDerivedClassRefs conversion or scope it so an ancestor never borrows a descendant's selectors.

Environment

  • NativeScript/runtimes main (verified identical at 5b697b39)
  • metadata-generator source + generated metadata.macos.*.nsmd
  • Impact is multiplied by the napi backend's unguarded selector dispatch — reading any phantom member aborts the process instead of raising a JS error (filed separately).
主要言語
C++
スター
27
フォーク
4
平均マージ
5日 11時間
マージ済み PR(30日)
12

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NativeScript/runtimes のほかの issue

NativeScript/runtimes の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。