From b21036990a953309ba6cbac556f146f8572766cd Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Fri, 30 Apr 2021 11:54:36 +0200 Subject: [PATCH] remove unchecked annot from enum --- compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala b/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala index def5cb39bee1..d47fd93abaf4 100644 --- a/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala +++ b/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala @@ -104,7 +104,7 @@ object DesugarEnums { /** The following lists of definitions for an enum type E and known value cases e_0, ..., e_n: * - * private val $values = Array[E](this.e_0,...,this.e_n)(ClassTag[E](classOf[E])): @unchecked + * private val $values = Array[E](this.e_0,...,this.e_n)(ClassTag[E](classOf[E])) * def values = $values.clone * def valueOf($name: String) = $name match { * case "e_0" => this.e_0 @@ -118,15 +118,7 @@ object DesugarEnums { extension (tpe: NamedType) def ofRawEnum = AppliedTypeTree(ref(tpe), rawEnumClassRef) val privateValuesDef = - val uncheckedValues = - // Here we use an unchecked annotation to silence warnings from the init checker. Without it, we get a warning - // that simple enum cases are promoting this from warm to initialised. This is because we are populating the - // array by selecting enum values from `this`, a value under construction. - // Singleton enum values always construct a new anonymous class, which will not be checked by the init-checker, - // so this warning will always persist even if the implementation of the anonymous class is safe. - // TODO: remove @unchecked after https://github.com/lampepfl/dotty-feature-requests/issues/135 is resolved. - Annotated(ArrayLiteral(enumValues, rawEnumClassRef), New(ref(defn.UncheckedAnnot.typeRef), Nil)) - ValDef(nme.DOLLAR_VALUES, TypeTree(), uncheckedValues) + ValDef(nme.DOLLAR_VALUES, TypeTree(), ArrayLiteral(enumValues, rawEnumClassRef)) .withFlags(Private | Synthetic) val valuesDef =