Skip to content

Commit 9ddeda3

Browse files
committed
Allow non-hot values in SeqLiterals
Closes #14460, #14751 Do not ensure that elements in a SeqLiteral are Hot. Review by @liufengyun
1 parent 20842cf commit 9ddeda3

File tree

7 files changed

+8
-38
lines changed

7 files changed

+8
-38
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,9 @@ object Semantic {
12341234

12351235
case SeqLiteral(elems, elemtpt) =>
12361236
val ress = elems.map { elem =>
1237-
eval(elem, thisV, klass).ensureHot("May only use initialized value as method arguments", elem)
1237+
eval(elem, thisV, klass)
12381238
}
1239-
Result(Hot, ress.flatMap(_.errors))
1239+
Result(ress.map(_.value).join, ress.flatMap(_.errors))
12401240

12411241
case Inlined(call, bindings, expansion) =>
12421242
val trace1 = trace.add(expr)

tests/init/neg/enum-desugared.check

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/init/neg/enum.check

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/init/neg/leak-warm.check

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
-- Error: tests/init/neg/leak-warm.scala:18:26 -------------------------------------------------------------------------
2-
18 | val l: List[A] = List(c, d) // error // error
3-
| ^
4-
| Cannot prove that the value is fully initialized. May only use initialized value as method arguments.
5-
-- Error: tests/init/neg/leak-warm.scala:18:29 -------------------------------------------------------------------------
6-
18 | val l: List[A] = List(c, d) // error // error
7-
| ^
8-
| Cannot prove that the value is fully initialized. May only use initialized value as method arguments.
2+
18 | val l: List[A] = List(c, d) // error
3+
| ^^^^
4+
| Cannot prove that the value is fully initialized. Only initialized values may be used as arguments.

tests/init/neg/leak-warm.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ object leakWarm {
1515
}
1616
val c = new C(1, 2)
1717
val d = new D(3, 4)
18-
val l: List[A] = List(c, d) // error // error
18+
val l: List[A] = List(c, d) // error
1919
val l2 = l.map(_.m())
2020
}

tests/init/neg/enum-desugared.scala renamed to tests/init/pos/error-enum-desugared.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object ErrorMessageID {
1414
final val NoExplanationID = $new(1, "NoExplanationID")
1515

1616
private[this] val $values: Array[ErrorMessageID] =
17-
Array(this.LazyErrorId, this.NoExplanationID) // error // error
17+
Array(this.LazyErrorId, this.NoExplanationID)
1818

1919
def values: Array[ErrorMessageID] = $values.clone()
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
enum ErrorMessageID extends java.lang.Enum[ErrorMessageID] {
22
case
33
LazyErrorId,
4-
NoExplanationID // error
4+
NoExplanationID
55
def errorNumber = ordinal - 2
66
}

0 commit comments

Comments
 (0)