Skip to content

Ambiguous overloads with type parameter and implicit conversion. #1381

Closed
@nicolasstucki

Description

@nicolasstucki
dotty> object Foo {
         class Bar[T]
         implicit def const[T](x: T): Bar[T] = ???

         def bar[T](e: T): Any = ???
         def bar[T](e: Bar[T]): Any = ???

         val b: Bar[Int] = ???
         bar(b)
       } 
  ^
  bar(bar)
<console>:13: error: Ambiguous overload. The overloaded alternatives of method bar in object Foo$ with types
 [T](e: Foo.Bar[T])Any
 [T](e: T)Any
both match arguments (Foo.Bar[Int](Foo.bar))
scala> object Foo {
     |   class Bar[T]
     |   implicit def const[T](x: T): Bar[T] = ???
     | 
     |   def bar[T](e: T): Any = ???
     |   def bar[T](e: Bar[T]): Any = ???
     | 
     |   val b: Bar[Int] = ???
     |   bar(b)
     | }
defined object Foo

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions