#FEATURE by cg cvs_MAIN expecco_ALM_1_10_0 expecco_ALM_1_10_0_8 expecco_ALM_1_11_0 expecco_ALM_1_11_0_2 expecco_ALM_1_11_2
authorClaus Gittinger <cg@exept.de>
Fri, 23 Dec 2016 11:56:55 +0100
branchcvs_MAIN
changeset 1011 193f12bef212
parent 1010 487ba1856c8e
child 1012 ec316e0316af
#FEATURE by cg class: SmallSense::SmalltalkInferencer
SmallSense__SmalltalkInferencer.st
--- 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:[