question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regression: Ambiguous implicits should error

See original GitHub issue

Compiler version

  • 3.0.0-RC1
  • 3.0.1-RC1-bin-20210412-69108bf-NIGHTLY

Minimized code

class Singleton[A]

object Singleton {

  implicit val Unit: Singleton[Unit] =
    new Singleton

  sealed trait Not[A]
  implicit def noSingletonFor[A]: Not[A] = null
  implicit def singletonFor1[A: Singleton]: Not[A] = null
  implicit def singletonFor2[A: Singleton]: Not[A] = null

  implicitly[Singleton    [Unit]] // ok
  implicitly[Singleton.Not[Unit]] // error expected
  implicitly[Singleton.Not[Int ]] // ok
}

Output

It all compiles.

Expectation

The same error as Scala 2:

x.scala:14: error: ambiguous implicit values:
 both method noSingletonFor in object Singleton of type [A]Singleton.Not[A]
 and method singletonFor1 in object Singleton of type [A](implicit evidence$1: Singleton[A]): Singleton.Not[A]
 match expected type Singleton.Not[Unit]
  implicitly[Singleton.Not[Unit]] // error expected
            ^
1 error

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
joroKr21commented, Apr 19, 2021

You can try adding a DummyImplicit to settle the score

Read more comments on GitHub >

github_iconTop Results From Across the Web

why do I get an "ambiguous implicits" error despite having ...
I import instances._ ; instances extends ExternalInstances1 , and ExternalInstances1 extends ExternalInstances0 . Because of this inheritance I ...
Read more >
"Ambiguous implicit values" error caused by a mix of -Xsource ...
"Ambiguous implicit values" error caused by a mix of -Xsource:3 , an explicit (not wildcard) import and a evicted/transitive(?) dependency # ...
Read more >
Type Class - Ambiguous Implicit Values Error - Scala Users
I'm doing one of the exercises and trying to write a Type Class that “should compare two values of type A and return...
Read more >
Reacting to ambiguous messages: An experimental analysis
1. Introduction. Individuals often make use of ambiguous formulations. Such ambiguity often appears deliberate as it could easily be avoided.
Read more >
32526 – [4.3 regression] Spurious error: Name 'x' at (1) is an ...
When I compile the modules listed below I get the following error message: e.f90:51.30: use poly_Personnel_class 1 Error: Name 'new' at (1) is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found