From 7c7d7f47cef499332799fdff62078b8a2acc0b0d Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Fri, 15 Jan 2021 11:52:16 +0100 Subject: [PATCH 1/2] Fix #11118: check irrefutable pattern def in 3.0 After #10793, we can perform the check in 3.0 --- compiler/src/dotty/tools/dotc/typer/Checking.scala | 1 - tests/neg/i11118.check | 4 ++++ tests/neg/i11118.scala | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i11118.check create mode 100644 tests/neg/i11118.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 0c654c3fb024..71a642293e29 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -700,7 +700,6 @@ trait Checking { def check(pat: Tree, pt: Type): Boolean = (pt <:< pat.tpe) || fail(pat, pt) def recur(pat: Tree, pt: Type): Boolean = - !sourceVersion.isAtLeast(`3.1`) || // only for 3.1 for now since mitigations work only after this PR pt.hasAnnotation(defn.UncheckedAnnot) || { patmatch.println(i"check irrefutable $pat: ${pat.tpe} against $pt") pat match { diff --git a/tests/neg/i11118.check b/tests/neg/i11118.check new file mode 100644 index 000000000000..5b58132eeafb --- /dev/null +++ b/tests/neg/i11118.check @@ -0,0 +1,4 @@ +-- Error: tests/neg/i11118.scala:2:6 ----------------------------------------------------------------------------------- +2 | val (a,b) = (1,2,3) // error + | ^ + | this case is unreachable since type (Int, Int, Int) is not a subclass of class Tuple2 diff --git a/tests/neg/i11118.scala b/tests/neg/i11118.scala new file mode 100644 index 000000000000..095a66999d3d --- /dev/null +++ b/tests/neg/i11118.scala @@ -0,0 +1,3 @@ +class Foo { + val (a,b) = (1,2,3) // error +} From 77730eb52e54cd4b008e38fb7d5a1d3528b8cf64 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Mon, 18 Jan 2021 10:13:15 +0100 Subject: [PATCH 2/2] Fix bootstrap --- .../quoted/runtime/impl/QuotesImpl.scala | 4 +-- .../tools/backend/jvm/BCodeBodyBuilder.scala | 12 ++++----- .../tools/backend/jvm/BCodeHelpers.scala | 2 +- .../tools/backend/jvm/BCodeSkelBuilder.scala | 2 +- .../dotty/tools/backend/sjs/JSCodeGen.scala | 26 +++++++++---------- .../tools/backend/sjs/JSConstructorGen.scala | 4 +-- .../tools/backend/sjs/JSExportsGen.scala | 2 +- .../src/dotty/tools/dotc/ast/Desugar.scala | 6 ++--- .../dotty/tools/dotc/ast/TreeTypeMap.scala | 3 ++- compiler/src/dotty/tools/dotc/ast/tpd.scala | 2 +- .../dotty/tools/dotc/config/Settings.scala | 2 +- .../dotty/tools/dotc/core/Annotations.scala | 2 +- .../tools/dotc/core/ConstraintHandling.scala | 4 +-- .../tools/dotc/core/OrderingConstraint.scala | 2 +- .../dotty/tools/dotc/core/TypeComparer.scala | 10 +++---- .../dotty/tools/dotc/core/TypeErasure.scala | 2 +- .../dotc/core/classfile/ClassfileParser.scala | 2 +- .../tools/dotc/core/tasty/TastyPickler.scala | 2 +- .../tools/dotc/core/tasty/TreePickler.scala | 8 +++--- .../core/unpickleScala2/Scala2Unpickler.scala | 4 +-- .../dotty/tools/dotc/parsing/Parsers.scala | 4 +-- .../dotty/tools/dotc/plugins/Plugins.scala | 2 +- .../tools/dotc/printing/PlainPrinter.scala | 2 +- .../tools/dotc/printing/RefinedPrinter.scala | 2 +- .../tools/dotc/quoted/PickledQuotes.scala | 2 +- .../dotty/tools/dotc/reporting/messages.scala | 2 +- .../dotty/tools/dotc/semanticdb/Scala3.scala | 4 +-- .../dotc/transform/ArrayConstructors.scala | 4 +-- .../tools/dotc/transform/CapturedVars.scala | 2 +- .../tools/dotc/transform/Constructors.scala | 2 +- .../dotc/transform/ElimOuterSelect.scala | 2 +- .../tools/dotc/transform/ElimRepeated.scala | 6 ++--- .../dotty/tools/dotc/transform/Erasure.scala | 6 ++--- .../tools/dotc/transform/ExpandSAMs.scala | 6 ++--- .../tools/dotc/transform/ExplicitOuter.scala | 2 +- .../dotc/transform/FullParameterization.scala | 2 +- .../dotty/tools/dotc/transform/Memoize.scala | 2 +- .../dotty/tools/dotc/transform/Mixin.scala | 2 +- .../tools/dotc/transform/PatternMatcher.scala | 8 +++--- .../tools/dotc/transform/PickleQuotes.scala | 2 +- .../tools/dotc/transform/PostTyper.scala | 2 +- .../dotty/tools/dotc/transform/Splicer.scala | 2 +- .../tools/dotc/transform/SuperAccessors.scala | 4 +-- .../dotc/transform/TransformByNameApply.scala | 2 +- .../tools/dotc/transform/TreeChecker.scala | 2 +- .../dotc/transform/TupleOptimizations.scala | 10 +++---- .../tools/dotc/transform/init/Checking.scala | 2 +- .../dotc/transform/init/Summarization.scala | 6 ++--- .../transform/sjs/AddLocalJSFakeNews.scala | 2 +- .../transform/sjs/JUnitBootstrappers.scala | 4 +-- .../dotc/transform/sjs/PrepJSInterop.scala | 2 +- .../dotty/tools/dotc/typer/Applications.scala | 4 +-- .../src/dotty/tools/dotc/typer/Deriving.scala | 2 +- .../src/dotty/tools/dotc/typer/Dynamic.scala | 2 +- .../src/dotty/tools/dotc/typer/Inliner.scala | 6 ++--- .../src/dotty/tools/dotc/typer/Namer.scala | 10 +++---- .../tools/dotc/typer/QuotesAndSplices.scala | 2 +- .../dotty/tools/dotc/typer/Synthesizer.scala | 2 +- .../src/dotty/tools/dotc/typer/Typer.scala | 20 +++++++------- .../dotty/tools/dotc/util/ParsedComment.scala | 2 +- .../tools/repl/CollectTopLevelImports.scala | 2 +- .../runtime/impl/printers/SourceCode.scala | 14 +++++----- library/src/scala/quoted/ExprMap.scala | 4 +-- 63 files changed, 137 insertions(+), 136 deletions(-) diff --git a/compiler/src-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala index 04606a9a9377..4e309b344df1 100644 --- a/compiler/src-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala @@ -224,7 +224,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler object ClassDef extends ClassDefModule: def copy(original: Tree)(name: String, constr: DefDef, parents: List[Tree], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement]): ClassDef = { - val dotc.ast.Trees.TypeDef(_, originalImpl: tpd.Template) = original + val dotc.ast.Trees.TypeDef(_, originalImpl: tpd.Template) = original: @unchecked tpd.cpy.TypeDef(original)(name.toTypeName, tpd.cpy.Template(originalImpl)(constr, parents, derived, selfOpt.getOrElse(tpd.EmptyValDef), body)) } def unapply(cdef: ClassDef): (String, DefDef, List[Tree /* Term | TypeTree */], List[TypeTree], Option[ValDef], List[Statement]) = @@ -956,7 +956,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler def qualifier: Term = self.qualifier def name: String = self.name.toString def level: Int = - val NameKinds.OuterSelectName(_, levels) = self.name + val NameKinds.OuterSelectName(_, levels) = self.name: @unchecked levels end extension end SelectOuterMethods diff --git a/compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala b/compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala index 2b21762fba72..b597b28be6a4 100644 --- a/compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala +++ b/compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala @@ -183,7 +183,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder { bc.aload(elementType) } else if (isArraySet(code)) { - val List(a1, a2) = args + val List(a1, a2) = args: @unchecked genLoad(a1, INT) genLoad(a2) generatedType = UNIT @@ -335,7 +335,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder { // but I was able to derrive it by reading // AbstractValidatingLambdaMetafactory.validateMetafactoryArgs - val DesugaredSelect(prefix, _) = fun + val DesugaredSelect(prefix, _) = fun: @unchecked genLoad(prefix) } @@ -679,7 +679,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder { lineNumber(app) app match { case Apply(_, args) if app.symbol eq defn.newArrayMethod => - val List(elemClaz, Literal(c: Constant), ArrayValue(_, dims)) = args + val List(elemClaz, Literal(c: Constant), ArrayValue(_, dims)) = args: @unchecked generatedType = toTypeKind(c.typeValue) mkArrayConstructorCall(generatedType.asArrayBType, app, dims) @@ -756,7 +756,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder { if (invokeStyle.hasInstance) genLoadQualifier(fun) genLoadArguments(args, paramTKs(app)) - val DesugaredSelect(qual, name) = fun // fun is a Select, also checked in genLoadQualifier + val DesugaredSelect(qual, name) = fun: @unchecked // fun is a Select, also checked in genLoadQualifier val isArrayClone = name == nme.clone_ && qual.tpe.widen.isInstanceOf[JavaArrayType] if (isArrayClone) { // Special-case Array.clone, introduced in 36ef60e. The goal is to generate this call @@ -799,7 +799,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder { } // end of genApply() private def genArrayValue(av: tpd.JavaSeqLiteral): BType = { - val ArrayValue(tpt, elems) = av + val ArrayValue(tpt, elems) = av: @unchecked lineNumber(av) genArray(elems, tpt) @@ -1287,7 +1287,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder { import ScalaPrimitivesOps.{ ZNOT, ZAND, ZOR, EQ } // lhs and rhs of test - lazy val DesugaredSelect(lhs, _) = fun + lazy val DesugaredSelect(lhs, _) = fun: @unchecked val rhs = if (args.isEmpty) tpd.EmptyTree else args.head // args.isEmpty only for ZNOT def genZandOrZor(and: Boolean): Unit = { diff --git a/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala b/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala index 2391574edeb2..fe2a31e045e7 100644 --- a/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala +++ b/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala @@ -148,7 +148,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters { // sorting ensures nested classes are listed after their enclosing class thus satisfying the Eclipse Java compiler for (nestedClass <- allNestedClasses.sortBy(_.internalName.toString)) { // Extract the innerClassEntry - we know it exists, enclosingNestedClassesChain only returns nested classes. - val Some(e) = nestedClass.innerClassAttributeEntry + val Some(e) = nestedClass.innerClassAttributeEntry: @unchecked jclass.visitInnerClass(e.name, e.outerName, e.innerName, e.flags) } } diff --git a/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala b/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala index 9401307e8d62..82448c616629 100644 --- a/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala +++ b/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala @@ -663,7 +663,7 @@ trait BCodeSkelBuilder extends BCodeHelpers { val origSym = dd.symbol.asTerm val newSym = makeStatifiedDefSymbol(origSym, origSym.name) tpd.DefDef(newSym, { paramRefss => - val selfParamRef :: regularParamRefs = paramRefss.head + val selfParamRef :: regularParamRefs = paramRefss.head: @unchecked val enclosingClass = origSym.owner.asClass new TreeTypeMap( typeMap = _.substThis(enclosingClass, selfParamRef.symbol.termRef) diff --git a/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala b/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala index 84c606251f34..a8d6bec1c188 100644 --- a/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala +++ b/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala @@ -1201,7 +1201,7 @@ class JSCodeGen()(using genCtx: Context) { } val (beforeSuper, superCall :: afterSuper) = - bodyStats.span(!_.isInstanceOf[js.JSSuperConstructorCall]) + bodyStats.span(!_.isInstanceOf[js.JSSuperConstructorCall]): @unchecked assert(!beforeSuper.exists(_.isInstanceOf[js.VarDef]), s"Trying to move a local VarDef after the super constructor call of a non-native JS class at ${body.pos}") @@ -1728,7 +1728,7 @@ class JSCodeGen()(using genCtx: Context) { */ private def genSuperCall(tree: Apply, isStat: Boolean): js.Tree = { implicit val pos = tree.span - val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree + val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree: @unchecked val sym = fun.symbol if (sym == defn.Any_getClass) { @@ -1769,7 +1769,7 @@ class JSCodeGen()(using genCtx: Context) { private def genApplyNew(tree: Apply): js.Tree = { implicit val pos: SourcePosition = tree.sourcePos - val Apply(fun @ Select(New(tpt), nme.CONSTRUCTOR), args) = tree + val Apply(fun @ Select(New(tpt), nme.CONSTRUCTOR), args) = tree: @unchecked val ctor = fun.symbol val tpe = tpt.tpe @@ -1818,7 +1818,7 @@ class JSCodeGen()(using genCtx: Context) { acquireContextualJSClassValue { jsClassValue => implicit val pos: Position = tree.span - val Apply(fun @ Select(New(tpt), _), args) = tree + val Apply(fun @ Select(New(tpt), _), args) = tree: @unchecked val cls = tpt.tpe.typeSymbol val ctor = fun.symbol @@ -2504,7 +2504,7 @@ class JSCodeGen()(using genCtx: Context) { implicit val pos = tree.span - val Apply(fun, args) = tree + val Apply(fun, args) = tree: @unchecked val arrayObj = qualifierOf(fun) val genArray = genExpr(arrayObj) @@ -2543,7 +2543,7 @@ class JSCodeGen()(using genCtx: Context) { /* JavaScript is single-threaded, so we can drop the * synchronization altogether. */ - val Apply(fun, List(arg)) = tree + val Apply(fun, List(arg)) = tree: @unchecked val receiver = qualifierOf(fun) val genReceiver = genExpr(receiver) @@ -2811,7 +2811,7 @@ class JSCodeGen()(using genCtx: Context) { private def genJSSuperCall(tree: Apply, isStat: Boolean): js.Tree = { acquireContextualJSClassValue { explicitJSSuperClassValue => implicit val pos = tree.span - val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree + val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree: @unchecked val sym = fun.symbol val genReceiver = genExpr(qual) @@ -2887,7 +2887,7 @@ class JSCodeGen()(using genCtx: Context) { /** Gen JS code for a switch-`Match`, which is translated into an IR `js.Match`. */ def genMatch(tree: Tree, isStat: Boolean): js.Tree = { implicit val pos = tree.span - val Match(selector, cases) = tree + val Match(selector, cases) = tree: @unchecked def abortMatch(msg: String): Nothing = throw new FatalError(s"$msg in switch-like pattern match at ${tree.span}: $tree") @@ -3098,7 +3098,7 @@ class JSCodeGen()(using genCtx: Context) { val call = if (isStaticCall) { genApplyStatic(sym, formalCaptures.map(_.ref) ::: actualParams) } else { - val thisCaptureRef :: argCaptureRefs = formalCaptures.map(_.ref) + val thisCaptureRef :: argCaptureRefs = formalCaptures.map(_.ref): @unchecked if (!sym.owner.isNonNativeJSClass || sym.isJSExposed) genApplyMethodMaybeStatically(thisCaptureRef, sym, argCaptureRefs ::: actualParams) else @@ -3110,7 +3110,7 @@ class JSCodeGen()(using genCtx: Context) { val funInterfaceSym = functionalInterface.tpe.typeSymbol if (jsdefn.isJSThisFunctionClass(funInterfaceSym)) { - val thisParam :: otherParams = formalParams + val thisParam :: otherParams = formalParams: @unchecked js.Closure( arrow = false, formalCaptures, @@ -3610,7 +3610,7 @@ class JSCodeGen()(using genCtx: Context) { */ private def genReflectiveCall(tree: Apply, isSelectDynamic: Boolean): js.Tree = { implicit val pos = tree.span - val Apply(fun @ Select(receiver, _), args) = tree + val Apply(fun @ Select(receiver, _), args) = tree: @unchecked val selectedValueTree = js.Apply(js.ApplyFlags.empty, genExpr(receiver), js.MethodIdent(selectedValueMethodName), Nil)(jstpe.AnyType) @@ -3875,7 +3875,7 @@ class JSCodeGen()(using genCtx: Context) { private def genCaptureValuesFromFakeNewInstance(tree: Tree): List[js.Tree] = { implicit val pos: Position = tree.span - val Apply(fun @ Select(New(_), _), args) = tree + val Apply(fun @ Select(New(_), _), args) = tree: @unchecked val sym = fun.symbol /* We use the same strategy as genActualJSArgs to detect which parameters were @@ -4188,7 +4188,7 @@ class JSCodeGen()(using genCtx: Context) { pathName.split('.').toList def parseGlobalPath(pathName: String): Global = { - val globalRef :: path = parsePath(pathName) + val globalRef :: path = parsePath(pathName): @unchecked Global(globalRef, path) } diff --git a/compiler/src/dotty/tools/backend/sjs/JSConstructorGen.scala b/compiler/src/dotty/tools/backend/sjs/JSConstructorGen.scala index da4db4760551..4b85b73451cd 100644 --- a/compiler/src/dotty/tools/backend/sjs/JSConstructorGen.scala +++ b/compiler/src/dotty/tools/backend/sjs/JSConstructorGen.scala @@ -270,7 +270,7 @@ object JSConstructorGen { (prepStats, applyCtor) } val js.ApplyStatic(_, _, js.MethodIdent(ctorName), js.This() :: ctorArgs) = - applyCtor + applyCtor: @unchecked assert(ctorName.isConstructor, s"unexpected super constructor call to non-constructor $ctorName at ${applyCtor.pos}") (prepStats, ctorName, ctorArgs) @@ -357,7 +357,7 @@ object JSConstructorGen { case _: js.JSSuperConstructorCall => true case _ => false } - } + }: @unchecked val ctorToChildren = secondaryCtors.map { ctor => findCtorForwarderCall(ctor.body.get) -> ctor diff --git a/compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala b/compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala index def0afec0b76..b09c1ffeac0d 100644 --- a/compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala +++ b/compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala @@ -390,7 +390,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) { None } else { val formalArgsRegistry = new FormalArgsRegistry(1, false) - val List(arg) = formalArgsRegistry.genFormalArgs() + val List(arg) = formalArgsRegistry.genFormalArgs(): @unchecked val body = genExportSameArgc(jsName, formalArgsRegistry, setters.map(Exported.apply), static, None) Some((arg, body)) } diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 59d5be66bc78..7fd7d3cd1ac1 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -390,7 +390,7 @@ object desugar { /** The expansion of a class definition. See inline comments for what is involved */ def classDef(cdef: TypeDef)(using Context): Tree = { - val impl @ Template(constr0, _, self, _) = cdef.rhs + val impl @ Template(constr0, _, self, _) = cdef.rhs: @unchecked val className = normalizeName(cdef, impl).asTypeName val parents = impl.parents val mods = cdef.mods @@ -750,7 +750,7 @@ object desugar { enumCompanionRef match { case ref: TermRefTree => // have the enum import watch the companion object - val (modVal: ValDef) :: _ = companions + val (modVal: ValDef) :: _ = companions: @unchecked ref.watching(modVal) case _ => } @@ -1139,7 +1139,7 @@ object desugar { /** Expand variable identifier x to x @ _ */ def patternVar(tree: Tree)(using Context): Bind = { - val Ident(name) = unsplice(tree) + val Ident(name) = unsplice(tree): @unchecked Bind(name, Ident(nme.WILDCARD)).withSpan(tree.span) } diff --git a/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala b/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala index fddde05d9a31..f13a243b4a10 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala @@ -140,9 +140,10 @@ class TreeTypeMap( private def transformAllParamss(paramss: List[ParamClause]): (TreeTypeMap, List[ParamClause]) = paramss match case params :: paramss1 => - val (tmap1, params1: ParamClause) = (params: @unchecked) match + val (tmap1, params1: ParamClause) = (params: @unchecked) match { case ValDefs(vparams) => transformDefs(vparams) case TypeDefs(tparams) => transformDefs(tparams) + }: @unchecked val (tmap2, paramss2) = tmap1.transformAllParamss(paramss1) (tmap2, params1 :: paramss2) case nil => diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 60201ae532a0..7d26b1efdd41 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -287,7 +287,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { ta.assignType(untpd.TypeDef(sym.name, TypeTree(sym.info)), sym) def ClassDef(cls: ClassSymbol, constr: DefDef, body: List[Tree], superArgs: List[Tree] = Nil)(using Context): TypeDef = { - val firstParent :: otherParents = cls.info.parents + val firstParent :: otherParents = cls.info.parents: @unchecked val superRef = if (cls.is(Trait)) TypeTree(firstParent) else { diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index c5eee24ba6ae..dcef7c7f6912 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -93,7 +93,7 @@ object Settings { } def tryToSet(state: ArgsSummary): ArgsSummary = { - val ArgsSummary(sstate, arg :: args, errors, warnings) = state + val ArgsSummary(sstate, arg :: args, errors, warnings) = state: @unchecked def update(value: Any, args: List[String]) = var dangers = warnings val value1 = diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index 4245ae3ef0ec..547e1d6b2ee9 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -184,7 +184,7 @@ object Annotations { def unapply(ann: Annotation)(using Context): Option[Symbol] = if (ann.symbol == defn.ChildAnnot) { - val AppliedType(_, (arg: NamedType) :: Nil) = ann.tree.tpe + val AppliedType(_, (arg: NamedType) :: Nil) = ann.tree.tpe: @unchecked Some(arg.symbol) } else None diff --git a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala index 97b4f73cfdec..b8017f26e5ba 100644 --- a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala +++ b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala @@ -111,7 +111,7 @@ trait ConstraintHandling { (c1 eq constraint) || { constraint = c1 - val TypeBounds(lo, hi) = constraint.entry(param) + val TypeBounds(lo, hi) = constraint.entry(param): @unchecked isSub(lo, hi) } end addOneBound @@ -226,7 +226,7 @@ trait ConstraintHandling { */ protected final def isSatisfiable(using Context): Boolean = constraint.forallParams { param => - val TypeBounds(lo, hi) = constraint.entry(param) + val TypeBounds(lo, hi) = constraint.entry(param): @unchecked isSub(lo, hi) || { report.log(i"sub fail $lo <:< $hi") false diff --git a/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala b/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala index 01cadbc096dc..f8619e683520 100644 --- a/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala +++ b/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala @@ -538,7 +538,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds, if (tl.isInstanceOf[HKLambda]) { // HKLambdas are hash-consed, need to create an artificial difference by adding // a LazyRef to a bound. - val TypeBounds(lo, hi) :: pinfos1 = tl.paramInfos + val TypeBounds(lo, hi) :: pinfos1 = tl.paramInfos: @unchecked paramInfos = TypeBounds(lo, LazyRef(hi)) :: pinfos1 } ensureFresh(tl.newLikeThis(tl.paramNames, paramInfos, tl.resultType)) diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 5891c1509504..add828f9616e 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -2022,8 +2022,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling def lubArgs(args1: List[Type], args2: List[Type], tparams: List[TypeParamInfo], canConstrain: Boolean = false): List[Type] = tparams match { case tparam :: tparamsRest => - val arg1 :: args1Rest = args1 - val arg2 :: args2Rest = args2 + val arg1 :: args1Rest = args1: @unchecked + val arg2 :: args2Rest = args2: @unchecked val common = singletonInterval(arg1, arg2) val v = tparam.paramVarianceSign val lubArg = @@ -2054,8 +2054,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling def glbArgs(args1: List[Type], args2: List[Type], tparams: List[TypeParamInfo]): List[Type] = tparams match { case tparam :: tparamsRest => - val arg1 :: args1Rest = args1 - val arg2 :: args2Rest = args2 + val arg1 :: args1Rest = args1: @unchecked + val arg2 :: args2Rest = args2: @unchecked val common = singletonInterval(arg1, arg2) val v = tparam.paramVarianceSign val glbArg = @@ -2781,7 +2781,7 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) { cas } - val defn.MatchCase(pat, body) = cas1 + val defn.MatchCase(pat, body) = cas1: @unchecked if (isSubType(scrut, pat)) // `scrut` is a subtype of `pat`: *It's a Match!* diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index b5bd1cfb92bc..c970bf4b9067 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -515,7 +515,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean } private def eraseArray(tp: Type)(using Context) = { - val defn.ArrayOf(elemtp) = tp + val defn.ArrayOf(elemtp) = tp: @unchecked if (classify(elemtp).derivesFrom(defn.NullClass)) JavaArrayType(defn.ObjectType) else if (isUnboundedGeneric(elemtp) && !isJava) defn.ObjectType else JavaArrayType(erasureFn(isJava, semiEraseVCs = false, isConstructor, wildcardOK)(elemtp)) diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 2a709193656b..ce83aca0df28 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -253,7 +253,7 @@ class ClassfileParser( */ def normalizeConstructorParams() = innerClasses.get(currentClassName.toString) match { case Some(entry) if !isStatic(entry.jflags) => - val mt @ MethodTpe(paramNames, paramTypes, resultType) = denot.info + val mt @ MethodTpe(paramNames, paramTypes, resultType) = denot.info: @unchecked var normalizedParamNames = paramNames.tail var normalizedParamTypes = paramTypes.tail if ((jflags & JAVA_ACC_SYNTHETIC) != 0) { diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala index 247d8c8c10cf..70bfe267b48a 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala @@ -29,7 +29,7 @@ class TastyPickler(val rootCls: ClassSymbol) { sections.foreach(_._2.assemble()) val nameBufferHash = TastyHash.pjwHash64(nameBuffer.bytes) - val treeSectionHash +: otherSectionHashes = sections.map(x => TastyHash.pjwHash64(x._2.bytes)) + val treeSectionHash +: otherSectionHashes = sections.map(x => TastyHash.pjwHash64(x._2.bytes)): @unchecked // Hash of name table and tree val uuidLow: Long = nameBufferHash ^ treeSectionHash diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 10af44c76169..be2c4b350931 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -393,7 +393,7 @@ class TreePickler(pickler: TastyPickler) { if (qual.isEmpty) pickleType(tree.tpe) else { writeByte(QUALTHIS) - val ThisType(tref) = tree.tpe + val ThisType(tref) = tree.tpe: @unchecked pickleTree(qual.withType(tref)) } case Select(qual, name) => @@ -403,7 +403,7 @@ class TreePickler(pickler: TastyPickler) { withLength { writeNat(levels) pickleTree(qual) - val SkolemType(tp) = tree.tpe + val SkolemType(tp) = tree.tpe: @unchecked pickleType(tp) } case _ => @@ -456,7 +456,7 @@ class TreePickler(pickler: TastyPickler) { withLength { pickleTree(qual); if (!mix.isEmpty) { - val SuperType(_, mixinType: TypeRef) = tree.tpe + val SuperType(_, mixinType: TypeRef) = tree.tpe: @unchecked pickleTree(mix.withType(mixinType)) } } @@ -573,7 +573,7 @@ class TreePickler(pickler: TastyPickler) { withLength { pickleParams(params) tree.parents.foreach(pickleTree) - val cinfo @ ClassInfo(_, _, _, _, selfInfo) = tree.symbol.owner.info + val cinfo @ ClassInfo(_, _, _, _, selfInfo) = tree.symbol.owner.info: @unchecked if (!tree.self.isEmpty) { writeByte(SELFDEF) pickleName(tree.self.name) diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 8087396e4084..f6b9b507cef4 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -77,7 +77,7 @@ object Scala2Unpickler { val (tparams, TempClassInfoType(parents, decls, clazz)) = info match { case TempPolyType(tps, cinfo) => (tps, cinfo) case cinfo => (Nil, cinfo) - } + }: @unchecked val ost = if (selfInfo eq NoType) && denot.is(ModuleClass) then val sourceModule = denot.sourceModule.orElse { @@ -1047,7 +1047,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas val tparams = until(end, () => readTypeDefRef()) val cls = symbol.asClass val ((constr: DefDef) :: Nil, stats) = - impl.body.partition(_.symbol == cls.primaryConstructor) + impl.body.partition(_.symbol == cls.primaryConstructor): @unchecked ClassDef(cls, constr, tparams ++ stats) case MODULEtree => diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index faa335a6ac07..6f318a621c23 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1388,7 +1388,7 @@ object Parsers { syntaxError("context function types require at least one parameter", paramSpan) new FunctionWithMods(params, t, imods) else if ctx.settings.YkindProjector.value then - val (newParams :+ newT, tparams) = replaceKindProjectorPlaceholders(params :+ t) + val (newParams :+ newT, tparams) = replaceKindProjectorPlaceholders(params :+ t): @unchecked lambdaAbstract(tparams, Function(newParams, newT)) else @@ -2089,7 +2089,7 @@ object Parsers { case _ => val tpt = typeDependingOn(location) if (isWildcard(t) && !location.inPattern) { - val vd :: rest = placeholderParams + val vd :: rest = placeholderParams: @unchecked placeholderParams = cpy.ValDef(vd)(tpt = tpt).withSpan(vd.span.union(tpt.span)) :: rest } diff --git a/compiler/src/dotty/tools/dotc/plugins/Plugins.scala b/compiler/src/dotty/tools/dotc/plugins/Plugins.scala index a4db7ef44a86..4f6b5ccf1323 100644 --- a/compiler/src/dotty/tools/dotc/plugins/Plugins.scala +++ b/compiler/src/dotty/tools/dotc/plugins/Plugins.scala @@ -60,7 +60,7 @@ trait Plugins { plugNames: Set[String]): List[Plugin] = { if (plugins.isEmpty) return Nil // early return - val plug :: tail = plugins + val plug :: tail = plugins: @unchecked def withoutPlug = pick(tail, plugNames) def withPlug = plug :: pick(tail, plugNames + plug.name) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 64cc0ff432ed..6a2307935290 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -163,7 +163,7 @@ class PlainPrinter(_ctx: Context) extends Printer { (toTextLocal(tycon) ~ "[" ~ argsText(args) ~ "]").close case tp: RefinedType => val parent :: (refined: List[RefinedType @unchecked]) = - refinementChain(tp).reverse + refinementChain(tp).reverse: @unchecked toTextLocal(parent) ~ "{" ~ Text(refined map toTextRefinement, "; ").close ~ "}" case tp: RecType => try { diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index aafdc006591b..e50f71f4f5c4 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -199,7 +199,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { else if defn.isFunctionClass(cls) then toTextFunction(args, cls.name.isContextFunction, cls.name.isErasedFunction) else if tp.tupleArity >= 2 && !printDebug then toTextTuple(tp.tupleElementTypes) else if isInfixType(tp) then - val l :: r :: Nil = args + val l :: r :: Nil = args: @unchecked val opName = tyconName(tycon) toTextInfixType(tyconName(tycon), l, r) { simpleNameString(tycon.typeSymbol) } else Str("") diff --git a/compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala b/compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala index bc2455c5d5d3..e5e2c3d59e85 100644 --- a/compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala +++ b/compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala @@ -55,7 +55,7 @@ object PickledQuotes { /** Unpickle the tree contained in the TastyExpr */ def unpickleTerm(pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.Quotes) => scala.quoted.Expr[?])(using Context): Tree = { val unpickled = withMode(Mode.ReadPositions)(unpickle(pickled, isType = false)) - val Inlined(call, Nil, expnasion) = unpickled + val Inlined(call, Nil, expnasion) = unpickled: @unchecked val inlineCtx = inlineContext(call) val expansion1 = spliceTypes(expnasion, typeHole, termHole)(using inlineCtx) val expansion2 = spliceTerms(expansion1, typeHole, termHole)(using inlineCtx) diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index 2431fc969675..1da6202c17fd 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -401,7 +401,7 @@ import transform.SymUtils._ def msg = em"""An ${hl("implicit class")} may not be top-level""" def explain = { - val TypeDef(name, impl @ Template(constr0, parents, self, _)) = cdef + val TypeDef(name, impl @ Template(constr0, parents, self, _)) = cdef: @unchecked val exampleArgs = if(constr0.termParamss.isEmpty) "..." else constr0.termParamss(0).map(_.withMods(untpd.Modifiers()).show).mkString(", ") diff --git a/compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala b/compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala index be9006592a4e..26706d854597 100644 --- a/compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala +++ b/compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala @@ -50,8 +50,8 @@ object Scala3: val EmptyPackage: String = "_empty_/" val LocalPrefix: String = "local" val PackageObjectDescriptor: String = "package." - val s"${RootPackageName @ _}/" = RootPackage - val s"${EmptyPackageName @ _}/" = EmptyPackage + val s"${RootPackageName @ _}/" = RootPackage: @unchecked + val s"${EmptyPackageName @ _}/" = EmptyPackage: @unchecked def displaySymbol(symbol: Symbol)(using Context): String = if symbol.isPackageObject then diff --git a/compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala b/compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala index 437ff0490822..8139bb26432c 100644 --- a/compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala +++ b/compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala @@ -29,11 +29,11 @@ class ArrayConstructors extends MiniPhase { tpd.newArray(elemType, tree.tpe, tree.span, JavaSeqLiteral(dims, TypeTree(defn.IntClass.typeRef))) if (tree.fun.symbol eq defn.ArrayConstructor) { - val TypeApply(tycon, targ :: Nil) = tree.fun + val TypeApply(tycon, targ :: Nil) = tree.fun: @unchecked expand(targ.tpe, tree.args) } else if ((tree.fun.symbol.maybeOwner eq defn.ArrayModule.moduleClass) && (tree.fun.symbol.name eq nme.ofDim) && !tree.tpe.isInstanceOf[MethodicType]) { - val Apply(Apply(TypeApply(_, List(tp)), _), _) = tree + val Apply(Apply(TypeApply(_, List(tp)), _), _) = tree: @unchecked val cs = tp.tpe.classSymbol tree.fun match { case Apply(TypeApply(t: Ident, targ), dims) diff --git a/compiler/src/dotty/tools/dotc/transform/CapturedVars.scala b/compiler/src/dotty/tools/dotc/transform/CapturedVars.scala index 7b6d7ee64cd2..0ac818d2b2f1 100644 --- a/compiler/src/dotty/tools/dotc/transform/CapturedVars.scala +++ b/compiler/src/dotty/tools/dotc/transform/CapturedVars.scala @@ -141,7 +141,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase = override def transformAssign(tree: Assign)(using Context): Tree = { def recur(lhs: Tree): Tree = lhs match { case TypeApply(Select(qual, nme.asInstanceOf_), _) => - val Select(_, nme.elem) = qual + val Select(_, nme.elem) = qual: @unchecked recur(qual) case Select(_, nme.elem) if refInfo.boxedRefClasses.contains(lhs.symbol.maybeOwner) => val tempDef = transformFollowing(SyntheticValDef(TempResultName.fresh(), tree.rhs)) diff --git a/compiler/src/dotty/tools/dotc/transform/Constructors.scala b/compiler/src/dotty/tools/dotc/transform/Constructors.scala index 16666795ab77..e79932e64ea9 100644 --- a/compiler/src/dotty/tools/dotc/transform/Constructors.scala +++ b/compiler/src/dotty/tools/dotc/transform/Constructors.scala @@ -127,7 +127,7 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase = override def transformTemplate(tree: Template)(using Context): Tree = { val cls = ctx.owner.asClass - val constr @ DefDef(nme.CONSTRUCTOR, (vparams: List[ValDef] @unchecked) :: Nil, _, EmptyTree) = tree.constr + val constr @ DefDef(nme.CONSTRUCTOR, (vparams: List[ValDef] @unchecked) :: Nil, _, EmptyTree) = tree.constr: @unchecked // Produce aligned accessors and constructor parameters. We have to adjust // for any outer parameters, which are last in the sequence of original diff --git a/compiler/src/dotty/tools/dotc/transform/ElimOuterSelect.scala b/compiler/src/dotty/tools/dotc/transform/ElimOuterSelect.scala index 20a3c3223ea8..071b40fa6cf3 100644 --- a/compiler/src/dotty/tools/dotc/transform/ElimOuterSelect.scala +++ b/compiler/src/dotty/tools/dotc/transform/ElimOuterSelect.scala @@ -25,7 +25,7 @@ class ElimOuterSelect extends MiniPhase { override def transformSelect(tree: Select)(using Context): Tree = tree.name match { case OuterSelectName(_, nhops) => - val SkolemType(tp) = tree.tpe + val SkolemType(tp) = tree.tpe: @unchecked ExplicitOuter.outer.path(start = tree.qualifier, count = nhops).ensureConforms(tp) case _ => tree } diff --git a/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala b/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala index c1be520cf0d5..f54f00d1dcc6 100644 --- a/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala +++ b/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala @@ -223,7 +223,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase => .symbol.asTerm // Generate the method val forwarderDef = DefDef(forwarderSym, prefss => { - val init :+ (last :+ vararg) = prefss + val init :+ (last :+ vararg) = prefss: @unchecked // Can't call `.argTypes` here because the underlying array type is of the // form `Array[? <: SomeType]`, so we need `.argInfos` to get the `TypeBounds`. val elemtp = vararg.tpe.widen.argInfos.head @@ -244,7 +244,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase => */ private def isValidJavaVarArgs(tp: Type)(using Context): Boolean = tp match case mt: MethodType => - val initp :+ lastp = mt.paramInfoss + val initp :+ lastp = mt.paramInfoss: @unchecked initp.forall(_.forall(!_.isRepeatedParam)) && lastp.nonEmpty && lastp.init.forall(!_.isRepeatedParam) && @@ -315,7 +315,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase => case m: MethodType => // multiple param lists tp.derivedLambdaType(tp.paramNames, tp.paramInfos, toJavaVarArgs(m)) case _ => - val init :+ last = tp.paramInfos + val init :+ last = tp.paramInfos: @unchecked val vararg = varargArrayType(last) tp.derivedLambdaType(tp.paramNames, init :+ vararg, tp.resultType) diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index 0d80ef87056f..edb8fd9832e0 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -59,7 +59,7 @@ class Erasure extends Phase with DenotTransformer { assert(ctx.phase == this, s"transforming $ref at ${ctx.phase}") if (ref.symbol eq defn.ObjectClass) { // After erasure, all former Any members are now Object members - val ClassInfo(pre, _, ps, decls, selfInfo) = ref.info + val ClassInfo(pre, _, ps, decls, selfInfo) = ref.info: @unchecked val extendedScope = decls.cloneScope for decl <- defn.AnyClass.classInfo.decls do if !decl.isConstructor then extendedScope.enter(decl) @@ -492,7 +492,7 @@ object Erasure { val bridge = newSymbol(ctx.owner, AdaptedClosureName(meth.symbol.name.asTermName), Flags.Synthetic | Flags.Method, bridgeType) Closure(bridge, bridgeParamss => inContext(ctx.withOwner(bridge)) { - val List(bridgeParams) = bridgeParamss + val List(bridgeParams) = bridgeParamss: @unchecked assert(ctx.typer.isInstanceOf[Erasure.Typer]) val rhs = Apply(meth, bridgeParams.lazyZip(implParamTypes).map(ctx.typer.adapt(_, _))) ctx.typer.adapt(rhs, bridgeType.resultType) @@ -712,7 +712,7 @@ object Erasure { def adaptIfSuper(qual: Tree): Tree = qual match { case Super(thisQual, untpd.EmptyTypeIdent) => - val SuperType(thisType, supType) = qual.tpe + val SuperType(thisType, supType) = qual.tpe: @unchecked if (sym.owner.is(Flags.Trait)) cpy.Super(qual)(thisQual, untpd.Ident(sym.owner.asClass.name)) .withType(SuperType(thisType, sym.owner.typeRef)) diff --git a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala index c0ea4adee353..f0e5289c37f2 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala @@ -54,7 +54,7 @@ class ExpandSAMs extends MiniPhase: tree case tpe => val tpe1 = checkRefinements(tpe, fn) - val Seq(samDenot) = tpe1.possibleSamMethods + val Seq(samDenot) = tpe1.possibleSamMethods: @unchecked cpy.Block(tree)(stats, AnonClass(tpe1 :: Nil, fn.symbol.asTerm :: Nil, samDenot.symbol.asTerm.name :: Nil)) } @@ -111,7 +111,7 @@ class ExpandSAMs extends MiniPhase: } } - val closureDef(anon @ DefDef(_, List(List(param)), _, _)) = tree + val closureDef(anon @ DefDef(_, List(List(param)), _, _)) = tree: @unchecked anon.rhs match { case PartialFunctionRHS(pf) => val anonSym = anon.symbol @@ -156,7 +156,7 @@ class ExpandSAMs extends MiniPhase: } def applyOrElseRhs(paramRefss: List[List[Tree]])(using Context) = { - val List(paramRef, defaultRef) = paramRefss(1) + val List(paramRef, defaultRef) = paramRefss(1): @unchecked def translateCase(cdef: CaseDef) = cdef.changeOwner(anonSym, applyOrElseFn) val defaultValue = defaultRef.select(nme.apply).appliedTo(paramRef) diff --git a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala index d64c94f6bc98..76949f2e5480 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -358,7 +358,7 @@ object ExplicitOuter { /** If `cls` has an outer parameter add one to the method type `tp`. */ def addParam(cls: ClassSymbol, tp: Type): Type = if (hasOuterParam(cls)) { - val mt @ MethodTpe(pnames, ptypes, restpe) = tp + val mt @ MethodTpe(pnames, ptypes, restpe) = tp: @unchecked mt.derivedLambdaType( nme.OUTER :: pnames, outerClass(cls).typeRef :: ptypes, restpe) } diff --git a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala index 93f72199617e..d0e2f9983d9b 100644 --- a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala +++ b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala @@ -154,7 +154,7 @@ trait FullParameterization { val origClass = origMeth.enclosingClass.asClass val origLeadingTypeParamSyms = allInstanceTypeParams(originalDef, abstractOverClass) val origOtherParamSyms = originalDef.trailingParamss.flatten.map(_.symbol) - val thisRef :: argRefs = vrefss.flatten + val thisRef :: argRefs = vrefss.flatten: @unchecked /** If tree should be rewired, the rewired tree, otherwise EmptyTree. * @param targs Any type arguments passed to the rewired tree. diff --git a/compiler/src/dotty/tools/dotc/transform/Memoize.scala b/compiler/src/dotty/tools/dotc/transform/Memoize.scala index 2f73ed8bd9eb..74bc4d74bfbf 100644 --- a/compiler/src/dotty/tools/dotc/transform/Memoize.scala +++ b/compiler/src/dotty/tools/dotc/transform/Memoize.scala @@ -166,7 +166,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase => removeUnwantedAnnotations(sym, defn.GetterMetaAnnot) Thicket(fieldDef, getterDef) else if sym.isSetter then - if (!sym.is(ParamAccessor)) { val Literal(Constant(())) = tree.rhs } // This is intended as an assertion + if (!sym.is(ParamAccessor)) { val Literal(Constant(())) = tree.rhs: @unchecked } // This is intended as an assertion val field = sym.field if !field.exists then // When transforming the getter, we determined that no field was needed. diff --git a/compiler/src/dotty/tools/dotc/transform/Mixin.scala b/compiler/src/dotty/tools/dotc/transform/Mixin.scala index fc335b66a25c..00024320e14f 100644 --- a/compiler/src/dotty/tools/dotc/transform/Mixin.scala +++ b/compiler/src/dotty/tools/dotc/transform/Mixin.scala @@ -214,7 +214,7 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase => } (scall, stats ::: inits, args) case _ => - val Apply(sel @ Select(New(_), nme.CONSTRUCTOR), args) = tree + val Apply(sel @ Select(New(_), nme.CONSTRUCTOR), args) = tree: @unchecked val (callArgs, initArgs) = if (tree.symbol.owner.is(Trait)) (Nil, args) else (args, Nil) (superRef(tree.symbol, tree.span).appliedToTermArgs(callArgs), Nil, initArgs) } diff --git a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala index 169f68e2cad9..af97c075544b 100644 --- a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -257,7 +257,7 @@ object PatternMatcher { def matchArgsPatternPlan(args: List[Tree], syms: List[Symbol]): Plan = args match { case arg :: args1 => - val sym :: syms1 = syms + val sym :: syms1 = syms: @unchecked patternPlan(sym, arg, matchArgsPatternPlan(args1, syms1)) case Nil => assert(syms.isEmpty) @@ -395,7 +395,7 @@ object PatternMatcher { assert(implicits.isEmpty) acc } - val mt @ MethodType(_) = extractor.tpe.widen + val mt @ MethodType(_) = extractor.tpe.widen: @unchecked val unapp0 = extractor.appliedTo(ref(scrutinee).ensureConforms(mt.paramInfos.head)) val unapp = applyImplicits(unapp0, implicits, mt.resultType) unapplyPlan(unapp, args) @@ -643,7 +643,7 @@ object PatternMatcher { */ private def inlineVars(plan: Plan): Plan = { val refCount = varRefCount(plan) - val LetPlan(topSym, _) = plan + val LetPlan(topSym, _) = plan: @unchecked def toDrop(sym: Symbol) = initializer.get(sym) match { case Some(rhs) => @@ -840,7 +840,7 @@ object PatternMatcher { else scrutinee.select(nme.toInt) def intLiteral(lit: Tree): Tree = - val Literal(constant) = lit + val Literal(constant) = lit: @unchecked if (constant.tag == Constants.IntTag) lit else cpy.Literal(lit)(Constant(constant.intValue)) diff --git a/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala b/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala index 0f00add41809..5ff4fed6c34b 100644 --- a/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala @@ -256,7 +256,7 @@ class PickleQuotes extends MacroTransform { defn.QuotedExprClass.typeRef.appliedTo(defn.AnyType)), args => { val cases = termSplices.map { case (splice, idx) => - val defn.FunctionOf(_, defn.FunctionOf(qctxType :: _, _, _, _), _, _) = splice.tpe + val defn.FunctionOf(_, defn.FunctionOf(qctxType :: _, _, _, _), _, _) = splice.tpe: @unchecked val rhs = splice.select(nme.apply).appliedTo(args(1)).select(nme.apply).appliedTo(args(2).asInstance(qctxType)) CaseDef(Literal(Constant(idx)), EmptyTree, rhs) } diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index ba0337a797f3..49df4b8bd70b 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -221,7 +221,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase case (NamedArg(_, arg) :: _, namedArgs1) => arg :: reorderArgs(pnames1, namedArgs1, otherArgs) case _ => - val otherArg :: otherArgs1 = otherArgs + val otherArg :: otherArgs1 = otherArgs: @unchecked otherArg :: reorderArgs(pnames1, namedArgs, otherArgs1) } case nil => diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index 66419c8c2006..e7c2c6632fb4 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -302,7 +302,7 @@ object Splicer { assert(argss.head.size == argTypes.size) interpretArgsGroup(argss.head, argTypes) ::: interpretArgs(argss.tail, fnType.resType) case fnType: AppliedType if defn.isContextFunctionType(fnType) => - val argTypes :+ resType = fnType.args + val argTypes :+ resType = fnType.args: @unchecked interpretArgsGroup(argss.head, argTypes) ::: interpretArgs(argss.tail, resType) case fnType: PolyType => interpretArgs(argss, fnType.resType) case fnType: ExprType => interpretArgs(argss, fnType.resType) diff --git a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala index aea1c49972ca..12d8b8c19b3d 100644 --- a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala +++ b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala @@ -103,7 +103,7 @@ class SuperAccessors(thisPhase: DenotTransformer) { * replace by a super accessor call. */ private def transformSuperSelect(sel: Select)(using Context): Tree = { - val Select(sup @ Super(_, mix), name) = sel + val Select(sup @ Super(_, mix), name) = sel: @unchecked val sym = sel.symbol assert(sup.symbol.exists, s"missing symbol in $sel: ${sup.tpe}") val clazz = sup.symbol @@ -173,7 +173,7 @@ class SuperAccessors(thisPhase: DenotTransformer) { /** Transform select node, adding super and protected accessors as needed */ def transformSelect(tree: Tree, targs: List[Tree])(using Context): Tree = { - val sel @ Select(qual, name) = tree + val sel @ Select(qual, name) = tree: @unchecked val sym = sel.symbol /** If an accesses to protected member of a class comes from a trait, diff --git a/compiler/src/dotty/tools/dotc/transform/TransformByNameApply.scala b/compiler/src/dotty/tools/dotc/transform/TransformByNameApply.scala index dab1d8f25ca2..037c3c2d66bd 100644 --- a/compiler/src/dotty/tools/dotc/transform/TransformByNameApply.scala +++ b/compiler/src/dotty/tools/dotc/transform/TransformByNameApply.scala @@ -57,7 +57,7 @@ abstract class TransformByNameApply extends MiniPhase { thisPhase: DenotTransfor arg } - val mt @ MethodType(_) = tree.fun.tpe.widen + val mt @ MethodType(_) = tree.fun.tpe.widen: @unchecked val args1 = tree.args.zipWithConserve(mt.paramInfos)(transformArg) cpy.Apply(tree)(tree.fun, args1) } diff --git a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala index 7eaad36b18a2..689a77f827ad 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -427,7 +427,7 @@ class TreeChecker extends Phase with SymTransformer { } override def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(using Context): Tree = { - val TypeDef(_, impl @ Template(constr, _, _, _)) = cdef + val TypeDef(_, impl @ Template(constr, _, _, _)) = cdef: @unchecked assert(cdef.symbol == cls) assert(impl.symbol.owner == cls) assert(constr.symbol.owner == cls) diff --git a/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala b/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala index d208c19c5c52..a501fd45e041 100644 --- a/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala +++ b/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala @@ -34,7 +34,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { else tree private def transformTupleCons(tree: tpd.Apply)(using Context): Tree = { - val head :: tail :: Nil = tree.args + val head :: tail :: Nil = tree.args: @unchecked defn.tupleTypes(tree.tpe.widenTermRefExpr.dealias) match { case Some(tpes) => // Generate a the tuple directly with TupleN+1.apply @@ -62,7 +62,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { } private def transformTupleTail(tree: tpd.Apply)(using Context): Tree = { - val Apply(_, tup :: Nil) = tree + val Apply(_, tup :: Nil) = tree: @unchecked defn.tupleTypes(tup.tpe.widenTermRefExpr.dealias, MaxTupleArity + 1) match { case Some(tpes) => // Generate a the tuple directly with TupleN-1.apply @@ -105,7 +105,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { } private def transformTupleConcat(tree: tpd.Apply)(using Context): Tree = { - val Apply(_, self :: that :: Nil) = tree + val Apply(_, self :: that :: Nil) = tree: @unchecked (defn.tupleTypes(self.tpe.widenTermRefExpr.dealias), defn.tupleTypes(that.tpe.widenTermRefExpr.dealias)) match { case (Some(tpes1), Some(tpes2)) => // Generate a the tuple directly with TupleN+M.apply @@ -140,7 +140,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { } private def transformTupleApply(tree: tpd.Apply)(using Context): Tree = { - val Apply(_, tup :: nTree :: Nil) = tree + val Apply(_, tup :: nTree :: Nil) = tree: @unchecked (defn.tupleTypes(tup.tpe.widenTermRefExpr.dealias), nTree.tpe) match { case (Some(tpes), nTpe: ConstantType) => // Get the element directly with TupleM._n+1 or TupleXXL.productElement(n) @@ -167,7 +167,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { } private def transformTupleToArray(tree: tpd.Apply)(using Context): Tree = { - val Apply(_, tup :: Nil) = tree + val Apply(_, tup :: Nil) = tree: @unchecked defn.tupleTypes(tup.tpe.widen, MaxTupleArity) match { case Some(tpes) => val size = tpes.size diff --git a/compiler/src/dotty/tools/dotc/transform/init/Checking.scala b/compiler/src/dotty/tools/dotc/transform/init/Checking.scala index 6a8007e06516..07719a82a123 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Checking.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Checking.scala @@ -104,7 +104,7 @@ object Checking { } def checkSecondaryConstructor(ctor: Symbol)(implicit state: State): Unit = traceOp("checking " + ctor.show, init) { - val Block(ctorCall :: stats, expr) = ctor.defTree.asInstanceOf[DefDef].rhs + val Block(ctorCall :: stats, expr) = ctor.defTree.asInstanceOf[DefDef].rhs: @unchecked val cls = ctor.owner.asClass traceOp("check ctor: " + ctorCall.show, init) { diff --git a/compiler/src/dotty/tools/dotc/transform/init/Summarization.scala b/compiler/src/dotty/tools/dotc/transform/init/Summarization.scala index 258900311d3e..80ecbb6d6178 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Summarization.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Summarization.scala @@ -292,15 +292,15 @@ object Summarization { val effsAll = tpl.parents.foldLeft(effs) { (effs, parent) => effs ++ (parent match { case tree @ Block(stats, parent) => - val ctor @ Select(qual, _) = funPart(parent) + val ctor @ Select(qual, _) = funPart(parent): @unchecked parentArgEffsWithInit(qual :: stats ++ termArgss(parent).flatten, ctor.symbol, tree) case tree @ Apply(Block(stats, parent), args) => - val ctor @ Select(qual, _) = funPart(parent) + val ctor @ Select(qual, _) = funPart(parent): @unchecked parentArgEffsWithInit(qual :: stats ++ args ++ termArgss(parent).flatten, ctor.symbol, tree) case parent : Apply => - val ctor @ Select(qual, _) = funPart(parent) + val ctor @ Select(qual, _) = funPart(parent): @unchecked parentArgEffsWithInit(qual :: termArgss(parent).flatten, ctor.symbol, parent) case ref => diff --git a/compiler/src/dotty/tools/dotc/transform/sjs/AddLocalJSFakeNews.scala b/compiler/src/dotty/tools/dotc/transform/sjs/AddLocalJSFakeNews.scala index 483622c2fb0c..4b9236a2d87c 100644 --- a/compiler/src/dotty/tools/dotc/transform/sjs/AddLocalJSFakeNews.scala +++ b/compiler/src/dotty/tools/dotc/transform/sjs/AddLocalJSFakeNews.scala @@ -61,7 +61,7 @@ class AddLocalJSFakeNews extends MiniPhase { thisPhase => override def transformApply(tree: Apply)(using Context): Tree = { if (tree.symbol == jsdefn.Runtime_createLocalJSClass) { - val classValueArg :: superClassValueArg :: _ :: Nil = tree.args + val classValueArg :: superClassValueArg :: _ :: Nil = tree.args: @unchecked val cls = classValueArg match { case Literal(constant) if constant.tag == Constants.ClazzTag => constant.typeValue.typeSymbol.asClass diff --git a/compiler/src/dotty/tools/dotc/transform/sjs/JUnitBootstrappers.scala b/compiler/src/dotty/tools/dotc/transform/sjs/JUnitBootstrappers.scala index a2964d802198..389961a15c4f 100644 --- a/compiler/src/dotty/tools/dotc/transform/sjs/JUnitBootstrappers.scala +++ b/compiler/src/dotty/tools/dotc/transform/sjs/JUnitBootstrappers.scala @@ -208,7 +208,7 @@ class JUnitBootstrappers extends MiniPhase { MethodType(junitNme.instance :: Nil, defn.ObjectType :: Nil, defn.UnitType)).entered DefDef(sym, { (paramRefss: List[List[Tree]]) => - val List(List(instanceParamRef)) = paramRefss + val List(List(instanceParamRef)) = paramRefss: @unchecked val calls = annotatedMethods(testClass, annot) .map(m => Apply(instanceParamRef.cast(testClass.typeRef).select(m), Nil)) Block(calls, unitLiteral) @@ -258,7 +258,7 @@ class JUnitBootstrappers extends MiniPhase { MethodType(List(junitNme.instance, junitNme.name), List(defn.ObjectType, defn.StringType), junitdefn.FutureType)).entered DefDef(sym, { (paramRefss: List[List[Tree]]) => - val List(List(instanceParamRef, nameParamRef)) = paramRefss + val List(List(instanceParamRef, nameParamRef)) = paramRefss: @unchecked val castInstanceSym = newSymbol(sym, junitNme.castInstance, Synthetic, testClass.typeRef, coord = owner.span) Block( ValDef(castInstanceSym, instanceParamRef.cast(testClass.typeRef)) :: Nil, diff --git a/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala b/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala index afc6e9d5d479..bd18e1f18060 100644 --- a/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala +++ b/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala @@ -1063,7 +1063,7 @@ object PrepJSInterop { Some(result) case _ => // Annotations are stored in reverse order, which we re-reverse now - val result :: duplicates = annots.reverse + val result :: duplicates = annots.reverse: @unchecked for (annot <- duplicates) report.error(badAnnotCountMsg, annot.tree) Some(result) diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 0839621bd6db..0b9945db4e7a 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -121,7 +121,7 @@ object Applications { if defn.isTupleClass(tp.tycon.typeSymbol) then tp.args else if tp.tycon.derivesFrom(defn.PairClass) then - val List(head, tail) = tp.args + val List(head, tail) = tp.args: @unchecked head :: tupleComponentTypes(tail) else Nil @@ -1623,7 +1623,7 @@ trait Applications extends Compatibility { } case Nil => previous } - val best :: rest = survivors(alt :: Nil, alts1) + val best :: rest = survivors(alt :: Nil, alts1): @unchecked def asGood(alts: List[TermRef]): List[TermRef] = alts match { case alt :: alts1 => if (compare(alt, best) < 0) asGood(alts1) else alt :: asGood(alts1) diff --git a/compiler/src/dotty/tools/dotc/typer/Deriving.scala b/compiler/src/dotty/tools/dotc/typer/Deriving.scala index 269924c21114..5a3e57331246 100644 --- a/compiler/src/dotty/tools/dotc/typer/Deriving.scala +++ b/compiler/src/dotty/tools/dotc/typer/Deriving.scala @@ -307,7 +307,7 @@ trait Deriving { } def finalize(stat: tpd.TypeDef): tpd.Tree = { - val templ @ Template(_, _, _, _) = stat.rhs + val templ @ Template(_, _, _, _) = stat.rhs: @unchecked tpd.cpy.TypeDef(stat)(rhs = tpd.cpy.Template(templ)(body = templ.body ++ syntheticDefs)) } } diff --git a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala index 232ad8456c0a..5350fc14f9b2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala +++ b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala @@ -176,7 +176,7 @@ trait Dynamic { * type */ def handleStructural(tree: Tree)(using Context): Tree = { - val fun @ Select(qual, name) = funPart(tree) + val fun @ Select(qual, name) = funPart(tree): @unchecked val vargss = termArgss(tree) def structuralCall(selectorName: TermName, classOfs: => List[Tree]) = { diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 79e1b739b542..60d6d7f9fc3b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -286,7 +286,7 @@ object Inliner { case _ => t } - val Apply(_, codeArg :: Nil) = tree + val Apply(_, codeArg :: Nil) = tree: @unchecked val underlyingCodeArg = stripTyped(codeArg.underlying) ConstFold(underlyingCodeArg).tpe.widenTermRefExpr match { case ConstantType(Constant(code: String)) => @@ -1349,14 +1349,14 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { typeMap = new TypeMap() { override def apply(tp: Type): Type = tp match { case tr: TypeRef if tr.prefix.eq(NoPrefix) && typeBindingsSet.contains(tr.symbol) => - val TypeAlias(res) = tr.info + val TypeAlias(res) = tr.info: @unchecked res case tp => mapOver(tp) } }, treeMap = { case ident: Ident if ident.isType && typeBindingsSet.contains(ident.symbol) => - val TypeAlias(r) = ident.symbol.info + val TypeAlias(r) = ident.symbol.info: @unchecked TypeTree(r).withSpan(ident.span) case tree => tree } diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 731f1786cac8..ca19edf1e38b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -426,7 +426,7 @@ class Namer { typer: Typer => annots // can happen if a class has several inaccessible children else { assert(childStart != other.span.start, i"duplicate child annotation $child / $other") - val (prefix, otherAnnot :: rest) = annots.span(_.symbol != defn.ChildAnnot) + val (prefix, otherAnnot :: rest) = annots.span(_.symbol != defn.ChildAnnot): @unchecked prefix ::: otherAnnot :: insertInto(rest) } case _ => @@ -464,7 +464,7 @@ class Namer { typer: Typer => /** Remove the subtree `tree` from the expanded tree of `mdef` */ def removeInExpanded(mdef: Tree, tree: Tree): Unit = { - val Thicket(trees) = expanded(mdef) + val Thicket(trees) = expanded(mdef): @unchecked mdef.putAttachment(ExpandedTree, Thicket(trees.filter(_ != tree))) } @@ -480,7 +480,7 @@ class Namer { typer: Typer => */ def mergeModuleClass(mdef: Tree, modCls: TypeDef, fromCls: TypeDef): TypeDef = { var res: TypeDef = null - val Thicket(trees) = expanded(mdef) + val Thicket(trees) = expanded(mdef): @unchecked val merged = trees.map { tree => if (tree == modCls) { val fromTempl = fromCls.rhs.asInstanceOf[Template] @@ -966,7 +966,7 @@ class Namer { typer: Typer => /** info to be used temporarily while completing the class, to avoid cyclic references. */ private var tempInfo: TempClassInfo = _ - val TypeDef(name, impl @ Template(constr, _, self, _)) = original + val TypeDef(name, impl @ Template(constr, _, self, _)) = original: @unchecked private val (params, rest): (List[Tree], List[Tree]) = impl.body.span { case td: TypeDef => td.mods.is(Param) @@ -1019,7 +1019,7 @@ class Namer { typer: Typer => // Note: in this branch we use the assumptions // that `prefss.head` corresponds to `mt.paramInfos` and // that `prefss.tail` corresponds to `mt.resType` - val init :+ vararg = prefss.head + val init :+ vararg = prefss.head: @unchecked val prefs = init :+ ctx.typeAssigner.seqToRepeated(vararg) adaptForwarderParams(prefs :: acc, mt.resType, prefss.tail) case mt: MethodOrPoly => diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index 3478b493caeb..575fed21b89f 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -123,7 +123,7 @@ trait QuotesAndSplices { */ def typedAppliedSplice(tree: untpd.Apply, pt: Type)(using Context): Tree = { assert(ctx.mode.is(Mode.QuotedPattern)) - val untpd.Apply(splice: untpd.Splice, args) = tree + val untpd.Apply(splice: untpd.Splice, args) = tree: @unchecked if !isFullyDefined(pt, ForceDegree.flipBottom) then report.error(i"Type must be fully defined.", splice.srcPos) tree.withType(UnspecifiedErrorType) diff --git a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala index 445c130e50fb..c42b9e3cbb9e 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -59,7 +59,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): else // Generate SAM: (s: ) => if s.isInstanceOf[] then Some(s.asInstanceOf[s.type & ]) else None def body(args: List[Tree]): Tree = { - val arg :: Nil = args + val arg :: Nil = args: @unchecked val t = arg.tpe & tp2 If( arg.isInstance(tp2), diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 3a4446426091..d0b075bb7baa 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1016,7 +1016,7 @@ class Typer extends Namer val thenp0 = typed(tree.thenp, pt.dropIfProto)(using cond1.nullableContextIf(true)) val elsep0 = typed(tree.elsep, pt.dropIfProto)(using cond1.nullableContextIf(false)) thenp0 :: elsep0 :: Nil - } + }: @unchecked assignType(cpy.If(tree)(cond1, thenp1, elsep1), thenp1, elsep1) def thenPathInfo = cond1.notNullInfoIf(true).seq(result.thenp.notNullInfo) @@ -1127,7 +1127,7 @@ class Typer extends Namer } def typedFunctionValue(tree: untpd.Function, pt: Type)(using Context): Tree = { - val untpd.Function(params: List[untpd.ValDef] @unchecked, _) = tree + val untpd.Function(params: List[untpd.ValDef] @unchecked, _) = tree: @unchecked val isContextual = tree match { case tree: untpd.FunctionWithMods => tree.mods.is(Given) @@ -1406,7 +1406,7 @@ class Typer extends Namer // check `pat` here and throw away the result. val gadtCtx: Context = ctx.fresh.setFreshGADTBounds val pat1 = typedPattern(pat, selType)(using gadtCtx) - val Typed(_, tpt) = tpd.unbind(tpd.unsplice(pat1)) + val Typed(_, tpt) = tpd.unbind(tpd.unsplice(pat1)): @unchecked instantiateMatchTypeProto(pat1, pt) match { case defn.MatchCase(patternTp, _) => tpt.tpe frozen_=:= patternTp case _ => false @@ -1643,7 +1643,7 @@ class Typer extends Namer val expr1 = typed(tree.expr, pt.dropIfProto) val cases1 = typedCases(tree.cases, EmptyTree, defn.ThrowableType, pt.dropIfProto) expr1 :: cases1 - } + }: @unchecked val finalizer1 = typed(tree.finalizer, defn.UnitType) val cases2 = cases2x.asInstanceOf[List[CaseDef]] assignType(cpy.Try(tree)(expr2, cases2, finalizer1), expr2, cases2) @@ -1730,7 +1730,7 @@ class Typer extends Namer val tpt1 = if (tree.tpt.isEmpty) TypeTree(defn.ObjectType) else typedAheadType(tree.tpt) val refineClsDef = desugar.refinedTypeToClass(tpt1, tree.refinements).withSpan(tree.span) val refineCls = createSymbol(refineClsDef).asClass - val TypeDef(_, impl: Template) = typed(refineClsDef) + val TypeDef(_, impl: Template) = typed(refineClsDef): @unchecked val refinements1 = impl.body assert(tree.refinements.hasSameLengthAs(refinements1), i"${tree.refinements}%, % > $refinements1%, %") val seen = mutable.Set[Symbol]() @@ -2107,7 +2107,7 @@ class Typer extends Namer def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(using Context): Tree = { if (!cls.info.isInstanceOf[ClassInfo]) return EmptyTree.assertingErrorsReported - val TypeDef(name, impl @ Template(constr, _, self, _)) = cdef + val TypeDef(name, impl @ Template(constr, _, self, _)) = cdef: @unchecked val parents = impl.parents val superCtx = ctx.superCallContext @@ -2297,7 +2297,7 @@ class Typer extends Namer * constructor call. Cannot simply use a type. Overridden in ReTyper. */ def ensureConstrCall(cls: ClassSymbol, parents: List[Tree])(using Context): List[Tree] = { - val firstParent :: otherParents = parents + val firstParent :: otherParents = parents: @unchecked if (firstParent.isType && !cls.is(Trait) && !cls.is(JavaDefined)) typed(untpd.New(untpd.TypedSplice(firstParent), Nil)) :: otherParents else parents @@ -2386,7 +2386,7 @@ class Typer extends Namer } def typedAsFunction(tree: untpd.PostfixOp, pt: Type)(using Context): Tree = { - val untpd.PostfixOp(qual, Ident(nme.WILDCARD)) = tree + val untpd.PostfixOp(qual, Ident(nme.WILDCARD)) = tree: @unchecked val pt1 = if (defn.isFunctionType(pt)) pt else AnyFunctionProto val nestedCtx = ctx.fresh.setNewTyperState() val res = typed(qual, pt1)(using nestedCtx) @@ -2632,7 +2632,7 @@ class Typer extends Namer tree protected def makeContextualFunction(tree: untpd.Tree, pt: Type)(using Context): Tree = { - val defn.FunctionOf(formals, _, true, _) = pt.dropDependentRefinement + val defn.FunctionOf(formals, _, true, _) = pt.dropDependentRefinement: @unchecked // The getter of default parameters may reach here. // Given the code below @@ -3654,7 +3654,7 @@ class Typer extends Namer /** Convert constructor proxy reference to a new expression */ def newExpr = - val Select(qual, nme.apply) = tree; @unchecked + val Select(qual, nme.apply) = tree: @unchecked val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false) val tpt = qual match case Ident(name) => cpy.Ident(qual)(name.toTypeName) diff --git a/compiler/src/dotty/tools/dotc/util/ParsedComment.scala b/compiler/src/dotty/tools/dotc/util/ParsedComment.scala index e02aae1e8dbb..6a18a9e54f7e 100644 --- a/compiler/src/dotty/tools/dotc/util/ParsedComment.scala +++ b/compiler/src/dotty/tools/dotc/util/ParsedComment.scala @@ -137,7 +137,7 @@ object ParsedComment { */ private def toDescriptionList(ctx: Context, items: List[String]): String = inContext(ctx) { val formattedItems = items.map { p => - val name :: rest = p.split(" ", 2).toList + val name :: rest = p.split(" ", 2).toList: @unchecked s"${bold(name)} ${rest.mkString("").trim}" } toMarkdownList(ctx, formattedItems) diff --git a/compiler/src/dotty/tools/repl/CollectTopLevelImports.scala b/compiler/src/dotty/tools/repl/CollectTopLevelImports.scala index f46b5feed76a..799aa3004152 100644 --- a/compiler/src/dotty/tools/repl/CollectTopLevelImports.scala +++ b/compiler/src/dotty/tools/repl/CollectTopLevelImports.scala @@ -20,7 +20,7 @@ class CollectTopLevelImports extends Phase { def run(using Context): Unit = { def topLevelImports(tree: Tree) = { - val PackageDef(_, _ :: TypeDef(_, rhs: Template) :: _) = tree + val PackageDef(_, _ :: TypeDef(_, rhs: Template) :: _) = tree: @unchecked rhs.body.collect { case tree: Import => tree } } diff --git a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala index f1ee10777c7c..6fdeb7f4e976 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala @@ -234,7 +234,7 @@ object SourceCode { this += " {" indented { if (printSelf) { - val Some(ValDef(name, tpt, _)) = self + val Some(ValDef(name, tpt, _)) = self: @unchecked indented { val name1 = if (name == "_") "this" else name this += " " += highlightValDef(name1) += ": " @@ -846,7 +846,7 @@ object SourceCode { val name = splicedName(arg.symbol).getOrElse(arg.symbol.name) val sym = arg.symbol.owner if sym.isDefDef && sym.name == "" then - val ClassDef(_, _, _, _, _, body) = sym.owner.tree + val ClassDef(_, _, _, _, _, body) = sym.owner.tree: @unchecked body.collectFirst { case vdef @ ValDef(`name`, _, _) if vdef.symbol.flags.is(Flags.ParamAccessor) => if (!vdef.symbol.flags.is(Flags.Local)) { @@ -1030,10 +1030,10 @@ object SourceCode { inSquare(printTrees(args, ", ")) case Annotated(tpt, annot) => - val Annotation(ref, args) = annot + val Annotation(ref, args) = annot: @unchecked ref.tpe match { case tpe: TypeRef if tpe.typeSymbol == Symbol.requiredClass("scala.annotation.internal.Repeated") => - val Types.Sequence(tp) = tpt.tpe + val Types.Sequence(tp) = tpt.tpe: @unchecked printType(tp) this += highlightTypeDef("*") case _ => @@ -1139,7 +1139,7 @@ object SourceCode { } case AnnotatedType(tp, annot) => - val Annotation(ref, args) = annot + val Annotation(ref, args) = annot: @unchecked printType(tp) this += " " printAnnotation(annot) @@ -1257,7 +1257,7 @@ object SourceCode { } private def printAnnotation(annot: Term)(using elideThis: Option[Symbol]): this.type = { - val Annotation(ref, args) = annot + val Annotation(ref, args) = annot: @unchecked this += "@" printTypeTree(ref) if (args.isEmpty) @@ -1397,7 +1397,7 @@ object SourceCode { this += name += "." case _ => } - val TypeRef(prefix, name) = tp + val TypeRef(prefix, name) = tp: @unchecked printClassPrefix(prefix) this += name } diff --git a/library/src/scala/quoted/ExprMap.scala b/library/src/scala/quoted/ExprMap.scala index 36d98845453b..004f69ed2f83 100644 --- a/library/src/scala/quoted/ExprMap.scala +++ b/library/src/scala/quoted/ExprMap.scala @@ -48,7 +48,7 @@ trait ExprMap: case Super(qual, mix) => tree case tree @ Apply(fun, args) => - val MethodType(_, tpes, _) = fun.tpe.widen + val MethodType(_, tpes, _) = fun.tpe.widen: @unchecked Apply.copy(tree)(transformTerm(fun, TypeRepr.of[Any])(owner), transformTerms(args, tpes)(owner)) case TypeApply(fun, args) => TypeApply.copy(tree)(transformTerm(fun, TypeRepr.of[Any])(owner), args) @@ -127,7 +127,7 @@ trait ExprMap: def transformTerms(trees: List[Term], tpes: List[TypeRepr])(owner: Symbol): List[Term] = var tpes2 = tpes // TODO use proper zipConserve trees.mapConserve{ x => - val tpe :: tail = tpes2 + val tpe :: tail = tpes2: @unchecked tpes2 = tail transformTerm(x, tpe)(owner) }