Skip to content

Commit 209b18e

Browse files
committed
Fix derivedPolyProto to use the correct result type
The method parameter was called `resultType` but inside the method we use `resType` which is the result type of the existing PolyProto instance, so TypeMaps never updated the result type of a PolyProto before. According to git blame, this typo was introduced when the class parameter was renamed back in 2015 in b5c3a28.
1 parent 0f6df73 commit 209b18e

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)