Skip to content

fix: add context-aware diagnostics for class-string<static>#286

Merged
calebdw merged 1 commit into
mainfrom
calebdw/push-nzxkuxoxtxsu
Jul 25, 2026
Merged

fix: add context-aware diagnostics for class-string<static>#286
calebdw merged 1 commit into
mainfrom
calebdw/push-nzxkuxoxtxsu

Conversation

@calebdw

@calebdw calebdw commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Resolve self/static/$this/parent in parameter types to concrete class names before the type compatibility check, so that class-string is properly validated instead of blanket- suppressed.

The call-site context class is extracted from the call expression: ClassName::method uses the named class, static::/self::/$this-> uses the enclosing class, and parent:: uses its parent. This turns class-string into class-string, letting the existing class-string covariance check flag provably invalid arguments (unrelated classes) while still accepting child classes and siblings.

Closes #273

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, examples/)
  • I have updated the config schema (config-schema.json)
  • I have added/updated tests to cover my changes
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited with
    an eye towards deleting anything that is irrelevant, clarifying anything
    that is confusing, and adding details that are relevant. This includes,
    for example, commit descriptions, PR descriptions, and code comments.

Resolve self/static/$this/parent in parameter types to concrete
class names before the type compatibility check, so that
class-string<static> is properly validated instead of blanket-
suppressed.

The call-site context class is extracted from the call expression:
ClassName::method uses the named class, static::/self::/$this->
uses the enclosing class, and parent:: uses its parent.  This
turns class-string<static> into class-string<DeclaringClass>,
letting the existing class-string covariance check flag provably
invalid arguments (unrelated classes) while still accepting child
classes and siblings.

Closes #273
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/diagnostics/type_errors/mod.rs 86.11% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@calebdw
calebdw merged commit 138bcf3 into main Jul 25, 2026
7 checks passed
@calebdw
calebdw deleted the calebdw/push-nzxkuxoxtxsu branch July 25, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add context-aware diagnostics for class-string<static>

2 participants