--- a/SmallSense__SmalltalkInferencer.st Fri Dec 23 11:56:37 2016 +0100
+++ b/SmallSense__SmalltalkInferencer.st Fri Dec 23 11:56:55 2016 +0100
@@ -74,8 +74,8 @@
documentation
"
A heart of SmallSense - a type inferencer. For given class
- and method source, instance of inferences walks the parse tree
- and annotate each node with inferred type.
+ and method source, instance of inferencer walks the parse tree
+ and annotates each node with inferred type.
[author:]
@@ -610,15 +610,31 @@
^ self.
].
- "/ Some selectors are known / expected to return some numerical values
+ "/ Some selectors are known / expected to return integer
+ (#( #indexOf: #lastIndexOf: #indexOf:startingAt: #lastIndexOf:startingAt:
+ #indexOf:ifAbsent: #lastIndexOf:ifAbsent:
+ #indexOf:startingAt:ifAbsent: #lastIndexOf:startingAt:ifAbsent:
+ #findFirst: #findFirst:ifNone: #findFirst:startingAt:
+ ) includes: selector) ifTrue:[
+ aMessageNode inferedType: (Type withClass: Integer).
+ ^ self.
+ ].
+
+ "/ Some selectors are known / expected to return some numerical values
(#( #+ #- #* #/ #// #\\ ) includes: selector) ifTrue:[
- "/ cg: is this true ? I thnk we should return Magnitude here (think of Charcters...)
+ "/ cg: is this true ? I think we should return Magnitude here (think of Characters...)
aMessageNode inferedType: (Type withClass: Number).
^ self.
].
+ "/ Some selectors are known / expected to return a value holder
+ (#( asValue ) includes: selector) ifTrue:[
+ aMessageNode inferedType: (Type withClass: ValueHolder).
+ ^ self.
+ ].
+
"/ #new / #basicNew: conventionally returns an instance of the class, if receiver is a class.
- (#(#new: #basicNew:) includes: selector) ifTrue:[
+ (#(#new #basicNew #new: #basicNew:) includes: selector) ifTrue:[
| rec type |
rec := aMessageNode receiver.
(rec isSelf and:[class isMetaclass]) ifTrue:[