Skip to content

Commit f6112f5

Browse files
authored
Merge pull request #11203 from dotty-staging/fix-11168
Handle adaptation of a method with implicit followed by type parameter
2 parents b7eae6a + c1163be commit f6112f5

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3697,7 +3697,7 @@ class Typer extends Namer
36973697
case pt: FunProto =>
36983698
if tree.symbol.isAllOf(ApplyProxyFlags) then newExpr
36993699
else adaptToArgs(wtp, pt)
3700-
case pt: PolyProto =>
3700+
case pt: PolyProto if !wtp.isImplicitMethod =>
37013701
tryInsertApplyOrImplicit(tree, pt, locked)(tree) // error will be reported in typedTypeApply
37023702
case _ =>
37033703
if (ctx.mode is Mode.Type) adaptType(tree.tpe)

tests/pos/i11168.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
trait Foo
2+
given foo: Foo with {}
3+
4+
extension (using Foo)(x: Any)
5+
def foo1[A] = ???
6+
7+
extension (x: Any)(using Foo)
8+
def foo2[A] = ???
9+
10+
implicit class LeadingFooOps(using Foo)(x: Any) {
11+
def foo3[A] = ???
12+
}
13+
14+
implicit class TrailingFooOps(x: Any)(using Foo) {
15+
def foo4[A] = ???
16+
}
17+
18+
def a1 = "".foo1[Any]
19+
def a2: Any = "".foo2[Any]
20+
def a3 = "".foo3[Any]
21+
def a4 = "".foo4[Any]
22+
23+
def b2 = "".foo2(using foo)[Any]
24+
25+
def c1 = foo1("")[Any]
26+
def c2 = foo2("")[Any]
27+
28+
def d1 = foo1(using foo)("")[Any]
29+
def d2 = foo2("")(using foo)[Any]

0 commit comments

Comments
 (0)