Skip to content

Commit

Permalink
Refactor TypeUtils
Browse files Browse the repository at this point in the history
 = 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.
  • Loading branch information
odersky committed Nov 23, 2023
1 parent 366f06a commit 6793291
Show file tree
Hide file tree
Showing 29 changed files with 5 additions and 33 deletions.
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Flags.*
import config.Config
import config.Printers.typr
import typer.ProtoTypes.{newTypeVar, representedParamRef}
import transform.TypeUtils.isTransparent
import UnificationDirection.*
import NameKinds.AvoidNameKind
import util.SimpleIdentitySet
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import scala.util.control.NonFatal
import config.Config
import reporting.*
import collection.mutable
import transform.TypeUtils.*
import cc.{CapturingType, derivedCapturingType}

import scala.annotation.internal.sharable
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Names.*
import StdNames.nme
import Flags.{Module, Provisional}
import dotty.tools.dotc.config.Config
import dotty.tools.dotc.transform.TypeUtils.isErasedValueType

object TypeApplications {

Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package dotty.tools
package dotc
package transform
package core

import core.*
import TypeErasure.ErasedValueType
import Types.*, Contexts.*, Symbols.*, Flags.*, Decorators.*
import Names.Name

object TypeUtils {
class TypeUtils {
/** A decorator that provides methods on types
* that are needed in the transformer pipeline.
*/
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Flags.*
import Names.*
import NameOps.*
import Decorators.*
import TypeUtils.*
import Types.*
import util.Spans.Span
import config.Printers.transforms
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import DenotTransformers.*
import NameOps.*
import NameKinds.OuterSelectName
import StdNames.*
import TypeUtils.isErasedValueType
import config.Feature
import inlines.Inlines.inInlineMethod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Types.*
import Contexts.*
import Symbols.*
import Decorators.*
import TypeUtils.*
import StdNames.nme
import ast.*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import patmat.SpaceEngine
import util.Spans.*
import typer.Applications.*
import SymUtils.*
import TypeUtils.*
import Annotations.*
import Flags.*, Constants.*
import Decorators.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package patmat

import core.*
import Types.*
import TypeUtils.*
import Contexts.*
import Flags.*
import ast.*
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import config.Feature
import config.Feature.sourceVersion
import config.SourceVersion.*
import printing.Formatting.hlAsKeyword
import transform.TypeUtils.*
import cc.isCaptureChecking

import collection.mutable
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/ConstFold.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Constants.*
import Names.*
import StdNames.*
import Contexts.*
import transform.TypeUtils.*

object ConstFold:

Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Dynamic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import util.Spans.*
import core.Symbols.*
import ErrorReporting.*
import dotty.tools.dotc.transform.ValueClasses
import dotty.tools.dotc.transform.TypeUtils.isPrimitiveValueType
import reporting.*
import inlines.Inlines

Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import ErrorReporting.*
import Inferencing.{fullyDefinedType, isFullyDefined}
import Scopes.newScope
import Typer.BindingPrec, BindingPrec.*
import transform.TypeUtils.*
import Hashable.*
import util.{EqHashMap, Stats}
import config.{Config, Feature}
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Inferencing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import ProtoTypes.*
import NameKinds.UniqueName
import util.Spans.*
import util.{Stats, SimpleIdentityMap, SimpleIdentitySet, SrcPos}
import transform.TypeUtils.isTransparent
import Decorators._
import config.Printers.{gadts, typr}
import annotation.tailrec
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Synthesizer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down

0 comments on commit 6793291

Please sign in to comment.