Skip to content

Commit d02edc7

Browse files
committed
Update check files
1 parent fe235e9 commit d02edc7

File tree

9 files changed

+38
-29
lines changed

9 files changed

+38
-29
lines changed

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import NameKinds.SuperAccessorName
1212

1313
import ast.tpd.*
1414
import config.Printers.init as printer
15-
import reporting.trace.force as log
15+
import reporting.trace as log
1616

1717
import Errors.*
1818

@@ -1669,7 +1669,16 @@ object Semantic:
16691669
if thisV.isThisRef || !thisV.asInstanceOf[Warm].isPopulatingParams then tpl.body.foreach {
16701670
case vdef : ValDef if !vdef.symbol.is(Flags.Lazy) && !vdef.rhs.isEmpty =>
16711671
val res = eval(vdef.rhs, thisV, klass)
1672-
thisV.updateField(vdef.symbol, res)
1672+
// TODO: Improve promotion to avoid handling enum initialization specially
1673+
//
1674+
// The failing case is tests/init/pos/i12544.scala due to promotion failure.
1675+
if vdef.symbol.name == nme.DOLLAR_VALUES
1676+
&& vdef.symbol.is(Flags.Synthetic)
1677+
&& vdef.symbol.owner.companionClass.isAllOf(Flags.Enum)
1678+
then
1679+
thisV.updateField(vdef.symbol, Hot)
1680+
else
1681+
thisV.updateField(vdef.symbol, res)
16731682
fieldsChanged = true
16741683

16751684
case _: MemberDef =>

tests/init/neg/closureLeak.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
99
| ^^^^^^^^^^^^^^^^^
1010
|
11-
| Promoting the value to hot failed due to the following problem:
11+
| Promoting the value to hot (transitively initialized) failed due to the following problem:
1212
| Cannot prove the method argument is hot. Only hot values are safe to leak.
1313
| Found = ThisRef[class Outer].
1414
| Non initialized field(s): value p. Promotion trace:

tests/init/neg/cycle-structure.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/cycle-structure.scala:3:13 --------------------------------------------------------------------
22
3 | val x = B(this) // error
33
| ^^^^^^^
4-
| Problematic object instantiation: arg 1 is not hot. Calling trace:
4+
| Problematic object instantiation: arg 1 is not hot (transitively initialized). Calling trace:
55
| -> case class A(b: B) { [ cycle-structure.scala:1 ]
66
| ^
77
| -> val x = B(this) // error [ cycle-structure.scala:3 ]
@@ -16,7 +16,7 @@
1616
-- Error: tests/init/neg/cycle-structure.scala:9:13 --------------------------------------------------------------------
1717
9 | val x = A(this) // error
1818
| ^^^^^^^
19-
| Problematic object instantiation: arg 1 is not hot. Calling trace:
19+
| Problematic object instantiation: arg 1 is not hot (transitively initialized). Calling trace:
2020
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
2121
| ^
2222
| -> val x = A(this) // error [ cycle-structure.scala:9 ]

tests/init/neg/i15363.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/i15363.scala:3:10 -----------------------------------------------------------------------------
22
3 | val b = new B(this) // error
33
| ^^^^^^^^^^^
4-
| Problematic object instantiation: arg 1 is not hot. Calling trace:
4+
| Problematic object instantiation: arg 1 is not hot (transitively initialized). Calling trace:
55
| -> class A: [ i15363.scala:1 ]
66
| ^
77
| -> val b = new B(this) // error [ i15363.scala:3 ]

tests/init/neg/inherit-non-hot.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| -> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ]
1212
| ^^^^^^^^^^^^^^^
1313
|
14-
| Promoting the value to hot failed due to the following problem:
14+
| Promoting the value to hot (transitively initialized) failed due to the following problem:
1515
| Cannot prove that the field value a is hot. Found = Cold. Promotion trace:
1616
| -> class B(a: A) { [ inherit-non-hot.scala:10 ]
1717
| ^^^^

tests/init/neg/promotion-loop.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| -> println(b) // error [ promotion-loop.scala:16 ]
99
| ^
1010
|
11-
| Promoting the value to hot failed due to the following problem:
11+
| Promoting the value to hot (transitively initialized) failed due to the following problem:
1212
| Cannot prove that the field value outer is hot. Found = ThisRef[class Test].
1313
| Non initialized field(s): value n. Promotion trace:
1414
| -> val outer = test [ promotion-loop.scala:12 ]

tests/init/neg/promotion-segment3.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
| -> bar(new B) // error [ promotion-segment3.scala:9 ]
99
| ^^^^^
1010
|
11-
| Promoting the value to hot failed due to the following problem:
11+
| Promoting the value to hot (transitively initialized) failed due to the following problem:
1212
| Promotion cancelled as the value contains inner class C.

tests/init/neg/secondary-ctor4.check

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/secondary-ctor4.scala:54:14 -------------------------------------------------------------------
22
54 | val c = new C(b, 5) // error
33
| ^^^^^^^^^^^
4-
| Problematic object instantiation: arg 1 is not hot. Calling trace:
4+
| Problematic object instantiation: arg 1 is not hot (transitively initialized). Calling trace:
55
| -> class D { [ secondary-ctor4.scala:52 ]
66
| ^
77
| -> val c = new C(b, 5) // error [ secondary-ctor4.scala:54 ]
@@ -24,21 +24,21 @@
2424
-- Error: tests/init/neg/secondary-ctor4.scala:42:4 --------------------------------------------------------------------
2525
42 | new A(new B(new D)) // error
2626
| ^^^^^^^^^^^^^^^^^^^
27-
| Problematic object instantiation: the outer M.this and arg 1 are not hot. Calling trace:
28-
| -> class N(d: D) extends M(d) { [ secondary-ctor4.scala:59 ]
29-
| ^
30-
| -> def this(d: D) = { [ secondary-ctor4.scala:7 ]
31-
| ^
32-
| -> new A(new B(new D)) // error [ secondary-ctor4.scala:42 ]
33-
| ^^^^^^^^^^^^^^^^^^^
27+
|Problematic object instantiation: the outer M.this and arg 1 are not hot (transitively initialized). Calling trace:
28+
|-> class N(d: D) extends M(d) { [ secondary-ctor4.scala:59 ]
29+
| ^
30+
|-> def this(d: D) = { [ secondary-ctor4.scala:7 ]
31+
| ^
32+
|-> new A(new B(new D)) // error [ secondary-ctor4.scala:42 ]
33+
| ^^^^^^^^^^^^^^^^^^^
3434
|
35-
| It leads to the following error during object initialization:
36-
| Access field value n on a cold object. Calling trace:
37-
| -> def this(b: B) = { [ secondary-ctor4.scala:17 ]
38-
| ^
39-
| -> Inner().foo() [ secondary-ctor4.scala:26 ]
40-
| ^^^^^^^
41-
| -> class Inner() { [ secondary-ctor4.scala:21 ]
42-
| ^
43-
| -> println(b.n) [ secondary-ctor4.scala:23 ]
44-
| ^^^
35+
|It leads to the following error during object initialization:
36+
|Access field value n on a cold object. Calling trace:
37+
|-> def this(b: B) = { [ secondary-ctor4.scala:17 ]
38+
| ^
39+
|-> Inner().foo() [ secondary-ctor4.scala:26 ]
40+
| ^^^^^^^
41+
|-> class Inner() { [ secondary-ctor4.scala:21 ]
42+
| ^
43+
|-> println(b.n) [ secondary-ctor4.scala:23 ]
44+
| ^^^

tests/init/neg/t3273.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| -> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
99
| ^^^^^^^^^^^^^^^
1010
|
11-
| Promoting the value to hot failed due to the following problem:
11+
| Promoting the value to hot (transitively initialized) failed due to the following problem:
1212
| Access non-initialized value num1. Promotion trace:
1313
| -> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
1414
| ^^^^
@@ -22,7 +22,7 @@
2222
| -> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424
|
25-
| Promoting the value to hot failed due to the following problem:
25+
| Promoting the value to hot (transitively initialized) failed due to the following problem:
2626
| Access non-initialized value num2. Promotion trace:
2727
| -> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]
2828
| ^^^^

0 commit comments

Comments
 (0)