@@ -329,8 +329,9 @@ class Semantic {
329
329
def widen : List [Value ] = values.map(_.widen).toList
330
330
331
331
extension (value : Value )
332
- def select (field : Symbol , source : Tree , needResolve : Boolean = true ): Contextual [Result ] =
333
- value match {
332
+ def select (field : Symbol , source : Tree , needResolve : Boolean = true ): Contextual [Result ] = log(" select " + field.show, printer, res => res.asInstanceOf [Result ].show) {
333
+ if promoted.isCurrentObjectPromoted then Result (Hot , Nil )
334
+ else value match {
334
335
case Hot =>
335
336
Result (Hot , Errors .empty)
336
337
@@ -376,14 +377,14 @@ class Semantic {
376
377
val errors = resList.flatMap(_.errors)
377
378
Result (value2, errors)
378
379
}
380
+ }
379
381
380
- def call (meth : Symbol , args : List [Value ], superType : Type , source : Tree , needResolve : Boolean = true ): Contextual [Result ] =
382
+ def call (meth : Symbol , args : List [Value ], superType : Type , source : Tree , needResolve : Boolean = true ): Contextual [Result ] = log( " call " + meth.show + " , args = " + args, printer, res => res. asInstanceOf [ Result ].show) {
381
383
def checkArgs = args.flatMap { arg => arg.promote(" May only use initialized value as arguments" , arg.source) }
382
384
383
385
// fast track if the current object is already initialized
384
- if promoted.isCurrentObjectPromoted then return Result (Hot , Nil )
385
-
386
- value match {
386
+ if promoted.isCurrentObjectPromoted then Result (Hot , Nil )
387
+ else value match {
387
388
case Hot =>
388
389
Result (Hot , checkArgs)
389
390
@@ -447,11 +448,13 @@ class Semantic {
447
448
val errors = resList.flatMap(_.errors)
448
449
Result (value2, errors)
449
450
}
451
+ }
450
452
451
453
/** Handle a new expression `new p.C` where `p` is abstracted by `value` */
452
- def instantiate (klass : ClassSymbol , ctor : Symbol , args : List [Value ], source : Tree ): Contextual [Result ] =
454
+ def instantiate (klass : ClassSymbol , ctor : Symbol , args : List [Value ], source : Tree ): Contextual [Result ] = log( " instantiating " + klass.show + " , args = " + args, printer, res => res. asInstanceOf [ Result ].show) {
453
455
val trace1 = trace.add(source)
454
- value match {
456
+ if promoted.isCurrentObjectPromoted then Result (Hot , Nil )
457
+ else value match {
455
458
case Hot =>
456
459
val buffer = new mutable.ArrayBuffer [Error ]
457
460
val args2 = args.map { arg =>
@@ -503,6 +506,7 @@ class Semantic {
503
506
val errors = resList.flatMap(_.errors)
504
507
Result (value2, errors)
505
508
}
509
+ }
506
510
end extension
507
511
508
512
// ----- Promotion ----------------------------------------------------
0 commit comments