@@ -140,9 +140,12 @@ object Semantic {
140
140
def hasField (f : Symbol ) = fields.contains(f)
141
141
}
142
142
143
- /** Abstract heap stores abstract warm objects
143
+ /** Abstract heap stores abstract objects
144
144
*
145
145
* The heap serves as cache of summaries for warm objects and is shared for checking all classes.
146
+ *
147
+ * The fact that objects of `ThisRef` are stored in heap is just an engineering convenience.
148
+ * Technically, we can also store the object directly in `ThisRef`.
146
149
*/
147
150
object Heap {
148
151
class Heap (private var map : Map [Ref , Objekt ]) {
@@ -322,6 +325,9 @@ object Semantic {
322
325
def call (meth : Symbol , args : List [ArgInfo ], superType : Type , source : Tree ): Contextual [Result ] =
323
326
value.call(meth, args, superType, source) ++ errors
324
327
328
+ def callConstructor (ctor : Symbol , args : List [ArgInfo ], source : Tree ): Contextual [Result ] =
329
+ value.callConstructor(ctor, args, source) ++ errors
330
+
325
331
def instantiate (klass : ClassSymbol , ctor : Symbol , args : List [ArgInfo ], source : Tree ): Contextual [Result ] =
326
332
value.instantiate(klass, ctor, args, source) ++ errors
327
333
}
@@ -934,7 +940,10 @@ object Semantic {
934
940
935
941
case Select (qual, _) =>
936
942
val res = eval(qual, thisV, klass) ++ errors
937
- res.call(ref.symbol, args, superType = NoType , source = expr)
943
+ if ref.symbol.isConstructor then
944
+ res.callConstructor(ref.symbol, args, source = expr)
945
+ else
946
+ res.call(ref.symbol, args, superType = NoType , source = expr)
938
947
939
948
case id : Ident =>
940
949
id.tpe match
@@ -946,7 +955,10 @@ object Semantic {
946
955
thisValue2.call(id.symbol, args, superType = NoType , expr, needResolve = false )
947
956
case TermRef (prefix, _) =>
948
957
val res = cases(prefix, thisV, klass, id) ++ errors
949
- res.call(id.symbol, args, superType = NoType , source = expr)
958
+ if id.symbol.isConstructor then
959
+ res.callConstructor(id.symbol, args, source = expr)
960
+ else
961
+ res.call(id.symbol, args, superType = NoType , source = expr)
950
962
951
963
case Select (qualifier, name) =>
952
964
val qualRes = eval(qualifier, thisV, klass)
0 commit comments