@@ -162,13 +162,15 @@ object ProtoTypes {
162162 override def viewExists (tp : Type , pt : Type )(using Context ): Boolean = false
163163 }
164164
165- /** A trait for prototypes that match all types */
166- trait MatchAlways extends ProtoType {
167- def isMatchedBy (tp1 : Type , keepConstraint : Boolean )(using Context ): Boolean = true
165+ /** A trait for prototypes that map to themselves */
166+ trait FixedProto extends ProtoType :
168167 def map (tm : TypeMap )(using Context ): ProtoType = this
169168 def fold [T ](x : T , ta : TypeAccumulator [T ])(using Context ): T = x
170169 override def toString : String = getClass.toString
171- }
170+
171+ /** A trait for prototypes that match all types */
172+ trait MatchAlways extends FixedProto :
173+ def isMatchedBy (tp1 : Type , keepConstraint : Boolean )(using Context ): Boolean = true
172174
173175 /** A class marking ignored prototypes that can be revealed by `deepenProto` */
174176 abstract case class IgnoredProto (ignored : Type ) extends CachedGroundType with MatchAlways :
@@ -179,6 +181,19 @@ object ProtoTypes {
179181 ignored
180182 override def deepenProtoTrans (using Context ): Type = ignored.deepenProtoTrans
181183
184+ override def isMatchedBy (tp1 : Type , keepConstraint : Boolean )(using Context ): Boolean =
185+ ignored match
186+ case ignored : SelectionProto if ignored.name != nme.apply =>
187+ // Non-implicit methods don't match ignored selection protos unless the
188+ // selection is via `apply`. This is because a match of a different selection
189+ // would require an eta expansion _and_ and an implicit conversion, which is
190+ // not allowed. So the prototype would not match even if implicit conversions
191+ // were present. Test case: i23773a.scala
192+ tp1.widen match
193+ case tp1w : MethodOrPoly => tp1w.isImplicitMethod
194+ case _ => true
195+ case _ => true
196+
182197 /** Did someone look inside via deepenProto? Used for error deagniostics
183198 * to give a more extensive expected type.
184199 */
0 commit comments