--- a/SmallSense__SmalltalkInferencer.st Thu Feb 27 10:15:47 2014 +0000
+++ b/SmallSense__SmalltalkInferencer.st Sat Mar 01 23:34:40 2014 +0000
@@ -12,7 +12,7 @@
SmalltalkParseNodeVisitor subclass:#Phase1
instanceVariableNames:'classInfo sends types'
classVariableNames:''
- poolDictionaries:''
+ poolDictionaries:'SmallSense::SmalltalkInferencerParameters'
privateIn:SmalltalkInferencer
!
@@ -289,7 +289,7 @@
process: tree in: cls info: clsInfo
- | i c |
+ | i c def prereqs |
class := cls.
classInfo := clsInfo.
@@ -309,18 +309,37 @@
self visit:tree.
+ prereqs := nil.
+ def := ProjectDefinition definitionClassForPackage: class package createIfAbsent: false.
+ def notNil ifTrue:[
+ prereqs := def effectivePreRequisites.
+ ].
+
+
"Now, infer variable types based on collected sends"
sends keysAndValuesDo:[:varName :sentSelectors|
- | classes |
+ (types includesKey: varName) ifTrue:[
+ | classes union |
+ classes := (self rootsUnderstanding: sentSelectors) collect:[:each | ClassType new klass: each ].
- classes := self rootsUnderstanding: sentSelectors.
- (types includesKey: varName) ifTrue:[
- (types at: varName) addClasses: classes.
+ prereqs notNil ifTrue:[
+ "/ Make classes in packages on which method's package does **NOT** depend
+ "/ less likely to be correct (by lowering their trustfullness)
+ classes do:[:each |
+ (prereqs includes: each klass package) ifTrue:[
+ each trustfullnessAdd: -20
+ ].
+ ]
+ ].
+ union := UnionType new.
+ union addType: (types at: varName) type.
+ union addTypes: classes.
+ (types at: varName) type: union
].
].
"Created: / 27-11-2011 / 16:22:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified (format): / 26-10-2013 / 13:58:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (format): / 01-03-2014 / 23:19:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!SmalltalkInferencer::Phase1 methodsFor:'visiting'!