@@ -96,6 +96,15 @@ object Inliner:
96
96
}
97
97
end isElideableExpr
98
98
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
+
99
108
// InlinerMap is a TreeTypeMap with special treatment for inlined arguments:
100
109
// They are generally left alone (not mapped further, and if they wrap a type
101
110
// the type Inlined wrapper gets dropped.
@@ -108,13 +117,7 @@ object Inliner:
108
117
substFrom : List [Symbol ],
109
118
substTo : List [Symbol ])(using Context )
110
119
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 ()):
118
121
119
122
override def transform (tree : Tree )(using Context ): Tree =
120
123
tree match
0 commit comments