Skip to content

Commit 0d9f9a7

Browse files
committed
Don't handle Function types separately when filtering overloaded methods
Along with fixing the regression, this also improves other cases, one of which was added to the test.
1 parent 94e4df9 commit 0d9f9a7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ class Definitions {
11181118
case ErasedFunctionOf(mt) =>
11191119
Some(mt.paramInfos, mt.resType, mt.isContextualMethod)
11201120
case _ =>
1121-
val tsym = ft.typeSymbol
1121+
val tsym = ft.dealias.typeSymbol
11221122
if isFunctionSymbol(tsym) && ft.isRef(tsym) then
11231123
val targs = ft.dealias.argInfos
11241124
if (targs.isEmpty) None

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,9 +2059,6 @@ trait Applications extends Compatibility {
20592059
if isDetermined(alts2) then alts2
20602060
else resolveMapped(alts1, _.widen.appliedTo(targs1.tpes), pt1)
20612061

2062-
case defn.FunctionOf(args, resultType, _) =>
2063-
narrowByTypes(alts, args, resultType)
2064-
20652062
case pt =>
20662063
val compat = alts.filterConserve(normalizedCompatible(_, pt, keepConstraint = false))
20672064
if (compat.isEmpty)

tests/pos/i17245.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ type OnChannel = Channel => Any
1515
val case2: OnChannel = Mockito.mock
1616
val case3 = Mockito.mock[OnChannel]
1717
val case4: OnChannel = Mockito.mock[OnChannel](summon[ClassTag[OnChannel]])
18+
19+
// not a regressive case, but an added improvement with the fix for the above
20+
val case5: Channel => Any = Mockito.mock[Channel => Any]

0 commit comments

Comments
 (0)