Hello,
We found a bug in our code to get a smalltalkClass from a famix one and the solution is that one As you can see, we use the fact that when the classes are not merged their names contains _class. The problem is that we cannot use hasClassScope to distinguish whether the method is a class method on a merged class or a class method on non merged class.
The following code distinguish between the two in a dirty way. In the following test self assert: ( model entityNamed: #'Smalltalk::LANNode.new()') compiledMethod = (LANNode class>>#new). shows that a class method on a merged class/metaclass should still returns a compiled method of the metaclass.
Now is there a better way to do that than to rely on _class?
FAMIXMethod>>smalltalkClass "Return the smalltalk class associated with the receiver. Note that it may be different than doing self parentType because the class and metaclass can be merged." ^ ('*_class' match: self parentType name) ifTrue: [self parentType smalltalkClass] ifFalse: [self hasClassScope ifTrue: [self parentType smalltalkClass class] ifFalse: [self parentType smalltalkClass]]
testWhenMergingClassAndMetaclassAccessWorks "self debug: #testWhenMergingClassAndMetaclassAccessWorks" "this test tests that we can access smalltalk class and compiledMethod from famix when the class and metaclasses are merged" |model importer fmNewMethodName| model := MooseModel new. importer := MooseSqueakClassPackageImporterTask new. importer importerClass: SmalltalkImporter. importer importingContext mergeClassAndMetaclass. importer model: model. importer addFromPackageNamed: #'Moose-TestResources-LAN'. importer run. self assert: (( model entityNamed: LANNode mooseName) smalltalkClass = LANNode). self assert: ( model entityNamed: (LANNode>>#accept:) mooseName) compiledMethod = (LANNode>>#accept:). self assert: ( model entityNamed: LANNode mooseName) isInstanceSide. self deny: ( model entityNamed: (LANNode>>#accept:) mooseName) hasClassScope. self assert: ( model entityNamed: #'Smalltalk::LANNode.new()') hasClassScope. self assert: ( model entityNamed: (LANNode>>#accept:) mooseName) smalltalkClass = LANNode. self assert: ( model entityNamed: #'Smalltalk::LANNode.new()') smalltalkClass = LANNode class. self assert: ( model entityNamed: #'Smalltalk::LANNode.new()') compiledMethod = (LANNode class>>#new).
stef and ussman