diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 800af19e9f78..76fcb77d8c30 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -582,7 +582,7 @@ object ProtoTypes { override def isMatchedBy(tp: Type, keepConstraint: Boolean)(using Context): Boolean = canInstantiate(tp) || tp.member(nme.apply).hasAltWith(d => canInstantiate(d.info)) - def derivedPolyProto(targs: List[Tree], resultType: Type): PolyProto = + def derivedPolyProto(targs: List[Tree], resType: Type): PolyProto = if ((targs eq this.targs) && (resType eq this.resType)) this else PolyProto(targs, resType) diff --git a/tests/neg/i14145.scala b/tests/neg/i14145.scala new file mode 100644 index 000000000000..e9619ae9d756 --- /dev/null +++ b/tests/neg/i14145.scala @@ -0,0 +1,4 @@ +val l: List[Option[Int]] = List(None, Some(1), None) + +@main def m15 = + l.collectFirst(Some.unapply.unlift[Option[Int], Int]) // error