From c8927bbdf49aa8d6520343c67b6c434f49fda418 Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 23 Nov 2023 12:38:47 +0100 Subject: [PATCH 1/3] Refactor some tuple methods - Move from Definitions to TypeUtils - Unify TypeUtils.tupleElementTypes and Definitions.tupleTypes. They do the same thing. I'd like to move more things out of Definitions and into TypeUtils and SymUtils. Then I'd like to move these files to the core package, and make their operations accessible automatically by having the companion objects of Types and Symbols inherit from them. This is a first step into that direction. [Cherry-picked 366f06a27a4604f4bd279a444d3fc7cbc3979ac6] --- .../dotty/tools/dotc/core/Definitions.scala | 20 ------- .../tools/dotc/printing/RefinedPrinter.scala | 2 +- .../dotc/transform/TupleOptimizations.scala | 12 ++-- .../tools/dotc/transform/TypeUtils.scala | 55 +++++++++++++------ .../dotty/tools/dotc/typer/Synthesizer.scala | 2 +- .../src/dotty/tools/dotc/typer/Typer.scala | 6 +- 6 files changed, 50 insertions(+), 47 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 87f21738841f..2084cd4b04b1 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1736,26 +1736,6 @@ class Definitions { else TypeOps.nestedPairs(elems) } - def tupleTypes(tp: Type, bound: Int = Int.MaxValue)(using Context): Option[List[Type]] = { - @tailrec def rec(tp: Type, acc: List[Type], bound: Int): Option[List[Type]] = tp.normalized.dealias match { - case _ if bound < 0 => Some(acc.reverse) - case tp: AppliedType if PairClass == tp.classSymbol => rec(tp.args(1), tp.args.head :: acc, bound - 1) - case tp: AppliedType if isTupleNType(tp) => Some(acc.reverse ::: tp.args) - case tp: TermRef if tp.symbol == defn.EmptyTupleModule => Some(acc.reverse) - case _ => None - } - rec(tp.stripTypeVar, Nil, bound) - } - - def isSmallGenericTuple(tp: Type)(using Context): Boolean = - if tp.derivesFrom(defn.PairClass) && !defn.isTupleNType(tp.widenDealias) then - // If this is a generic tuple we need to cast it to make the TupleN/ members accessible. - // This works only for generic tuples of known size up to 22. - defn.tupleTypes(tp.widenTermRefExpr) match - case Some(elems) if elems.length <= Definitions.MaxTupleArity => true - case _ => false - else false - def isProductSubType(tp: Type)(using Context): Boolean = tp.derivesFrom(ProductClass) /** Is `tp` (an alias) of either a scala.FunctionN or a scala.ContextFunctionN diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index f8fca4b6767d..66737547bb21 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -235,7 +235,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { def appliedText(tp: Type): Text = tp match case tp @ AppliedType(tycon, args) => - tp.tupleElementTypes match + tp.tupleElementTypesUpTo(200, normalize = false) match case Some(types) if types.size >= 2 && !printDebug => toTextTuple(types) case _ => val tsym = tycon.typeSymbol diff --git a/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala b/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala index fee7bb19e0be..5cdb13429a32 100644 --- a/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala +++ b/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala @@ -10,9 +10,9 @@ import StdNames.* import Symbols.* import MegaPhase.* import Types.* +import transform.TypeUtils.* import dotty.tools.dotc.ast.tpd - /** Optimize generic operations on tuples */ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { import tpd.* @@ -33,7 +33,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { private def transformTupleCons(tree: tpd.Apply)(using Context): Tree = { val head :: tail :: Nil = tree.args: @unchecked - defn.tupleTypes(tree.tpe.widenTermRefExpr.dealias) match { + tree.tpe.widenTermRefExpr.tupleElementTypes match { case Some(tpes) => // Generate a the tuple directly with TupleN+1.apply val size = tpes.size @@ -61,7 +61,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { private def transformTupleTail(tree: tpd.Apply)(using Context): Tree = { val Apply(_, tup :: Nil) = tree: @unchecked - defn.tupleTypes(tup.tpe.widenTermRefExpr.dealias, MaxTupleArity + 1) match { + tup.tpe.widenTermRefExpr.tupleElementTypesUpTo(MaxTupleArity + 1) match { case Some(tpes) => // Generate a the tuple directly with TupleN-1.apply val size = tpes.size @@ -104,7 +104,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { private def transformTupleConcat(tree: tpd.Apply)(using Context): Tree = { val Apply(_, self :: that :: Nil) = tree: @unchecked - (defn.tupleTypes(self.tpe.widenTermRefExpr.dealias), defn.tupleTypes(that.tpe.widenTermRefExpr.dealias)) match { + (self.tpe.widenTermRefExpr.tupleElementTypes, that.tpe.widenTermRefExpr.tupleElementTypes) match { case (Some(tpes1), Some(tpes2)) => // Generate a the tuple directly with TupleN+M.apply val n = tpes1.size @@ -139,7 +139,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { private def transformTupleApply(tree: tpd.Apply)(using Context): Tree = { val Apply(_, tup :: nTree :: Nil) = tree: @unchecked - (defn.tupleTypes(tup.tpe.widenTermRefExpr.dealias), nTree.tpe) match { + (tup.tpe.widenTermRefExpr.tupleElementTypes, nTree.tpe) match { case (Some(tpes), nTpe: ConstantType) => // Get the element directly with TupleM._n+1 or TupleXXL.productElement(n) val size = tpes.size @@ -166,7 +166,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { private def transformTupleToArray(tree: tpd.Apply)(using Context): Tree = { val Apply(_, tup :: Nil) = tree: @unchecked - defn.tupleTypes(tup.tpe.widen, MaxTupleArity) match { + tup.tpe.widen.tupleElementTypesUpTo(MaxTupleArity) match { case Some(tpes) => val size = tpes.size if (size == 0) diff --git a/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala b/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala index 9528e683cc55..4a64dffc7c25 100644 --- a/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala @@ -49,22 +49,45 @@ object TypeUtils { case ps => ps.reduceLeft(AndType(_, _)) } - /** The element types of this tuple type, which can be made up of EmptyTuple, TupleX and `*:` pairs */ - def tupleElementTypes(using Context): Option[List[Type]] = self.dealias match { - case AppliedType(tycon, hd :: tl :: Nil) if tycon.isRef(defn.PairClass) => - tl.tupleElementTypes.map(hd :: _) - case self: SingletonType => - if self.termSymbol == defn.EmptyTupleModule then Some(Nil) else None - case AndType(tp1, tp2) => - // We assume that we have the following property: - // (T1, T2, ..., Tn) & (U1, U2, ..., Un) = (T1 & U1, T2 & U2, ..., Tn & Un) - tp1.tupleElementTypes.zip(tp2.tupleElementTypes).map { case (t1, t2) => t1.intersect(t2) } - case OrType(tp1, tp2) => - None // We can't combine the type of two tuples - case _ => - if defn.isTupleClass(self.typeSymbol) then Some(self.dealias.argInfos) - else None - } + /** The element types of this tuple type, which can be made up of EmptyTuple, TupleX and `*:` pairs + */ + def tupleElementTypes(using Context): Option[List[Type]] = + tupleElementTypesUpTo(Int.MaxValue) + + /** The element types of this tuple type, which can be made up of EmptyTuple, TupleX and `*:` pairs + * @param bound The maximum number of elements that needs generating minus 1 + * The generation will stop once more than bound elems have been generated + * @param normalize If true, normalize and dealias at each step. + * If false, never normalize and dealias only to find *: + * and EmptyTuple types. This is useful for printing. + */ + def tupleElementTypesUpTo(bound: Int, normalize: Boolean = true)(using Context): Option[List[Type]] = + def recur(tp: Type, bound: Int): Option[List[Type]] = + if bound < 0 then Some(Nil) + else (if normalize then tp.normalized else tp).dealias match + case AppliedType(tycon, hd :: tl :: Nil) if tycon.isRef(defn.PairClass) => + recur(tl, bound - 1).map(hd :: _) + case tp: AppliedType if defn.isTupleNType(tp) && normalize => + Some(tp.args) // if normalize is set, use the dealiased tuple + // otherwise rely on the default case below to print unaliased tuples. + case tp: SingletonType => + if tp.termSymbol == defn.EmptyTupleModule then Some(Nil) else None + case _ => + if defn.isTupleClass(tp.typeSymbol) && !normalize then Some(tp.dealias.argInfos) + else None + recur(self.stripTypeVar, bound) + + /** Is this a generic tuple that would fit into the range 1..22, + * but is not already an instance of one of Tuple1..22? + * In this case we need to cast it to make the TupleN/ members accessible. + * This works only for generic tuples of known size up to 22. + */ + def isSmallGenericTuple(using Context): Boolean = + self.derivesFrom(defn.PairClass) + && !defn.isTupleNType(self.widenDealias) + && self.widenTermRefExpr.tupleElementTypesUpTo(Definitions.MaxTupleArity).match + case Some(elems) if elems.length <= Definitions.MaxTupleArity => true + case _ => false /** The `*:` equivalent of an instance of a Tuple class */ def toNestedPairs(using Context): Type = diff --git a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala index df3ccb4337d0..776ca07d609c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -118,7 +118,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): // TupledFunction[?, (...) => R] tupled.functionArgInfos match case tupledArgs :: funRet :: Nil => - defn.tupleTypes(tupledArgs.dealias) match + tupledArgs.tupleElementTypes match case Some(funArgs) if functionTypeEqual(tupled, funArgs, funRet, fun) => // TupledFunction[?, ((...funArgs...)) => funRet] funArgs.size diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index ffabe0d7bde9..19ad7eaa8638 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -698,8 +698,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer // There's a second trial where we try to instantiate all type variables in `qual.tpe.widen`, // but that is done only after we search for extension methods or conversions. typedSelect(tree, pt, qual) - else if defn.isSmallGenericTuple(qual.tpe) then - val elems = defn.tupleTypes(qual.tpe.widenTermRefExpr).getOrElse(Nil) + else if qual.tpe.isSmallGenericTuple then + val elems = qual.tpe.widenTermRefExpr.tupleElementTypes.getOrElse(Nil) typedSelect(tree, pt, qual.cast(defn.tupleType(elems))) else val tree1 = tryExtensionOrConversion( @@ -720,7 +720,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer if checkedType1.exists then gadts.println(i"Member selection healed by GADT approximation") finish(tree1, qual1, checkedType1) - else if defn.isSmallGenericTuple(qual1.tpe) then + else if qual1.tpe.isSmallGenericTuple then gadts.println(i"Tuple member selection healed by GADT approximation") typedSelect(tree, pt, qual1) else From dadccc427ef25a36f66dfac5480f9d1b01d17304 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Tue, 25 Jun 2024 00:15:30 +0200 Subject: [PATCH 2/3] Refactor TypeUtils = Move to core package. It was for historical reasons in transform because it was originally intended as a collection of type operations that were were useful in transform phases. But it's now used from everywhere. - Make a base class of Types, so that it does not need to be imported explicitly. [Cherry-picked 6793291700e141cb153f25b410d03393bf590747][modified] --- compiler/src/dotty/tools/dotc/ast/tpd.scala | 1 - .../src/dotty/tools/dotc/core/SymDenotations.scala | 1 - .../src/dotty/tools/dotc/core/TypeApplications.scala | 1 - compiler/src/dotty/tools/dotc/core/TypeComparer.scala | 1 - compiler/src/dotty/tools/dotc/core/TypeErasure.scala | 2 -- .../tools/dotc/{transform => core}/TypeUtils.scala | 11 +++-------- compiler/src/dotty/tools/dotc/core/Types.scala | 3 +-- .../dotty/tools/dotc/printing/RefinedPrinter.scala | 1 - .../dotty/tools/dotc/transform/AccessProxies.scala | 1 - compiler/src/dotty/tools/dotc/transform/Erasure.scala | 1 - .../dotty/tools/dotc/transform/ExtensionMethods.scala | 1 - .../dotty/tools/dotc/transform/FirstTransform.scala | 1 - .../tools/dotc/transform/FullParameterization.scala | 1 - .../tools/dotc/transform/GenericSignatures.scala | 1 - .../dotty/tools/dotc/transform/ParamForwarding.scala | 2 +- .../dotty/tools/dotc/transform/PatternMatcher.scala | 1 - .../dotty/tools/dotc/transform/SuperAccessors.scala | 2 +- .../tools/dotc/transform/TupleOptimizations.scala | 1 - .../src/dotty/tools/dotc/transform/patmat/Space.scala | 1 - .../src/dotty/tools/dotc/typer/Applications.scala | 1 - compiler/src/dotty/tools/dotc/typer/Checking.scala | 1 - compiler/src/dotty/tools/dotc/typer/ConstFold.scala | 1 - compiler/src/dotty/tools/dotc/typer/Dynamic.scala | 1 - compiler/src/dotty/tools/dotc/typer/Implicits.scala | 1 - compiler/src/dotty/tools/dotc/typer/Namer.scala | 1 - compiler/src/dotty/tools/dotc/typer/Synthesizer.scala | 1 - compiler/src/dotty/tools/dotc/typer/Typer.scala | 1 - 27 files changed, 6 insertions(+), 36 deletions(-) rename compiler/src/dotty/tools/dotc/{transform => core}/TypeUtils.scala (97%) diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 441068ef39e1..a637312c335f 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -5,7 +5,6 @@ package ast import dotty.tools.dotc.transform.{ExplicitOuter, Erasure} import typer.ProtoTypes import transform.SymUtils.* -import transform.TypeUtils.* import core.* import Scopes.newScope import util.Spans.*, Types.*, Contexts.*, Constants.*, Names.*, Flags.*, NameOps.* diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 3afae80ef0f2..37b9644b571f 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -23,7 +23,6 @@ import scala.util.control.NonFatal import config.Config import reporting.* import collection.mutable -import transform.TypeUtils.* import cc.{CapturingType, derivedCapturingType, Setup, EventuallyCapturingType, isEventuallyCapturingType} import scala.annotation.internal.sharable diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala index 3bac4474a6c4..ab216bfd147d 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala @@ -13,7 +13,6 @@ import StdNames.nme import Flags.{Module, Provisional} import dotty.tools.dotc.config.Config import cc.boxedUnlessFun -import dotty.tools.dotc.transform.TypeUtils.isErasedValueType object TypeApplications { diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 5d04ee48a31e..4c717bccead3 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -16,7 +16,6 @@ import TypeErasure.{erasedLub, erasedGlb} import TypeApplications.* import Variances.{Variance, variancesConform} import Constants.Constant -import transform.TypeUtils.* import transform.SymUtils.* import scala.util.control.NonFatal import typer.ProtoTypes.constrained diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index 2d918e6ed3d9..be028428804c 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -9,7 +9,6 @@ import TypeOps.makePackageObjPrefixExplicit import backend.sjs.JSDefinitions import transform.ExplicitOuter.* import transform.ValueClasses.* -import transform.TypeUtils.* import transform.ContextFunctionResults.* import unpickleScala2.Scala2Erasure import Decorators.* @@ -404,7 +403,6 @@ object TypeErasure { tp1 // After erasure, T | Nothing is just T and C | Null is just C, if C is a reference type. else tp1 match { case JavaArrayType(elem1) => - import dotty.tools.dotc.transform.TypeUtils.* tp2 match { case JavaArrayType(elem2) => if (elem1.isPrimitiveValueType || elem2.isPrimitiveValueType) diff --git a/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala similarity index 97% rename from compiler/src/dotty/tools/dotc/transform/TypeUtils.scala rename to compiler/src/dotty/tools/dotc/core/TypeUtils.scala index 4a64dffc7c25..0f7ab756d362 100644 --- a/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala @@ -1,17 +1,12 @@ package dotty.tools package dotc -package transform +package core -import core.* import TypeErasure.ErasedValueType -import Types.* -import Contexts.* -import Symbols.* +import Types.*, Contexts.*, Symbols.*, Flags.*, Decorators.* import Names.Name -import dotty.tools.dotc.core.Decorators.* - -object TypeUtils { +class TypeUtils { /** A decorator that provides methods on types * that are needed in the transformer pipeline. */ diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 7ec82eb6707f..8cc3770ee9e5 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -43,9 +43,8 @@ import scala.annotation.internal.sharable import scala.annotation.threadUnsafe import dotty.tools.dotc.transform.SymUtils.* -import dotty.tools.dotc.transform.TypeUtils.isErasedClass -object Types { +object Types extends TypeUtils { @sharable private var nextId = 0 diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 66737547bb21..3934e0995eef 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -23,7 +23,6 @@ import Trees.* import TypeApplications.* import NameKinds.{WildcardParamName, DefaultGetterName} import util.Chars.isOperatorPart -import transform.TypeUtils.* import transform.SymUtils.* import config.{Config, Feature} diff --git a/compiler/src/dotty/tools/dotc/transform/AccessProxies.scala b/compiler/src/dotty/tools/dotc/transform/AccessProxies.scala index c5ffde140bd6..237db90b315f 100644 --- a/compiler/src/dotty/tools/dotc/transform/AccessProxies.scala +++ b/compiler/src/dotty/tools/dotc/transform/AccessProxies.scala @@ -9,7 +9,6 @@ import Flags.* import Names.* import NameOps.* import Decorators.* -import TypeUtils.* import Types.* import util.Spans.Span import config.Printers.transforms diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index cd0eb048e040..028888fa61c6 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -29,7 +29,6 @@ import dotty.tools.dotc.ast.{tpd, untpd} import ast.TreeTypeMap import dotty.tools.dotc.core.{Constants, Flags} import ValueClasses.* -import TypeUtils.* import ContextFunctionResults.* import ExplicitOuter.* import core.Mode diff --git a/compiler/src/dotty/tools/dotc/transform/ExtensionMethods.scala b/compiler/src/dotty/tools/dotc/transform/ExtensionMethods.scala index 8b3a783745fb..22d3da39573d 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExtensionMethods.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExtensionMethods.scala @@ -15,7 +15,6 @@ import SymDenotations.*, Symbols.*, StdNames.*, Denotations.* import TypeErasure.{ valueErasure, ErasedValueType } import NameKinds.{ExtMethName, BodyRetainerName} import Decorators.* -import TypeUtils.* /** * Perform Step 1 in the inline classes SIP: Creates extension methods for all diff --git a/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala b/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala index ce14d3d3c457..b5bc43ee762c 100644 --- a/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala +++ b/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala @@ -16,7 +16,6 @@ import DenotTransformers.* import NameOps.* import NameKinds.OuterSelectName import StdNames.* -import TypeUtils.isErasedValueType import config.Feature import inlines.Inlines.inInlineMethod diff --git a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala index eafbd68fe478..5fa85f8ad7b0 100644 --- a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala +++ b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala @@ -6,7 +6,6 @@ import Types.* import Contexts.* import Symbols.* import Decorators.* -import TypeUtils.* import StdNames.nme import ast.* diff --git a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala index 77f4f76c33ba..36bc8ee8931d 100644 --- a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala +++ b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala @@ -15,7 +15,6 @@ import core.TypeErasure.{erasedGlb, erasure, fullErasure, isGenericArrayElement, import core.Types.* import core.classfile.ClassfileConstants import SymUtils.* -import TypeUtils.* import config.Printers.transforms import reporting.trace import java.lang.StringBuilder diff --git a/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala b/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala index 82ba3b7a1b7f..5c038cee2617 100644 --- a/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala +++ b/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala @@ -3,7 +3,7 @@ package dotc package transform import core.* -import Contexts.*, Types.*, Symbols.*, Flags.*, TypeUtils.*, DenotTransformers.*, StdNames.* +import Contexts.*, Types.*, Symbols.*, Flags.*, DenotTransformers.*, StdNames.* import Decorators.* import MegaPhase.* import NameKinds.ParamAccessorName diff --git a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala index 8f5eec693609..a96773fd05c6 100644 --- a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -9,7 +9,6 @@ import patmat.SpaceEngine import util.Spans.* import typer.Applications.* import SymUtils.* -import TypeUtils.* import Annotations.* import Flags.*, Constants.* import Decorators.* diff --git a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala index 2d8d51b4059f..13ea452bcc9e 100644 --- a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala +++ b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala @@ -7,7 +7,7 @@ import scala.collection.mutable import ValueClasses.isMethodWithExtension import core.* import Contexts.*, Flags.*, Symbols.*, Names.*, StdNames.*, NameOps.*, Trees.* -import TypeUtils.*, SymUtils.* +import SymUtils.* import DenotTransformers.DenotTransformer import Symbols.* import util.Spans.* diff --git a/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala b/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala index 5cdb13429a32..bdb7072a6530 100644 --- a/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala +++ b/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala @@ -10,7 +10,6 @@ import StdNames.* import Symbols.* import MegaPhase.* import Types.* -import transform.TypeUtils.* import dotty.tools.dotc.ast.tpd /** Optimize generic operations on tuples */ diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 5c8b2ee90712..166b5802cbb0 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -5,7 +5,6 @@ package patmat import core.* import Types.* -import TypeUtils.* import Contexts.* import Flags.* import ast.* diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index aae35b725f6b..9e20e925ea36 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -21,7 +21,6 @@ import NameKinds.DefaultGetterName import ProtoTypes.* import Inferencing.* import reporting.* -import transform.TypeUtils.* import transform.SymUtils.* import Nullables.*, NullOpsDecorator.* import config.Feature diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index e29bb1f76e6a..ebfc06c15564 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -38,7 +38,6 @@ import config.Feature import config.Feature.sourceVersion import config.SourceVersion.* import printing.Formatting.hlAsKeyword -import transform.TypeUtils.* import collection.mutable import reporting.* diff --git a/compiler/src/dotty/tools/dotc/typer/ConstFold.scala b/compiler/src/dotty/tools/dotc/typer/ConstFold.scala index 22e6260cd04e..8d3fe543d157 100644 --- a/compiler/src/dotty/tools/dotc/typer/ConstFold.scala +++ b/compiler/src/dotty/tools/dotc/typer/ConstFold.scala @@ -11,7 +11,6 @@ import Constants.* import Names.* import StdNames.* import Contexts.* -import transform.TypeUtils.* object ConstFold: diff --git a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala index 71b32b639997..c9013f0bc208 100644 --- a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala +++ b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala @@ -16,7 +16,6 @@ import util.Spans.* import core.Symbols.* import ErrorReporting.* import dotty.tools.dotc.transform.ValueClasses -import dotty.tools.dotc.transform.TypeUtils.isPrimitiveValueType import reporting.* object Dynamic { diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index d3da9de64439..f95bcebd4785 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -23,7 +23,6 @@ import ProtoTypes.* import ErrorReporting.* import Inferencing.{fullyDefinedType, isFullyDefined} import Scopes.newScope -import transform.TypeUtils.* import Hashable.* import util.{EqHashMap, Stats} import config.{Config, Feature} diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index b3533db98dff..cb489d94ca27 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -23,7 +23,6 @@ import parsing.Parsers.Parser import Annotations.* import Inferencing.* import transform.ValueClasses.* -import transform.TypeUtils.* import transform.SymUtils.* import TypeErasure.erasure import reporting.* diff --git a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala index 776ca07d609c..95bdbcaa1c06 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -12,7 +12,6 @@ import ProtoTypes.* import Inferencing.{fullyDefinedType, isFullyDefined} import ast.untpd import transform.SymUtils.* -import transform.TypeUtils.* import transform.SyntheticMembers.* import util.Property import ast.Trees.genericEmptyTree diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 19ad7eaa8638..8e7801b308c0 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -46,7 +46,6 @@ import config.SourceVersion.* import rewrites.Rewrites.patch import staging.StagingLevel import transform.SymUtils.* -import transform.TypeUtils.* import reporting.* import Nullables.* import NullOpsDecorator.* From dbdaf17bd8d1323278ed0bfb166e48738a83dd31 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Tue, 25 Jun 2024 00:52:36 +0200 Subject: [PATCH 3/3] Refactor SymUtils - Move to core package. It was for historical reasons in transform because it was originally intended as a collection of type operations that were were useful in transform phases. But it's now used from everywhere. - Make a base class of Types, so that it does not need to be imported explicitly. Also: move isDerivedValueClass to SymUtils [Cherry-picked 125321e157af0e12cfddeeea526a5e87166fcd65][modified] --- .../tools/backend/jvm/BCodeBodyBuilder.scala | 1 - .../tools/backend/jvm/BCodeSkelBuilder.scala | 2 +- .../tools/backend/jvm/BTypesFromSymbols.scala | 2 +- .../src/dotty/tools/backend/jvm/CodeGen.scala | 2 +- .../backend/jvm/DottyBackendInterface.scala | 2 +- .../src/dotty/tools/backend/sjs/JSCodeGen.scala | 2 +- .../src/dotty/tools/dotc/CompilationUnit.scala | 1 - compiler/src/dotty/tools/dotc/ast/Desugar.scala | 2 +- .../src/dotty/tools/dotc/ast/TreeInfo.scala | 2 +- .../src/dotty/tools/dotc/ast/TreeTypeMap.scala | 2 +- compiler/src/dotty/tools/dotc/ast/tpd.scala | 1 - .../src/dotty/tools/dotc/cc/CheckCaptures.scala | 1 - .../dotty/tools/dotc/config/JavaPlatform.scala | 2 +- .../dotc/{transform => core}/SymUtils.scala | 16 ++++++++++++---- .../src/dotty/tools/dotc/core/Symbols.scala | 3 +-- .../dotty/tools/dotc/core/TypeComparer.scala | 1 - .../src/dotty/tools/dotc/core/TypeErasure.scala | 10 +++++----- .../src/dotty/tools/dotc/core/TypeOps.scala | 1 - compiler/src/dotty/tools/dotc/core/Types.scala | 2 +- .../tools/dotc/core/tasty/TreePickler.scala | 1 - .../tools/dotc/core/tasty/TreeUnpickler.scala | 1 - .../core/unpickleScala2/Scala2Unpickler.scala | 1 - .../tools/dotc/inlines/InlineReducer.scala | 1 - .../src/dotty/tools/dotc/inlines/Inliner.scala | 1 - .../src/dotty/tools/dotc/inlines/Inlines.scala | 1 - .../tools/dotc/inlines/PrepareInlineable.scala | 1 - .../tools/dotc/interactive/Interactive.scala | 1 - .../tools/dotc/printing/RefinedPrinter.scala | 1 - .../dotty/tools/dotc/reporting/DidYouMean.scala | 1 - .../dotty/tools/dotc/reporting/messages.scala | 1 - .../src/dotty/tools/dotc/sbt/ExtractAPI.scala | 3 +-- .../tools/dotc/sbt/ExtractDependencies.scala | 2 +- .../dotc/semanticdb/ExtractSemanticDB.scala | 1 - .../src/dotty/tools/dotc/staging/HealType.scala | 2 +- .../dotc/transform/ArrayConstructors.scala | 4 ++-- .../tools/dotc/transform/BeanProperties.scala | 2 +- .../tools/dotc/transform/CheckShadowing.scala | 3 +-- .../tools/dotc/transform/CheckStatic.scala | 2 +- .../dotc/transform/CollectNullableFields.scala | 2 +- .../dotc/transform/CompleteJavaEnums.scala | 2 +- .../tools/dotc/transform/Constructors.scala | 2 +- .../tools/dotc/transform/Dependencies.scala | 2 +- .../dotty/tools/dotc/transform/EtaReduce.scala | 2 +- .../dotty/tools/dotc/transform/ExpandSAMs.scala | 1 - .../tools/dotc/transform/ExplicitOuter.scala | 2 +- .../tools/dotc/transform/ExplicitSelf.scala | 2 +- .../dotc/transform/GenericSignatures.scala | 4 ++-- .../dotty/tools/dotc/transform/Getters.scala | 5 ++--- .../tools/dotc/transform/HoistSuperArgs.scala | 2 +- .../dotty/tools/dotc/transform/Inlining.scala | 2 +- .../dotty/tools/dotc/transform/LambdaLift.scala | 2 +- .../dotty/tools/dotc/transform/LazyVals.scala | 1 - .../dotty/tools/dotc/transform/Memoize.scala | 2 +- .../src/dotty/tools/dotc/transform/Mixin.scala | 2 +- .../dotty/tools/dotc/transform/MixinOps.scala | 2 +- .../tools/dotc/transform/MoveStatics.scala | 2 +- .../tools/dotc/transform/PatternMatcher.scala | 4 ++-- .../tools/dotc/transform/PickleQuotes.scala | 2 +- .../dotty/tools/dotc/transform/PostTyper.scala | 2 +- .../tools/dotc/transform/PruneErasedDefs.scala | 2 +- .../dotty/tools/dotc/transform/Recheck.scala | 2 +- .../tools/dotc/transform/ReifiedReflect.scala | 2 +- .../tools/dotc/transform/ResolveSuper.scala | 2 +- .../tools/dotc/transform/SelectStatic.scala | 2 +- .../dotty/tools/dotc/transform/Splicing.scala | 2 +- .../dotty/tools/dotc/transform/Staging.scala | 2 +- .../tools/dotc/transform/SuperAccessors.scala | 2 +- .../tools/dotc/transform/SyntheticMembers.scala | 17 ++++++++--------- .../tools/dotc/transform/TypeTestsCasts.scala | 5 ++--- .../tools/dotc/transform/ValueClasses.scala | 9 --------- .../tools/dotc/transform/patmat/Space.scala | 1 - .../dotc/transform/sjs/ExplicitJSClasses.scala | 2 +- .../tools/dotc/transform/sjs/JSSymUtils.scala | 2 +- .../dotc/transform/sjs/PrepJSExports.scala | 2 +- .../dotc/transform/sjs/PrepJSInterop.scala | 2 +- .../dotty/tools/dotc/typer/Applications.scala | 1 - .../src/dotty/tools/dotc/typer/Checking.scala | 5 ++--- .../tools/dotc/typer/CrossVersionChecks.scala | 2 +- .../src/dotty/tools/dotc/typer/Dynamic.scala | 4 ++-- compiler/src/dotty/tools/dotc/typer/Namer.scala | 1 - .../tools/dotc/typer/QuotesAndSplices.scala | 2 +- .../src/dotty/tools/dotc/typer/RefChecks.scala | 2 +- .../dotty/tools/dotc/typer/Synthesizer.scala | 1 - compiler/src/dotty/tools/dotc/typer/Typer.scala | 1 - .../src/dotty/tools/dotc/util/Signatures.scala | 3 +-- compiler/src/dotty/tools/repl/Rendering.scala | 3 +-- .../tools/pc/completions/CompletionValue.scala | 1 - .../tools/pc/completions/Completions.scala | 1 - .../pc/completions/KeywordsCompletions.scala | 1 - 89 files changed, 89 insertions(+), 127 deletions(-) rename compiler/src/dotty/tools/dotc/{transform => core}/SymUtils.scala (97%) diff --git a/compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala b/compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala index 84f1756781cd..d7c84f98f49a 100644 --- a/compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala +++ b/compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala @@ -19,7 +19,6 @@ import dotty.tools.dotc.core.Types.* import dotty.tools.dotc.core.StdNames.{nme, str} import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.transform.Erasure -import dotty.tools.dotc.transform.SymUtils.* import dotty.tools.dotc.util.Spans.* import dotty.tools.dotc.core.Contexts.* import dotty.tools.dotc.core.Phases.* diff --git a/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala b/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala index 61383d2000d1..0ab9ed85b6cf 100644 --- a/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala +++ b/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala @@ -20,7 +20,7 @@ import dotty.tools.dotc.core.Types.* import dotty.tools.dotc.core.Contexts.* import dotty.tools.dotc.util.Spans.* import dotty.tools.dotc.report -import dotty.tools.dotc.transform.SymUtils.* + /* * diff --git a/compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala b/compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala index 992f3a3b3489..ec23998ccd72 100644 --- a/compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala +++ b/compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala @@ -12,7 +12,7 @@ import dotty.tools.dotc.core.Contexts.* import dotty.tools.dotc.core.Phases.* import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.core.Phases.Phase -import dotty.tools.dotc.transform.SymUtils.* + import dotty.tools.dotc.core.StdNames import dotty.tools.dotc.core.Phases diff --git a/compiler/src/dotty/tools/backend/jvm/CodeGen.scala b/compiler/src/dotty/tools/backend/jvm/CodeGen.scala index 85b865696819..a54d0a00fdc4 100644 --- a/compiler/src/dotty/tools/backend/jvm/CodeGen.scala +++ b/compiler/src/dotty/tools/backend/jvm/CodeGen.scala @@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Phases.Phase import scala.collection.mutable import scala.jdk.CollectionConverters.* -import dotty.tools.dotc.transform.SymUtils.* + import dotty.tools.dotc.interfaces import dotty.tools.dotc.report diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 86ffc98283a3..09b80d668af5 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -4,7 +4,7 @@ import scala.language.unsafeNulls import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.core.Flags.* -import dotty.tools.dotc.transform.SymUtils.* + import java.io.{File => _} import scala.reflect.ClassTag diff --git a/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala b/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala index ff3a0684a8c9..9a74febca2e7 100644 --- a/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala +++ b/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala @@ -21,7 +21,7 @@ import StdNames.* import TypeErasure.ErasedValueType import dotty.tools.dotc.transform.{Erasure, ValueClasses} -import dotty.tools.dotc.transform.SymUtils.* + import dotty.tools.dotc.util.SourcePosition import dotty.tools.dotc.report diff --git a/compiler/src/dotty/tools/dotc/CompilationUnit.scala b/compiler/src/dotty/tools/dotc/CompilationUnit.scala index 54b111bee427..f9eb2755f8d8 100644 --- a/compiler/src/dotty/tools/dotc/CompilationUnit.scala +++ b/compiler/src/dotty/tools/dotc/CompilationUnit.scala @@ -12,7 +12,6 @@ import ast.{tpd, untpd} import tpd.{Tree, TreeTraverser} import ast.Trees.{Import, Ident} import typer.Nullables -import transform.SymUtils.* import core.Decorators.* import config.{SourceVersion, Feature} import StdNames.nme diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 9def22feb849..122a34d0b1b1 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -5,7 +5,7 @@ package ast import core.* import util.Spans.*, Types.*, Contexts.*, Constants.*, Names.*, NameOps.*, Flags.* import Symbols.*, StdNames.*, Trees.*, ContextOps.* -import Decorators.*, transform.SymUtils.* +import Decorators.* import Annotations.Annotation import NameKinds.{UniqueName, ContextBoundParamName, ContextFunctionParamName, DefaultGetterName, WildcardParamName} import typer.{Namer, Checking} diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index eac65b2d1e80..df8b235e302b 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -7,7 +7,7 @@ import Flags.*, Trees.*, Types.*, Contexts.* import Names.*, StdNames.*, NameOps.*, Symbols.* import typer.ConstFold import reporting.trace -import dotty.tools.dotc.transform.SymUtils.* + import Decorators.* import Constants.Constant import scala.collection.mutable diff --git a/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala b/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala index 06af2cdc31a9..4d26781cd7be 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala @@ -6,7 +6,7 @@ import core.* import Types.*, Contexts.*, Flags.* import Symbols.*, Annotations.*, Trees.*, Symbols.*, Constants.Constant import Decorators.* -import dotty.tools.dotc.transform.SymUtils.* + /** A map that applies three functions and a substitution together to a tree and * makes sure they are coordinated so that the result is well-typed. The functions are diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index a637312c335f..d207e133f958 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -4,7 +4,6 @@ package ast import dotty.tools.dotc.transform.{ExplicitOuter, Erasure} import typer.ProtoTypes -import transform.SymUtils.* import core.* import Scopes.newScope import util.Spans.*, Types.*, Contexts.*, Constants.*, Names.*, Flags.*, NameOps.* diff --git a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala index e989574ee794..5ae9e2b2e32c 100644 --- a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala +++ b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala @@ -13,7 +13,6 @@ import Trees.* import typer.RefChecks.{checkAllOverrides, checkSelfAgainstParents, OverridingPairsChecker} import typer.Checking.{checkBounds, checkAppliedTypesIn} import util.{SimpleIdentitySet, EqHashMap, SrcPos} -import transform.SymUtils.* import transform.{Recheck, PreRecheck} import Recheck.* import scala.collection.mutable diff --git a/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala b/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala index e2d4cae3b553..884e40e97d96 100644 --- a/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala +++ b/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala @@ -7,7 +7,7 @@ import classpath.AggregateClassPath import core.* import Symbols.*, Types.*, Contexts.*, StdNames.* import Flags.* -import transform.ExplicitOuter, transform.SymUtils.* +import transform.ExplicitOuter class JavaPlatform extends Platform { diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/core/SymUtils.scala similarity index 97% rename from compiler/src/dotty/tools/dotc/transform/SymUtils.scala rename to compiler/src/dotty/tools/dotc/core/SymUtils.scala index e2b006d0d738..b6657615d505 100644 --- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/core/SymUtils.scala @@ -1,5 +1,5 @@ package dotty.tools.dotc -package transform +package core import core.* import Types.* @@ -11,18 +11,18 @@ import NameOps.* import StdNames.* import NameKinds.* import Flags.* -import ValueClasses.isDerivedValueClass import Decorators.* import Constants.Constant import Annotations.Annotation import Phases.* import ast.tpd.Literal +import transform.Mixin import dotty.tools.dotc.transform.sjs.JSSymUtils.sjsNeedsField import scala.annotation.tailrec -object SymUtils: +class SymUtils: extension (self: Symbol) @@ -79,6 +79,14 @@ object SymUtils: self.is(Enum, butNot = Case) && self.info.parents.exists(p => p.typeSymbol == defn.JavaEnumClass) + def isDerivedValueClass(using Context): Boolean = self.isClass && { + val d = self.denot + !d.isRefinementClass && + d.isValueClass && + (d.initial.symbol ne defn.AnyValClass) && // Compare the initial symbol because AnyVal does not exist after erasure + !d.isPrimitiveValueClass + } + /** Is this a case class for which a product mirror is generated? * Excluded are value classes, abstract classes and case classes with more than one * parameter section. @@ -100,7 +108,7 @@ object SymUtils: if (!self.is(CaseClass)) "it is not a case class" else if (self.is(Abstract)) "it is an abstract class" else if (self.primaryConstructor.info.paramInfoss.length != 1) "it takes more than one parameter list" - else if (isDerivedValueClass(self)) "it is a value class" + else if self.isDerivedValueClass then "it is a value class" else if (!(companionMirror || canAccessCtor)) s"the constructor of $self is inaccessible from the calling scope." else "" end whyNotGenericProduct diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index e914dfaa8d3c..d6dd03c4c522 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -18,7 +18,6 @@ import util.Spans.* import DenotTransformers.* import StdNames.* import NameOps.* -import transform.SymUtils.* import NameKinds.LazyImplicitName import ast.tpd import tpd.{Tree, TreeProvider, TreeOps} @@ -32,7 +31,7 @@ import util.{SourceFile, NoSource, Property, SourcePosition, SrcPos, EqHashMap} import scala.annotation.internal.sharable import config.Printers.typr -object Symbols { +object Symbols extends SymUtils { implicit def eqSymbol: CanEqual[Symbol, Symbol] = CanEqual.derived diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 4c717bccead3..353e7746280d 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -16,7 +16,6 @@ import TypeErasure.{erasedLub, erasedGlb} import TypeApplications.* import Variances.{Variance, variancesConform} import Constants.Constant -import transform.SymUtils.* import scala.util.control.NonFatal import typer.ProtoTypes.constrained import typer.Applications.productSelectorTypes diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index be028428804c..c24375ebdf5a 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -71,7 +71,7 @@ end SourceLanguage object TypeErasure { private def erasureDependsOnArgs(sym: Symbol)(using Context) = - sym == defn.ArrayClass || sym == defn.PairClass || isDerivedValueClass(sym) + sym == defn.ArrayClass || sym == defn.PairClass || sym.isDerivedValueClass /** The arity of this tuple type, which can be made up of EmptyTuple, TupleX and `*:` pairs. * @@ -125,7 +125,7 @@ object TypeErasure { case tp: TypeRef => val sym = tp.symbol sym.isClass && - (!erasureDependsOnArgs(sym) || isDerivedValueClass(sym)) && + (!erasureDependsOnArgs(sym) || sym.isDerivedValueClass) && !defn.specialErasure.contains(sym) && !defn.isSyntheticFunctionClass(sym) case _: TermRef => @@ -630,7 +630,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst case tp: TypeRef => val sym = tp.symbol if !sym.isClass then this(checkedSuperType(tp)) - else if semiEraseVCs && isDerivedValueClass(sym) then eraseDerivedValueClass(tp) + else if semiEraseVCs && sym.isDerivedValueClass then eraseDerivedValueClass(tp) else if defn.isSyntheticFunctionClass(sym) then defn.functionTypeErasure(sym) else eraseNormalClassRef(tp) case tp: AppliedType => @@ -638,7 +638,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst if (tycon.isRef(defn.ArrayClass)) eraseArray(tp) else if (tycon.isRef(defn.PairClass)) erasePair(tp) else if (tp.isRepeatedParam) apply(tp.translateFromRepeated(toArray = sourceLanguage.isJava)) - else if (semiEraseVCs && isDerivedValueClass(tycon.classSymbol)) eraseDerivedValueClass(tp) + else if (semiEraseVCs && tycon.classSymbol.isDerivedValueClass) eraseDerivedValueClass(tp) else this(checkedSuperType(tp)) case tp: TermRef => this(underlyingOfTermRef(tp)) @@ -898,7 +898,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst if (!info.exists) assert(false, i"undefined: $tp with symbol $sym") return sigName(info) } - if (semiEraseVCs && isDerivedValueClass(sym)) { + if (semiEraseVCs && sym.isDerivedValueClass) { val erasedVCRef = eraseDerivedValueClass(tp) if (erasedVCRef.exists) return sigName(erasedVCRef) } diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 01dd0cd4664e..7e3afb35b2b6 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -13,7 +13,6 @@ import ast.tpd.* import reporting.trace import config.Printers.typr import config.Feature -import transform.SymUtils.* import typer.ProtoTypes.* import typer.ForceDegree import typer.Inferencing.* diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 8cc3770ee9e5..ee067abe2c7d 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -42,7 +42,7 @@ import CaptureSet.{CompareResult, IdempotentCaptRefMap, IdentityCaptRefMap} import scala.annotation.internal.sharable import scala.annotation.threadUnsafe -import dotty.tools.dotc.transform.SymUtils.* + object Types extends TypeUtils { diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index ce4fde3896af..f2ff8faa605a 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -14,7 +14,6 @@ import Contexts.*, Symbols.*, Types.*, Names.*, Constants.*, Decorators.*, Annot import Comments.{Comment, CommentsContext} import NameKinds.* import StdNames.nme -import transform.SymUtils.* import config.Config import collection.mutable import reporting.{Profile, NoProfile} diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 25c92db22885..f0447ae57759 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -31,7 +31,6 @@ import util.{SourceFile, Property} import ast.{Trees, tpd, untpd} import Trees.* import Decorators.* -import transform.SymUtils.* import cc.{adaptFunctionTypeUnderPureFuns, adaptByNameArgUnderPureFuns} import dotty.tools.tasty.{TastyBuffer, TastyReader} diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index a59d3ec42d43..ecbff01f5bce 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -23,7 +23,6 @@ import util.common.* import util.NoSourcePosition import typer.Checking.checkNonCyclic import typer.Nullables.* -import transform.SymUtils.* import PickleBuffer.* import PickleFormat.* import Decorators.* diff --git a/compiler/src/dotty/tools/dotc/inlines/InlineReducer.scala b/compiler/src/dotty/tools/dotc/inlines/InlineReducer.scala index 2dbfd9117f48..4680ea77df9c 100644 --- a/compiler/src/dotty/tools/dotc/inlines/InlineReducer.scala +++ b/compiler/src/dotty/tools/dotc/inlines/InlineReducer.scala @@ -5,7 +5,6 @@ package inlines import ast.*, core.* import Flags.*, Symbols.*, Types.*, Decorators.*, Contexts.* import StdNames.nme -import transform.SymUtils.* import typer.* import Names.TermName import NameKinds.{InlineAccessorName, InlineBinderName, InlineScrutineeName} diff --git a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala index a444c899c092..d2817a879a04 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala @@ -4,7 +4,6 @@ package inlines import ast.*, core.* import Flags.*, Symbols.*, Types.*, Decorators.*, Constants.*, Contexts.* -import transform.SymUtils.* import StdNames.nme import typer.* import Names.Name diff --git a/compiler/src/dotty/tools/dotc/inlines/Inlines.scala b/compiler/src/dotty/tools/dotc/inlines/Inlines.scala index 91b549f3ca45..89b70711db66 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inlines.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inlines.scala @@ -5,7 +5,6 @@ package inlines import ast.*, core.* import Flags.*, Symbols.*, Types.*, Decorators.*, Constants.*, Contexts.* import StdNames.{tpnme, nme} -import transform.SymUtils.* import typer.* import NameKinds.BodyRetainerName import SymDenotations.SymDenotation diff --git a/compiler/src/dotty/tools/dotc/inlines/PrepareInlineable.scala b/compiler/src/dotty/tools/dotc/inlines/PrepareInlineable.scala index 10b55d69bf37..0b5c72bd997f 100644 --- a/compiler/src/dotty/tools/dotc/inlines/PrepareInlineable.scala +++ b/compiler/src/dotty/tools/dotc/inlines/PrepareInlineable.scala @@ -19,7 +19,6 @@ import NameOps.* import Annotations.* import transform.{AccessProxies, Splicer} import staging.CrossStageSafety -import transform.SymUtils.* import config.Printers.inlining import util.Property import staging.StagingLevel diff --git a/compiler/src/dotty/tools/dotc/interactive/Interactive.scala b/compiler/src/dotty/tools/dotc/interactive/Interactive.scala index 6c8e3b61cd01..3f3e5e25f66e 100644 --- a/compiler/src/dotty/tools/dotc/interactive/Interactive.scala +++ b/compiler/src/dotty/tools/dotc/interactive/Interactive.scala @@ -10,7 +10,6 @@ import ast.{NavigateAST, Trees, tpd, untpd} import core.* import Decorators.*, ContextOps.* import Contexts.*, Flags.*, Names.*, NameOps.*, Symbols.*, Trees.*, Types.* -import transform.SymUtils.* import util.Spans.*, util.SourceFile, util.SourcePosition /** High-level API to get information out of typed trees, designed to be used by IDEs. diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 3934e0995eef..2872f1f823c4 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -23,7 +23,6 @@ import Trees.* import TypeApplications.* import NameKinds.{WildcardParamName, DefaultGetterName} import util.Chars.isOperatorPart -import transform.SymUtils.* import config.{Config, Feature} import dotty.tools.dotc.util.SourcePosition diff --git a/compiler/src/dotty/tools/dotc/reporting/DidYouMean.scala b/compiler/src/dotty/tools/dotc/reporting/DidYouMean.scala index a9b2f68d07d6..04b9b518fd5e 100644 --- a/compiler/src/dotty/tools/dotc/reporting/DidYouMean.scala +++ b/compiler/src/dotty/tools/dotc/reporting/DidYouMean.scala @@ -6,7 +6,6 @@ import core.* import Contexts.* import Decorators.*, Symbols.*, Names.*, Types.*, Flags.* import typer.ProtoTypes.{FunProto, SelectionProto} -import transform.SymUtils.isNoValue /** A utility object to support "did you mean" hinting */ object DidYouMean: diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index 08c0430c17f4..ee3a636e31b1 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -25,7 +25,6 @@ import printing.Formatting.hl import ast.Trees.* import ast.untpd import ast.tpd -import transform.SymUtils.* import scala.util.matching.Regex import java.util.regex.Matcher.quoteReplacement import cc.CaptureSet.IdentityCaptRefMap diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala index c0c8f47648de..d088b2f6fca0 100644 --- a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala +++ b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala @@ -18,7 +18,6 @@ import Names.* import NameOps.* import inlines.Inlines import transform.ValueClasses -import transform.SymUtils.* import dotty.tools.io.File import java.io.PrintWriter @@ -274,7 +273,7 @@ private class ExtractAPICollector(using Context) extends ThunkHolder { report.error(ex, csym.sourcePos) defn.ObjectType :: Nil } - if (ValueClasses.isDerivedValueClass(csym)) { + if (csym.isDerivedValueClass) { val underlying = ValueClasses.valueClassUnbox(csym).info.finalResultType // The underlying type of a value class should be part of the name hash // of the value class (see the test `value-class-underlying`), this is accomplished diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala index cba7b27f7e47..89fe69623081 100644 --- a/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala +++ b/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala @@ -17,7 +17,7 @@ import dotty.tools.dotc.core.Phases.* import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.core.Denotations.StaleSymbol import dotty.tools.dotc.core.Types.* -import dotty.tools.dotc.transform.SymUtils.* + import dotty.tools.dotc.util.{SrcPos, NoSourcePosition} import dotty.tools.io import dotty.tools.io.{AbstractFile, PlainFile, ZipArchive} diff --git a/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala b/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala index 75805d4aed17..77eef4564bbf 100644 --- a/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala +++ b/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala @@ -17,7 +17,6 @@ import NameOps.* import Denotations.StaleSymbol import util.Spans.Span import util.SourceFile -import transform.SymUtils.* import scala.collection.mutable import scala.annotation.{ threadUnsafe => tu, tailrec } diff --git a/compiler/src/dotty/tools/dotc/staging/HealType.scala b/compiler/src/dotty/tools/dotc/staging/HealType.scala index 2469bd73bdcb..8b77f0774cdc 100644 --- a/compiler/src/dotty/tools/dotc/staging/HealType.scala +++ b/compiler/src/dotty/tools/dotc/staging/HealType.scala @@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.core.Types.* import dotty.tools.dotc.staging.StagingLevel.* import dotty.tools.dotc.staging.QuoteTypeTags.* -import dotty.tools.dotc.transform.SymUtils.* + import dotty.tools.dotc.typer.Implicits.SearchFailureType import dotty.tools.dotc.util.SrcPos diff --git a/compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala b/compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala index b0106f0d2ff3..e94fa612e6cf 100644 --- a/compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala +++ b/compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala @@ -38,10 +38,10 @@ class ArrayConstructors extends MiniPhase { val cs = tp.tpe.classSymbol tree.fun match { case Apply(TypeApply(t: Ident, targ), dims) - if !TypeErasure.isGeneric(targ.head.tpe) && !ValueClasses.isDerivedValueClass(cs) => + if !TypeErasure.isGeneric(targ.head.tpe) && !cs.isDerivedValueClass => expand(targ.head.tpe, dims) case Apply(TypeApply(t: Select, targ), dims) - if !TypeErasure.isGeneric(targ.head.tpe) && !ValueClasses.isDerivedValueClass(cs) => + if !TypeErasure.isGeneric(targ.head.tpe) && !cs.isDerivedValueClass => Block(t.qualifier :: Nil, expand(targ.head.tpe, dims)) case _ => tree } diff --git a/compiler/src/dotty/tools/dotc/transform/BeanProperties.scala b/compiler/src/dotty/tools/dotc/transform/BeanProperties.scala index 7e21703f67ee..57aeb93a3b61 100644 --- a/compiler/src/dotty/tools/dotc/transform/BeanProperties.scala +++ b/compiler/src/dotty/tools/dotc/transform/BeanProperties.scala @@ -6,7 +6,7 @@ import ast.tpd.* import Annotations.* import Contexts.* import Symbols.* -import SymUtils.* + import Decorators.* import Flags.* import Names.* diff --git a/compiler/src/dotty/tools/dotc/transform/CheckShadowing.scala b/compiler/src/dotty/tools/dotc/transform/CheckShadowing.scala index fdc055df9ac4..a85cabdd5460 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckShadowing.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckShadowing.scala @@ -19,8 +19,7 @@ import dotty.tools.dotc.core.Types.Type import dotty.tools.dotc.core.Types import dotty.tools.dotc.semanticdb.TypeOps import dotty.tools.dotc.cc.boxedCaptureSet -import dotty.tools.dotc.core.Symbols.NoSymbol -import dotty.tools.dotc.transform.SymUtils.isParamOrAccessor +import dotty.tools.dotc.core.Symbols.{NoSymbol, isParamOrAccessor} import scala.collection.mutable import dotty.tools.dotc.core.Scopes.Scope import scala.collection.immutable.HashMap diff --git a/compiler/src/dotty/tools/dotc/transform/CheckStatic.scala b/compiler/src/dotty/tools/dotc/transform/CheckStatic.scala index 2b616bad0a01..26c94407f35b 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckStatic.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckStatic.scala @@ -9,7 +9,7 @@ import Symbols.* import dotty.tools.dotc.ast.tpd import reporting.* -import dotty.tools.dotc.transform.SymUtils.* + /** A transformer that check that requirements of Static fields\methods are implemented: * 1. Only objects can have members annotated with `@static` diff --git a/compiler/src/dotty/tools/dotc/transform/CollectNullableFields.scala b/compiler/src/dotty/tools/dotc/transform/CollectNullableFields.scala index 22739dc528c8..9433f7949163 100644 --- a/compiler/src/dotty/tools/dotc/transform/CollectNullableFields.scala +++ b/compiler/src/dotty/tools/dotc/transform/CollectNullableFields.scala @@ -5,7 +5,7 @@ import dotty.tools.dotc.core.Contexts.* import dotty.tools.dotc.core.Flags.* import dotty.tools.dotc.core.Symbols.Symbol import dotty.tools.dotc.transform.MegaPhase.MiniPhase -import dotty.tools.dotc.transform.SymUtils.* + import scala.collection.mutable diff --git a/compiler/src/dotty/tools/dotc/transform/CompleteJavaEnums.scala b/compiler/src/dotty/tools/dotc/transform/CompleteJavaEnums.scala index eac0b9f05c60..5740f359cb77 100644 --- a/compiler/src/dotty/tools/dotc/transform/CompleteJavaEnums.scala +++ b/compiler/src/dotty/tools/dotc/transform/CompleteJavaEnums.scala @@ -13,7 +13,7 @@ import Symbols.* import Constants.* import Decorators.* import DenotTransformers.* -import SymUtils.* + object CompleteJavaEnums { diff --git a/compiler/src/dotty/tools/dotc/transform/Constructors.scala b/compiler/src/dotty/tools/dotc/transform/Constructors.scala index e465e42fe8d8..9a0df830c6d7 100644 --- a/compiler/src/dotty/tools/dotc/transform/Constructors.scala +++ b/compiler/src/dotty/tools/dotc/transform/Constructors.scala @@ -10,7 +10,7 @@ import Flags.* import Names.Name import NameOps.* import NameKinds.{FieldName, ExplicitFieldName} -import SymUtils.* + import Symbols.* import Decorators.* import DenotTransformers.* diff --git a/compiler/src/dotty/tools/dotc/transform/Dependencies.scala b/compiler/src/dotty/tools/dotc/transform/Dependencies.scala index ea32f513f5bb..eda97e14c521 100644 --- a/compiler/src/dotty/tools/dotc/transform/Dependencies.scala +++ b/compiler/src/dotty/tools/dotc/transform/Dependencies.scala @@ -3,7 +3,7 @@ package transform import core.* import Symbols.*, Contexts.*, Types.*, Flags.*, Decorators.* -import SymUtils.* + import collection.mutable.{LinkedHashMap, LinkedHashSet} import annotation.constructorOnly diff --git a/compiler/src/dotty/tools/dotc/transform/EtaReduce.scala b/compiler/src/dotty/tools/dotc/transform/EtaReduce.scala index b8b10d355ede..a8565d008f46 100644 --- a/compiler/src/dotty/tools/dotc/transform/EtaReduce.scala +++ b/compiler/src/dotty/tools/dotc/transform/EtaReduce.scala @@ -6,7 +6,7 @@ import MegaPhase.MiniPhase import core.* import Symbols.*, Contexts.*, Types.*, Decorators.* import StdNames.nme -import SymUtils.* + import NameKinds.AdaptedClosureName /** Rewrite `(x1, ... xN) => f(x1, ... xN)` for N >= 0 to `f`, diff --git a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala index 532ceab0ff2f..47c2dad1d61b 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala @@ -6,7 +6,6 @@ import core.* import Scopes.newScope import Contexts.*, Symbols.*, Types.*, Flags.*, Decorators.*, StdNames.*, Constants.* import MegaPhase.* -import SymUtils.* import NullOpsDecorator.* import ast.untpd diff --git a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala index b197d23f0b94..f57595293ae1 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -14,7 +14,7 @@ import core.StdNames.nme import core.Names.* import core.NameOps.* import core.NameKinds.SuperArgName -import SymUtils.* + import dotty.tools.dotc.ast.tpd import collection.mutable diff --git a/compiler/src/dotty/tools/dotc/transform/ExplicitSelf.scala b/compiler/src/dotty/tools/dotc/transform/ExplicitSelf.scala index cd62a55cb8dc..cc4f1e8f45b8 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExplicitSelf.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExplicitSelf.scala @@ -3,7 +3,7 @@ package transform import core.* import Contexts.*, Types.*, MegaPhase.*, ast.Trees.*, Symbols.*, Decorators.*, Flags.* -import SymUtils.* + /** Transform references of the form * diff --git a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala index 36bc8ee8931d..7fbaef4bf221 100644 --- a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala +++ b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala @@ -14,7 +14,7 @@ import core.TypeApplications.{EtaExpansion, TypeParamInfo} import core.TypeErasure.{erasedGlb, erasure, fullErasure, isGenericArrayElement, tupleArity} import core.Types.* import core.classfile.ClassfileConstants -import SymUtils.* + import config.Printers.transforms import reporting.trace import java.lang.StringBuilder @@ -272,7 +272,7 @@ object GenericSignatures { if (!primitiveOK) jsig(defn.ObjectType) else if (sym == defn.UnitClass) jsig(defn.BoxedUnitClass.typeRef) else builder.append(defn.typeTag(sym.info)) - else if (ValueClasses.isDerivedValueClass(sym)) { + else if (sym.isDerivedValueClass) { val erasedUnderlying = fullErasure(tp) if (erasedUnderlying.isPrimitiveValueType && !primitiveOK) classSig(sym, pre, args) diff --git a/compiler/src/dotty/tools/dotc/transform/Getters.scala b/compiler/src/dotty/tools/dotc/transform/Getters.scala index eeb2e868ddc8..43289209d146 100644 --- a/compiler/src/dotty/tools/dotc/transform/Getters.scala +++ b/compiler/src/dotty/tools/dotc/transform/Getters.scala @@ -9,8 +9,7 @@ import Types.* import Symbols.* import MegaPhase.* import Flags.* -import ValueClasses.* -import SymUtils.* + import NameOps.* @@ -66,7 +65,7 @@ class Getters extends MiniPhase with SymTransformer { thisPhase => override def transformSym(d: SymDenotation)(using Context): SymDenotation = { def noGetterNeeded = d.isOneOf(NoGetterNeededFlags) || - d.isAllOf(PrivateLocal) && !d.owner.is(Trait) && !isDerivedValueClass(d.owner) && !d.is(Lazy) || + d.isAllOf(PrivateLocal) && !d.owner.is(Trait) && !d.owner.isDerivedValueClass && !d.is(Lazy) || d.is(Module) && d.isStatic || d.hasAnnotation(defn.ScalaStaticAnnot) || d.isSelfSym diff --git a/compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala b/compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala index 190150ca8a81..96cffeb1097d 100644 --- a/compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala +++ b/compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala @@ -12,7 +12,7 @@ import core.Decorators.* import collection.mutable import ast.Trees.* import core.NameKinds.SuperArgName -import SymUtils.* + import core.Decorators.* object HoistSuperArgs { diff --git a/compiler/src/dotty/tools/dotc/transform/Inlining.scala b/compiler/src/dotty/tools/dotc/transform/Inlining.scala index bfc44f868cb6..2215a580dccd 100644 --- a/compiler/src/dotty/tools/dotc/transform/Inlining.scala +++ b/compiler/src/dotty/tools/dotc/transform/Inlining.scala @@ -5,7 +5,7 @@ import core.* import Flags.* import Contexts.* import Symbols.* -import SymUtils.* + import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.ast.Trees.* import dotty.tools.dotc.quoted.* diff --git a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala index 0d8f98c0815e..3fbdf1fa5427 100644 --- a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala +++ b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala @@ -13,7 +13,7 @@ import core.StdNames.nme import core.Names.* import core.NameOps.* import core.NameKinds.ExpandPrefixName -import SymUtils.* + import ExplicitOuter.outer import util.Store import collection.mutable.{HashMap, LinkedHashMap, ListBuffer} diff --git a/compiler/src/dotty/tools/dotc/transform/LazyVals.scala b/compiler/src/dotty/tools/dotc/transform/LazyVals.scala index 5e78d25000db..e6cae7010ade 100644 --- a/compiler/src/dotty/tools/dotc/transform/LazyVals.scala +++ b/compiler/src/dotty/tools/dotc/transform/LazyVals.scala @@ -16,7 +16,6 @@ import core.Types.* import core.{Names, StdNames} import dotty.tools.dotc.config.Feature import transform.MegaPhase.MiniPhase -import transform.SymUtils.* import scala.collection.mutable diff --git a/compiler/src/dotty/tools/dotc/transform/Memoize.scala b/compiler/src/dotty/tools/dotc/transform/Memoize.scala index 98a38d91f0d9..a4d238106c08 100644 --- a/compiler/src/dotty/tools/dotc/transform/Memoize.scala +++ b/compiler/src/dotty/tools/dotc/transform/Memoize.scala @@ -8,7 +8,7 @@ import Phases.* import SymDenotations.SymDenotation import Denotations.* import Symbols.* -import SymUtils.* + import Constants.* import MegaPhase.* import NameOps.* diff --git a/compiler/src/dotty/tools/dotc/transform/Mixin.scala b/compiler/src/dotty/tools/dotc/transform/Mixin.scala index 33864a33a047..6df4bebde132 100644 --- a/compiler/src/dotty/tools/dotc/transform/Mixin.scala +++ b/compiler/src/dotty/tools/dotc/transform/Mixin.scala @@ -6,7 +6,7 @@ import core.* import MegaPhase.* import Contexts.* import Flags.* -import SymUtils.* + import Symbols.* import SymDenotations.* import Types.* diff --git a/compiler/src/dotty/tools/dotc/transform/MixinOps.scala b/compiler/src/dotty/tools/dotc/transform/MixinOps.scala index d40a2a7eb17e..1b2d3e79c9a4 100644 --- a/compiler/src/dotty/tools/dotc/transform/MixinOps.scala +++ b/compiler/src/dotty/tools/dotc/transform/MixinOps.scala @@ -4,7 +4,7 @@ package transform import core.* import Symbols.*, Types.*, Contexts.*, DenotTransformers.*, Flags.* import util.Spans.* -import SymUtils.* + import StdNames.*, NameOps.* import typer.Nullables diff --git a/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala b/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala index a417d41ffd56..95975ad9e6b8 100644 --- a/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala +++ b/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala @@ -15,7 +15,7 @@ import NameOps.* import ast.* -import SymUtils.* + import MegaPhase.* /** Move static methods from companion to the class itself */ diff --git a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala index a96773fd05c6..91c83170db0e 100644 --- a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -8,7 +8,7 @@ import Symbols.*, Contexts.*, Types.*, StdNames.*, NameOps.* import patmat.SpaceEngine import util.Spans.* import typer.Applications.* -import SymUtils.* + import Annotations.* import Flags.*, Constants.* import Decorators.* @@ -1022,7 +1022,7 @@ object PatternMatcher { case Block((_: ValDef) :: Block(_, Match(_, cases)) :: Nil, _) => cases case _ => Nil val caseThreshold = - if ValueClasses.isDerivedValueClass(tpt.tpe.typeSymbol) then 1 + if tpt.tpe.typeSymbol.isDerivedValueClass then 1 else MinSwitchCases def typesInPattern(pat: Tree): List[Type] = pat match case Alternative(pats) => pats.flatMap(typesInPattern) diff --git a/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala b/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala index 9e949969dfad..69f64ef4bf57 100644 --- a/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala @@ -11,7 +11,7 @@ import Constants.* import ast.Trees.* import ast.untpd import ast.TreeTypeMap -import SymUtils.* + import NameKinds.* import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.ast.untpd diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 7e37b281b7a0..01c2417b98fe 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -12,7 +12,7 @@ import typer.ErrorReporting.errorTree import Types.*, Contexts.*, Names.*, Flags.*, DenotTransformers.*, Phases.* import SymDenotations.*, StdNames.*, Annotations.*, Trees.*, Scopes.* import Decorators.* -import Symbols.*, SymUtils.*, NameOps.* +import Symbols.*, NameOps.* import ContextFunctionResults.annotateContextResults import config.Printers.typr import config.Feature diff --git a/compiler/src/dotty/tools/dotc/transform/PruneErasedDefs.scala b/compiler/src/dotty/tools/dotc/transform/PruneErasedDefs.scala index f0de71dfc239..9bb30926d45a 100644 --- a/compiler/src/dotty/tools/dotc/transform/PruneErasedDefs.scala +++ b/compiler/src/dotty/tools/dotc/transform/PruneErasedDefs.scala @@ -10,7 +10,7 @@ import Symbols.* import typer.RefChecks import MegaPhase.MiniPhase import ast.tpd -import SymUtils.* + import config.Feature import Decorators.* import dotty.tools.dotc.core.Types.MethodType diff --git a/compiler/src/dotty/tools/dotc/transform/Recheck.scala b/compiler/src/dotty/tools/dotc/transform/Recheck.scala index 503045779dce..9554fa4ffcda 100644 --- a/compiler/src/dotty/tools/dotc/transform/Recheck.scala +++ b/compiler/src/dotty/tools/dotc/transform/Recheck.scala @@ -4,7 +4,7 @@ package transform import core.* import Symbols.*, Contexts.*, Types.*, ContextOps.*, Decorators.*, SymDenotations.* -import Flags.*, SymUtils.*, NameKinds.*, Denotations.{Denotation, SingleDenotation} +import Flags.*, NameKinds.*, Denotations.{Denotation, SingleDenotation} import ast.* import Names.Name import Phases.Phase diff --git a/compiler/src/dotty/tools/dotc/transform/ReifiedReflect.scala b/compiler/src/dotty/tools/dotc/transform/ReifiedReflect.scala index 2fd9f923d98e..90c5ac85167c 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifiedReflect.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifiedReflect.scala @@ -7,7 +7,7 @@ import Flags.* import Types.* import Contexts.* import Symbols.* -import SymUtils.* + import NameKinds.* import dotty.tools.dotc.ast.tpd import tpd.* diff --git a/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala b/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala index e864178af658..dd3f41be5a8e 100644 --- a/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala +++ b/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala @@ -5,7 +5,7 @@ import core.* import MegaPhase.* import Contexts.* import Flags.* -import SymUtils.* + import Symbols.* import Decorators.* import DenotTransformers.* diff --git a/compiler/src/dotty/tools/dotc/transform/SelectStatic.scala b/compiler/src/dotty/tools/dotc/transform/SelectStatic.scala index 6177e5d0839d..6dc718ef526b 100644 --- a/compiler/src/dotty/tools/dotc/transform/SelectStatic.scala +++ b/compiler/src/dotty/tools/dotc/transform/SelectStatic.scala @@ -8,7 +8,7 @@ import dotty.tools.dotc.core.Flags.* import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.core.* import dotty.tools.dotc.transform.MegaPhase.* -import dotty.tools.dotc.transform.SymUtils.* + /** Removes `Select`s that would be compiled into `GetStatic`. * diff --git a/compiler/src/dotty/tools/dotc/transform/Splicing.scala b/compiler/src/dotty/tools/dotc/transform/Splicing.scala index 1c449803c6b4..e9cc877ca770 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicing.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicing.scala @@ -11,7 +11,7 @@ import Constants.* import ast.Trees.* import ast.{TreeTypeMap, untpd} import util.Spans.* -import SymUtils.* + import NameKinds.* import dotty.tools.dotc.ast.tpd diff --git a/compiler/src/dotty/tools/dotc/transform/Staging.scala b/compiler/src/dotty/tools/dotc/transform/Staging.scala index f7fac1981fb2..a48718b2d60a 100644 --- a/compiler/src/dotty/tools/dotc/transform/Staging.scala +++ b/compiler/src/dotty/tools/dotc/transform/Staging.scala @@ -10,7 +10,7 @@ import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.core.Types.* import dotty.tools.dotc.inlines.Inlines import dotty.tools.dotc.util.SrcPos -import dotty.tools.dotc.transform.SymUtils.* + import dotty.tools.dotc.staging.StagingLevel.* import dotty.tools.dotc.staging.CrossStageSafety import dotty.tools.dotc.staging.HealType diff --git a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala index 13ea452bcc9e..ce2b8fa591d8 100644 --- a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala +++ b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala @@ -7,7 +7,7 @@ import scala.collection.mutable import ValueClasses.isMethodWithExtension import core.* import Contexts.*, Flags.*, Symbols.*, Names.*, StdNames.*, NameOps.*, Trees.* -import SymUtils.* + import DenotTransformers.DenotTransformer import Symbols.* import util.Spans.* diff --git a/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala b/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala index b51b04071a83..70f82434a5a6 100644 --- a/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala +++ b/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala @@ -2,7 +2,7 @@ package dotty.tools.dotc package transform import core.* -import Symbols.*, Types.*, Contexts.*, Names.*, StdNames.*, Constants.*, SymUtils.* +import Symbols.*, Types.*, Contexts.*, Names.*, StdNames.*, Constants.* import Flags.* import DenotTransformers.* import Decorators.* @@ -10,8 +10,7 @@ import NameOps.* import Annotations.Annotation import typer.ProtoTypes.constrained import ast.untpd -import ValueClasses.isDerivedValueClass -import SymUtils.* + import util.Property import util.Spans.Span import config.Printers.derive @@ -90,7 +89,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) { def caseAndValueMethods(clazz: ClassSymbol)(using Context): List[Tree] = { val clazzType = clazz.appliedRef lazy val accessors = - if (isDerivedValueClass(clazz)) clazz.paramAccessors.take(1) // Tail parameters can only be `erased` + if clazz.isDerivedValueClass then clazz.paramAccessors.take(1) // Tail parameters can only be `erased` else clazz.caseAccessors val isEnumValue = clazz.isAnonymousClass && clazz.info.parents.head.classSymbol.is(Enum) val isSimpleEnumValue = isEnumValue && !clazz.owner.isAllOf(EnumCase) @@ -98,12 +97,12 @@ class SyntheticMembers(thisPhase: DenotTransformer) { val isNonJavaEnumValue = isEnumValue && !isJavaEnumValue val symbolsToSynthesize: List[Symbol] = - if (clazz.is(Case)) - if (clazz.is(Module)) caseModuleSymbols + if clazz.is(Case) then + if clazz.is(Module) then caseModuleSymbols else caseSymbols - else if (isNonJavaEnumValue) nonJavaEnumValueSymbols - else if (isEnumValue) enumValueSymbols - else if (isDerivedValueClass(clazz)) valueSymbols + else if isNonJavaEnumValue then nonJavaEnumValueSymbols + else if isEnumValue then enumValueSymbols + else if clazz.isDerivedValueClass then valueSymbols else Nil def syntheticDefIfMissing(sym: Symbol): List[Tree] = diff --git a/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala b/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala index f8092ba51c2a..bac731c5f41b 100644 --- a/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala +++ b/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala @@ -9,8 +9,7 @@ import Contexts.*, Symbols.*, Types.*, Constants.*, StdNames.*, Decorators.* import ast.untpd import Erasure.Boxing.* import TypeErasure.* -import ValueClasses.* -import SymUtils.* + import core.Flags.* import util.Spans.* import reporting.* @@ -218,7 +217,7 @@ object TypeTestsCasts { !(!testCls.isPrimitiveValueClass && foundCls.isPrimitiveValueClass) && // foundCls can be `Boolean`, while testCls is `Integer` // it can happen in `(3: Boolean | Int).isInstanceOf[Int]` - !isDerivedValueClass(foundCls) && !isDerivedValueClass(testCls) + !foundCls.isDerivedValueClass && !testCls.isDerivedValueClass // we don't have the logic to handle derived value classes /** Check whether a runtime test that a value of `foundCls` can be a `testCls` diff --git a/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala b/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala index d0c012322fce..5cdd5d8ded43 100644 --- a/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala +++ b/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala @@ -8,19 +8,10 @@ import Contexts.* import Phases.* import Flags.* import StdNames.* -import SymUtils.* /** Methods that apply to user-defined value classes */ object ValueClasses { - def isDerivedValueClass(sym: Symbol)(using Context): Boolean = sym.isClass && { - val d = sym.denot - !d.isRefinementClass && - d.isValueClass && - (d.initial.symbol ne defn.AnyValClass) && // Compare the initial symbol because AnyVal does not exist after erasure - !d.isPrimitiveValueClass - } - def isMethodWithExtension(sym: Symbol)(using Context): Boolean = val d = sym.denot.initial d.validFor.firstPhaseId <= extensionMethodsPhase.id diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 166b5802cbb0..fe16a00d7256 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -17,7 +17,6 @@ import typer.* import Applications.* import Inferencing.* import ProtoTypes.* -import transform.SymUtils.* import reporting.* import config.Printers.{exhaustivity => debug} import util.{SrcPos, NoSourcePosition} diff --git a/compiler/src/dotty/tools/dotc/transform/sjs/ExplicitJSClasses.scala b/compiler/src/dotty/tools/dotc/transform/sjs/ExplicitJSClasses.scala index 5143b415d47b..55953989a027 100644 --- a/compiler/src/dotty/tools/dotc/transform/sjs/ExplicitJSClasses.scala +++ b/compiler/src/dotty/tools/dotc/transform/sjs/ExplicitJSClasses.scala @@ -18,7 +18,7 @@ import core.StdNames.nme import core.SymDenotations.SymDenotation import core.Names.* import core.NameKinds.* -import SymUtils.* + import util.Store diff --git a/compiler/src/dotty/tools/dotc/transform/sjs/JSSymUtils.scala b/compiler/src/dotty/tools/dotc/transform/sjs/JSSymUtils.scala index fafa1eb3cf79..936b6958fb33 100644 --- a/compiler/src/dotty/tools/dotc/transform/sjs/JSSymUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/sjs/JSSymUtils.scala @@ -11,7 +11,7 @@ import Names.* import Phases.* import StdNames.* import Symbols.* -import SymUtils.* + import ast.Trees.* import Types.* diff --git a/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSExports.scala b/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSExports.scala index d7073ac2e261..dbd6e1a8f412 100644 --- a/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSExports.scala +++ b/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSExports.scala @@ -11,7 +11,7 @@ import Flags.* import NameKinds.DefaultGetterName import StdNames.* import Symbols.* -import SymUtils.* + import Types.* import util.Spans.Span diff --git a/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala b/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala index 2da2a98837c7..610fca869ad2 100644 --- a/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala +++ b/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala @@ -18,7 +18,7 @@ import NameKinds.{DefaultGetterName, ModuleClassName} import NameOps.* import StdNames.* import Symbols.* -import SymUtils.* + import Types.* import JSSymUtils.* diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 9e20e925ea36..a987eb8bb76f 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -21,7 +21,6 @@ import NameKinds.DefaultGetterName import ProtoTypes.* import Inferencing.* import reporting.* -import transform.SymUtils.* import Nullables.*, NullOpsDecorator.* import config.Feature diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index ebfc06c15564..7647768a3a34 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -23,8 +23,6 @@ import util.SrcPos import util.Spans.Span import rewrites.Rewrites.patch import inlines.Inlines -import transform.SymUtils.* -import transform.ValueClasses.* import Decorators.* import ErrorReporting.{err, errorType} import config.Printers.{typr, patmatch} @@ -34,6 +32,7 @@ import SymDenotations.{NoCompleter, NoDenotation} import Applications.unapplyArgs import Inferencing.isFullyDefined import transform.patmat.SpaceEngine.{isIrrefutable, isIrrefutableQuotedPattern} +import transform.ValueClasses.underlyingOfValueClass import config.Feature import config.Feature.sourceVersion import config.SourceVersion.* @@ -697,7 +696,7 @@ object Checking { case _ => report.error(ValueClassesMayNotContainInitalization(clazz), stat.srcPos) } - if (isDerivedValueClass(clazz)) { + if (clazz.isDerivedValueClass) { if (clazz.is(Trait)) report.error(CannotExtendAnyVal(clazz), clazz.srcPos) if clazz.is(Module) then diff --git a/compiler/src/dotty/tools/dotc/typer/CrossVersionChecks.scala b/compiler/src/dotty/tools/dotc/typer/CrossVersionChecks.scala index 4087c5faf404..91303b00618c 100644 --- a/compiler/src/dotty/tools/dotc/typer/CrossVersionChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/CrossVersionChecks.scala @@ -3,7 +3,7 @@ package dotc package transform import core.* -import Symbols.*, Types.*, Contexts.*, Flags.*, SymUtils.*, Decorators.*, reporting.* +import Symbols.*, Types.*, Contexts.*, Flags.*, Decorators.*, reporting.* import util.SrcPos import config.{ScalaVersion, NoScalaVersion, Feature, ScalaRelease} import MegaPhase.MiniPhase diff --git a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala index c9013f0bc208..db87ece77eb7 100644 --- a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala +++ b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala @@ -14,8 +14,8 @@ import dotty.tools.dotc.core.Decorators.* import dotty.tools.dotc.core.TypeErasure import util.Spans.* import core.Symbols.* +import transform.ValueClasses import ErrorReporting.* -import dotty.tools.dotc.transform.ValueClasses import reporting.* object Dynamic { @@ -231,7 +231,7 @@ trait Dynamic { */ def maybeBoxingCast(tpe: Type) = val maybeBoxed = - if ValueClasses.isDerivedValueClass(tpe.classSymbol) && qual.tpe <:< defn.ReflectSelectableTypeRef then + if tpe.classSymbol.isDerivedValueClass && qual.tpe <:< defn.ReflectSelectableTypeRef then val genericUnderlying = ValueClasses.valueClassUnbox(tpe.classSymbol.asClass) val underlying = tpe.select(genericUnderlying).widen.resultType New(tpe.widen, tree.cast(underlying) :: Nil) diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index cb489d94ca27..c709464510a9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -23,7 +23,6 @@ import parsing.Parsers.Parser import Annotations.* import Inferencing.* import transform.ValueClasses.* -import transform.SymUtils.* import TypeErasure.erasure import reporting.* import config.Feature.sourceVersion diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index a6742c278d78..ad6c9c2e791d 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -16,7 +16,7 @@ import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.core.Types.* import dotty.tools.dotc.inlines.PrepareInlineable import dotty.tools.dotc.staging.StagingLevel.* -import dotty.tools.dotc.transform.SymUtils.* + import dotty.tools.dotc.typer.ErrorReporting.errorTree import dotty.tools.dotc.typer.Implicits.* import dotty.tools.dotc.typer.Inferencing.* diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index 53ceae7500d8..b42fb7f8d218 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -5,7 +5,7 @@ package typer import transform.* import core.* import Symbols.*, Types.*, Contexts.*, Flags.*, Names.*, NameOps.*, NameKinds.* -import StdNames.*, Denotations.*, SymUtils.*, Phases.*, SymDenotations.* +import StdNames.*, Denotations.*, Phases.*, SymDenotations.* import NameKinds.DefaultGetterName import util.Spans.* import scala.collection.mutable diff --git a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala index 95bdbcaa1c06..e499f362f0ba 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -11,7 +11,6 @@ import Decorators.* import ProtoTypes.* import Inferencing.{fullyDefinedType, isFullyDefined} import ast.untpd -import transform.SymUtils.* import transform.SyntheticMembers.* import util.Property import ast.Trees.genericEmptyTree diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 8e7801b308c0..8c7add6eba37 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -45,7 +45,6 @@ import config.Feature.{sourceVersion, migrateTo3} import config.SourceVersion.* import rewrites.Rewrites.patch import staging.StagingLevel -import transform.SymUtils.* import reporting.* import Nullables.* import NullOpsDecorator.* diff --git a/compiler/src/dotty/tools/dotc/util/Signatures.scala b/compiler/src/dotty/tools/dotc/util/Signatures.scala index c3779d3473cf..b0583f9dfd0a 100644 --- a/compiler/src/dotty/tools/dotc/util/Signatures.scala +++ b/compiler/src/dotty/tools/dotc/util/Signatures.scala @@ -11,9 +11,8 @@ import core.NameOps.isUnapplyName import core.Names.* import core.NameKinds import core.Types.* -import core.Symbols.NoSymbol +import core.Symbols.{NoSymbol, isLocalToBlock} import interactive.Interactive -import transform.SymUtils.isLocalToBlock import util.Spans.Span import reporting.* diff --git a/compiler/src/dotty/tools/repl/Rendering.scala b/compiler/src/dotty/tools/repl/Rendering.scala index a4ef89acb168..b581e82739e1 100644 --- a/compiler/src/dotty/tools/repl/Rendering.scala +++ b/compiler/src/dotty/tools/repl/Rendering.scala @@ -7,7 +7,6 @@ import dotc.*, core.* import Contexts.*, Denotations.*, Flags.*, NameOps.*, StdNames.*, Symbols.* import printing.ReplPrinter import reporting.Diagnostic -import transform.ValueClasses import util.StackTraceOps.* import scala.util.control.NonFatal @@ -126,7 +125,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None): * @param value underlying value */ private def rewrapValueClass(sym: Symbol, value: Object)(using Context): Option[Object] = - if ValueClasses.isDerivedValueClass(sym) then + if sym.isDerivedValueClass then val valueClass = Class.forName(sym.binaryClassName, true, classLoader()) valueClass.getConstructors.headOption.map(_.newInstance(value)) else diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala index 6011a1a3d660..35fc276d26cb 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala @@ -7,7 +7,6 @@ import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Flags.* import dotty.tools.dotc.core.Symbols.Symbol import dotty.tools.dotc.core.Types.Type -import dotty.tools.dotc.transform.SymUtils.* import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.utils.MtagsEnrichments.decoded diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala index 557d1762720b..862b0425ef6a 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala @@ -26,7 +26,6 @@ import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.core.Types.* import dotty.tools.dotc.interactive.Completion import dotty.tools.dotc.interactive.Completion.Mode -import dotty.tools.dotc.transform.SymUtils.* import dotty.tools.dotc.util.SourcePosition import dotty.tools.dotc.util.Spans import dotty.tools.dotc.util.Spans.Span diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/KeywordsCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/KeywordsCompletions.scala index 9f1a5a0e9bff..5fa667568cf5 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/KeywordsCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/KeywordsCompletions.scala @@ -11,7 +11,6 @@ import dotty.tools.dotc.ast.untpd.UntypedTreeTraverser import dotty.tools.dotc.core.Comments import dotty.tools.dotc.core.Comments.Comment import dotty.tools.dotc.core.Contexts.Context -import dotty.tools.dotc.transform.SymUtils._ import dotty.tools.dotc.util.SourcePosition import dotty.tools.dotc.util.Spans.Span