Skip to content

Ambiguous implicit arguments when referencing an object via a val #9103

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

Minimized code

object a:
  type Foo[T]
  given as Foo[Unit] = ???

val b = a

def Test = summon[b.Foo[Unit]]

Output

-- Error: /Users/kmetiuk/Projects/scala3/playground/ambiguous/Test.scala:7:30 --
7 |def Test = summon[b.Foo[Unit]]
  |                              ^
  |ambiguous implicit arguments: both method given_Foo_Unit in object a and method given_Foo_Unit in object a match type b.Foo[Unit] of parameter x of method summon in object DottyPredef
1 error found

Expectation

Should compile. The following examples all compile successfully:

object a:
  type Foo[T]
  given as Foo[Unit] = ???

def Test = summon[a.Foo[Unit]]
object a:
  type Foo
  given as Foo = ???

val b = a

def Test = summon[b.Foo]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions