Skip to content

Commit 6003950

Browse files
Fix #8188: For the purposes of overloading, contextual methods aren't methodic
1 parent 750ce40 commit 6003950

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,10 @@ trait Applications extends Compatibility {
17831783
}
17841784

17851785
def resultIsMethod(tp: Type): Boolean = tp.widen.stripPoly match
1786-
case tp: MethodType => tp.resultType.isInstanceOf[MethodType]
1786+
case tp: MethodType =>
1787+
tp.resultType match
1788+
case mt: MethodType => !mt.isContextualMethod
1789+
case _ => false
17871790
case _ => false
17881791

17891792
val found = narrowMostSpecific(candidates)

tests/pos/i8188.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Test {
2+
extension StrDeco on (tree: String) {
3+
def show(given DummyImplicit): String = ???
4+
def show(color: Boolean)(given DummyImplicit): String = ???
5+
}
6+
7+
val a: String = "foo".show
8+
val b: String = "foo".show(true)
9+
val c: Any = "foo".show
10+
val d: Any = "foo".show(true)
11+
}

0 commit comments

Comments
 (0)