GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Track variable usage in ghosted type list initializers (fixes #398) by kjonescertinia · Pull Request #400 · apex-dev-tools/apex-ls

Conversation

@kjonescertinia

@kjonescertinia kjonescertinia commented Nov 22, 2025

Copy link
Copy Markdown
Contributor

Summary

  • Fixed false positive unused variable warnings when variables are used within List/Set initializers with ghosted element types
  • Ghosted types are external namespace types without available definitions (e.g., ext__Type__c)
  • Root cause: SetOrListCreatorRest.verify() was returning early without tracking variable usage when the element type lookup failed

Changes

  • Creator.scala: Added parts.foreach(_.verify(input, context)) call before early return when element type is ghosted, ensuring variable usage is tracked even when type compatibility checks are skipped
  • UnusedTest.scala: Added 3 comprehensive test cases covering:
    • Single variable used in ghosted type list initializer
    • Multiple variables used in ghosted type list elements
    • Unused variable correctly flagged even with ghosted type lists

Test plan

  • All existing tests pass (697 total)
  • New unit tests verify the fix
  • Tested against minimal reproduction case with external namespace types
  • Code formatted with sbt scalafmtAll

Fixes #398

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kjonescertinia
fix: Track variable usage in ghosted type list initializers (fixes #398)
ce6e664
When initializing a List/Set with a ghosted element type (external namespace
types without definitions), the variable usage tracking was being skipped. This
caused variables used within the list initializer to be incorrectly flagged as
unused.

The fix ensures that parts.foreach(_.verify(input, context)) is called even
when the element type lookup fails, maintaining proper variable usage tracking
while skipping type compatibility checks for unavailable types.
@kjonescertinia
kjonescertinia requested a review from pwrightcertinia November 23, 2025 19:12
pwrightcertinia
pwrightcertinia previously approved these changes Nov 24, 2025
View reviewed changes
kjonescertinia added 2 commits November 25, 2025 09:27
@kjonescertinia
Merge remote-tracking branch 'origin/main' into fix/issue-398-ghosted…
599dace
…-type-list-unused

# Conflicts:
#	jvm/src/test/scala/com/nawforce/apexlink/plugin/UnusedTest.scala
@kjonescertinia
chore: add changelog entry for #398
3dd7a71
@kjonescertinia
kjonescertinia dismissed pwrightcertinia’s stale review via 3dd7a71 November 25, 2025 09:41
@kjonescertinia
kjonescertinia merged commit d80f95d into main Nov 25, 2025
@kjonescertinia
kjonescertinia deleted the fix/issue-398-ghosted-type-list-unused branch November 25, 2025 10:03
@kjonescertinia kjonescertinia mentioned this pull request Feb 23, 2026
Fix unused warnings for methods implementing external interfaces #432
Merged
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pwrightcertinia pwrightcertinia pwrightcertinia left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

False Positive: Unused Variable Warnings for String Variables with Multi-line Assignments

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kjonescertinia @pwrightcertinia
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.