Skip to content

Ambiguous implicits due to export #12591

Closed
@soronpo

Description

@soronpo

AFAIK, this bug only appears across packages. Export to an outer package that reflects into an inner package causes implicit ambiguity.

Compiler version

v3.0.0

Minimized code

Complete minimized project at:
https://github.com/soronpo/dottybug/tree/export_ambiguous_implicits
Outer.scala

package outer
export inner.Foo
export Foo.Bar

Inner.scala

package outer
package inner

sealed trait Foo
object Foo:
  trait TC[T]
  given ofFoo[T <: Foo]: TC[T] = ???
  trait Bar extends Foo

import Foo.TC
//Adding import Foo.Bar resolves the issue
val badSummon = summon[TC[Bar]] //error here

Output

[error] 13 |val badSummon = summon[TC[Bar]]                                                                                                                                                                                                    
[error]    |                               ^                                                                                                                                                                                                   
[error]    |                               ambiguous implicit arguments: both given instance ofFoo in object Foo and given instance ofFoo in object Foo match type outer.inner.Foo.TC[outer.Bar] of parameter x of method summon in object Predef  

Expectation

No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions