Skip to content

Commit 2a85f53

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 2a85f53

File tree

6 files changed

+7
-29
lines changed

6 files changed

+7
-29
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ 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
}
12391239
Result(Hot, ress.flatMap(_.errors))
12401240

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/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
}

tests/init/pos/inner-enum.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Outer:
2+
enum MyEnum {
3+
case Case
4+
}

0 commit comments

Comments
 (0)