@@ -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