Skip to content

Commit de42a98

Browse files
authored
Merge pull request #14148 from dotty-staging/fix-derivedPolyProto
Fix `derivedPolyProto` to use the correct result type
2 parents 0b55c7d + 209b18e commit de42a98

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ object ProtoTypes {
582582
override def isMatchedBy(tp: Type, keepConstraint: Boolean)(using Context): Boolean =
583583
canInstantiate(tp) || tp.member(nme.apply).hasAltWith(d => canInstantiate(d.info))
584584

585-
def derivedPolyProto(targs: List[Tree], resultType: Type): PolyProto =
585+
def derivedPolyProto(targs: List[Tree], resType: Type): PolyProto =
586586
if ((targs eq this.targs) && (resType eq this.resType)) this
587587
else PolyProto(targs, resType)
588588

tests/neg/i14145.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
val l: List[Option[Int]] = List(None, Some(1), None)
2+
3+
@main def m15 =
4+
l.collectFirst(Some.unapply.unlift[Option[Int], Int]) // error

0 commit comments

Comments
 (0)