pharo icon indicating copy to clipboard operation
pharo copied to clipboard

deleting a pragma leaves ObsoleteClasses in the PragmaCache

Open SabineMa opened this issue 4 months ago • 3 comments

Bug description Deleting a class which has method(s) with Pragmas leads to having obsolete classes in the PragmaCache.

To Reproduce Steps to reproduce the behavior:

  1. Go to Launcher and create a new P14 image
  2. Create a new class and add a method with a pragma
Image
  1. Delete this class
  2. Now you have an obsolete class in the PragmaCache Pragma pragmaCache at: #aPragmaForDemo
Image

additionally, I wonder that, each time, I save this method with the pragma, we have a new entry in the PragmaCache. I think, this is a Bug, too. This is the reason why in the screen are 2 entries - I saved that method twice.

Expected behavior 1.) Deleting a class should remove the Pragmas of the associated methods from the PragmaCache. 2.) Saving a method a second time should only add it if not yet there (I am not sure about this, perhaps it is by intent?)

Version information:

  • OS: ;MacOS
  • Pharo Version: tested with P11 and P14

Additional context I found this when working with Tealight: https://github.com/astares/Tealight/issues/6

SabineMa avatar Oct 25 '25 12:10 SabineMa

Tx for the report.

Ducasse avatar Oct 25 '25 13:10 Ducasse

We already filter for #isInstalled. We can add to check if the class is Obsolete, e.g. in pragmaNamed:

	^ (pragmas select: [ :each | each method isInstalled and: [ each methodClass isObsolete not  ]]) asArray

MarcusDenker avatar Oct 31 '25 14:10 MarcusDenker

The Obsolete classes in the cache will get cleaned up eventually (when the class gets GCed)

MarcusDenker avatar Oct 31 '25 14:10 MarcusDenker