Skip to content

Commit

Permalink
Merge pull request #14148 from dotty-staging/fix-derivedPolyProto
Browse files Browse the repository at this point in the history
Fix `derivedPolyProto` to use the correct result type
  • Loading branch information
odersky authored Dec 21, 2021
2 parents 0b55c7d + 209b18e commit de42a98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i14145.scala
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit de42a98

Please sign in to comment.