Regression: Ambiguous implicits should error
See original GitHub issueCompiler 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:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can still cross-compile by defining a NotGiven for Scala 2: https://github.com/typelevel/fs2/blob/main/core/shared/src/main/scala-2/fs2/compat/NotGiven.scala https://github.com/typelevel/fs2/blob/main/core/shared/src/main/scala-3/fs2/compat/NotGiven.scala (something that could be added to https://github.com/scala/scala-collection-compat perhaps?)
You can try adding a
DummyImplicit
to settle the score