Small improvement in type inference - infer instvar types from living instances.
--- a/SmallSense__ClassType.st Tue Sep 24 12:42:20 2013 +0100
+++ b/SmallSense__ClassType.st Tue Sep 24 23:01:37 2013 +0100
@@ -17,7 +17,12 @@
!
klass:aClass
+
klass := aClass.
+ (klass == True or:[klass == False]) ifTrue: [
+ klass := Boolean
+ ].
+
"Some manual trustfullness tweaks"
@@ -25,7 +30,7 @@
self trustfullnessAdd: -10.
]
- "Modified: / 17-05-2012 / 19:59:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-09-2013 / 15:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
trustfullness
@@ -96,9 +101,13 @@
printWithoutAnglesOn:aStream
"superclass SmallSenseType says that I am responsible to implement this method"
- klass printOn: aStream
+ klass == UndefinedObject ifTrue:[
+ 'nil' printOn: aStream
+ ] ifFalse:[
+ klass printOn: aStream
+ ].
- "Modified: / 16-12-2011 / 01:54:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-09-2013 / 13:46:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ClassType methodsFor:'testing'!
--- a/SmallSense__Manager.st Tue Sep 24 12:42:20 2013 +0100
+++ b/SmallSense__Manager.st Tue Sep 24 23:01:37 2013 +0100
@@ -165,13 +165,26 @@
delayedUpdateInfoForClass: class
- | superclass |
+ | superclass info instVarNames instVarTypes |
superclass := class superclass.
superclass notNil ifTrue:[self updateInfoForClass: superclass].
+ info := self infoForClass: class.
+ instVarNames := class allInstVarNames.
+ instVarTypes := instVarNames collect: [:instvar | info infoForInstvar: instvar ].
+
+ class allInstancesDo: [:instance |
+ 1 to: instVarNames size do:[:i|
+ | instVarType |
+
+ instVarType := instVarTypes at:i.
+ instVarType union: ((Type withClass: (instance instVarAt: i) class) type trustfullness: 70).
+ ].
+ ].
class methodsDo:[:mthd|updater add:mthd].
"Created: / 27-11-2011 / 18:04:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-09-2013 / 13:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
delayedUpdateInfoForClassOrMethod: classOrMethod
--- a/SmallSense__Type.st Tue Sep 24 12:42:20 2013 +0100
+++ b/SmallSense__Type.st Tue Sep 24 23:01:37 2013 +0100
@@ -154,11 +154,11 @@
printOn:aStream
- aStream nextPut:$<.
+ aStream nextPut:$<; space.
self printWithoutAnglesOn: aStream.
- aStream nextPut:$>.
+ aStream space; nextPut:$>.
- "Modified: / 16-12-2011 / 01:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-09-2013 / 13:47:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
printWithoutAnglesOn: aStream
--- a/SmallSense__UnionType.st Tue Sep 24 12:42:20 2013 +0100
+++ b/SmallSense__UnionType.st Tue Sep 24 23:01:37 2013 +0100
@@ -181,10 +181,10 @@
] ifFalse:[
types
do:[:each|each printWithoutAnglesOn:aStream]
- separatedBy:[aStream nextPut:$|]
+ separatedBy:[aStream space; nextPut:$|; space.]
]
- "Modified: / 16-12-2011 / 01:54:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-09-2013 / 13:47:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!UnionType methodsFor:'private'!
@@ -195,11 +195,11 @@
self updateTrustfullness.
types size < 1 ifTrue:[ ^ self ].
- "Experimental - remove those with trustfullness less than mine"
-
+ "Experimental - remove those with trustfullness less than mine"
types := types reject:[:type|type trustfullness < trustfullness ].
"Created: / 17-05-2012 / 19:38:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-09-2013 / 15:31:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
updateTrustfullness