Skip to content

Commit e01af07

Browse files
committed
Revert "Rename InlineCopier to ConservativeTreeCopier, use it in TypeMaps"
This reverts commit bb63e31.
1 parent 4b09b13 commit e01af07

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

-8
Original file line numberDiff line numberDiff line change
@@ -842,14 +842,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
842842
Closure(tree: Tree)(env, meth, tpt)
843843
}
844844

845-
// This is a more fault-tolerant copier that does not cause errors when
846-
// function types in applications are undefined.
847-
// This was called `Inliner.InlineCopier` before 3.6.3.
848-
class ConservativeTreeCopier() extends TypedTreeCopier:
849-
override def Apply(tree: Tree)(fun: Tree, args: List[Tree])(using Context): Apply =
850-
if fun.tpe.widen.exists then super.Apply(tree)(fun, args)
851-
else untpd.cpy.Apply(tree)(fun, args).withTypeUnchecked(tree.tpe)
852-
853845
override def skipTransform(tree: Tree)(using Context): Boolean = tree.tpe.isError
854846

855847
implicit class TreeOps[ThisTree <: tpd.Tree](private val tree: ThisTree) extends AnyVal {

compiler/src/dotty/tools/dotc/core/Types.scala

+1-8
Original file line numberDiff line numberDiff line change
@@ -6310,14 +6310,7 @@ object Types extends TypeUtils {
63106310
}
63116311
}
63126312

6313-
private def treeTypeMap = new TreeTypeMap(
6314-
typeMap = this,
6315-
// Using `ConservativeTreeCopier` is needed when copying dependent annoted
6316-
// types, where we can refer to a previous parameter represented as
6317-
// `TermParamRef` that has no underlying type yet.
6318-
// See tests/pos/annot-17242.scala.
6319-
cpy = ConservativeTreeCopier()
6320-
)
6313+
private def treeTypeMap = new TreeTypeMap(typeMap = this)
63216314

63226315
def mapOver(syms: List[Symbol]): List[Symbol] = mapSymbols(syms, treeTypeMap)
63236316

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

+10-7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ object Inliner:
9696
}
9797
end isElideableExpr
9898

99+
// InlineCopier is a more fault-tolerant copier that does not cause errors when
100+
// function types in applications are undefined. This is necessary since we copy at
101+
// the same time as establishing the proper context in which the copied tree should
102+
// be evaluated. This matters for opaque types, see neg/i14653.scala.
103+
private class InlineCopier() extends TypedTreeCopier:
104+
override def Apply(tree: Tree)(fun: Tree, args: List[Tree])(using Context): Apply =
105+
if fun.tpe.widen.exists then super.Apply(tree)(fun, args)
106+
else untpd.cpy.Apply(tree)(fun, args).withTypeUnchecked(tree.tpe)
107+
99108
// InlinerMap is a TreeTypeMap with special treatment for inlined arguments:
100109
// They are generally left alone (not mapped further, and if they wrap a type
101110
// the type Inlined wrapper gets dropped.
@@ -108,13 +117,7 @@ object Inliner:
108117
substFrom: List[Symbol],
109118
substTo: List[Symbol])(using Context)
110119
extends TreeTypeMap(
111-
typeMap, treeMap, oldOwners, newOwners, substFrom, substTo,
112-
// It is necessary to use the `ConservativeTreeCopier` since we copy at
113-
// the same time as establishing the proper context in which the copied
114-
// tree should be evaluated. This matters for opaque types, see
115-
// neg/i14653.scala.
116-
ConservativeTreeCopier()
117-
):
120+
typeMap, treeMap, oldOwners, newOwners, substFrom, substTo, InlineCopier()):
118121

119122
override def transform(tree: Tree)(using Context): Tree =
120123
tree match

0 commit comments

Comments
 (0)