Skip to content

Handle adaptation of a method with implicit followed by type parameter #11203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3697,7 +3697,7 @@ class Typer extends Namer
case pt: FunProto =>
if tree.symbol.isAllOf(ApplyProxyFlags) then newExpr
else adaptToArgs(wtp, pt)
case pt: PolyProto =>
case pt: PolyProto if !wtp.isImplicitMethod =>
tryInsertApplyOrImplicit(tree, pt, locked)(tree) // error will be reported in typedTypeApply
case _ =>
if (ctx.mode is Mode.Type) adaptType(tree.tpe)
Expand Down
29 changes: 29 additions & 0 deletions tests/pos/i11168.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
trait Foo
given foo: Foo with {}

extension (using Foo)(x: Any)
def foo1[A] = ???

extension (x: Any)(using Foo)
def foo2[A] = ???

implicit class LeadingFooOps(using Foo)(x: Any) {
def foo3[A] = ???
}

implicit class TrailingFooOps(x: Any)(using Foo) {
def foo4[A] = ???
}

def a1 = "".foo1[Any]
def a2: Any = "".foo2[Any]
def a3 = "".foo3[Any]
def a4 = "".foo4[Any]

def b2 = "".foo2(using foo)[Any]

def c1 = foo1("")[Any]
def c2 = foo2("")[Any]

def d1 = foo1(using foo)("")[Any]
def d2 = foo2("")(using foo)[Any]