forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix how implicit candidates are combined (scala#18321)
- Loading branch information
Showing
4 changed files
with
60 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import scala.language.implicitConversions | ||
object squerel { | ||
trait EqualityExpression | ||
object PrimitiveTypeMode: | ||
implicit def intToTE(f: Int): TypedExpression[Int] = ??? | ||
|
||
trait TypedExpression[A1]: | ||
def ===[A2](b: TypedExpression[A2]): EqualityExpression = ??? | ||
} | ||
|
||
object scalactic { | ||
trait TripleEqualsSupport: | ||
class Equalizer[L](val leftSide: L): | ||
def ===(rightSide: Any): Boolean = ??? | ||
|
||
trait TripleEquals extends TripleEqualsSupport: | ||
implicit def convertToEqualizer[T](left: T): Equalizer[T] = ??? | ||
} | ||
|
||
import squerel.PrimitiveTypeMode._ // remove to make code compile | ||
object Test extends scalactic.TripleEquals { | ||
import squerel.PrimitiveTypeMode._ | ||
val fails: squerel.EqualityExpression = 1 === 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class R1 | ||
class R2 | ||
|
||
class Foo { def meth(x: Int): R1 = null } | ||
class Bar { def meth(x: Int): R2 = null } | ||
|
||
object Impl { implicit def mkFoo(i: Int): Foo = null } | ||
trait Trait { implicit def mkBar(i: Int): Bar = null } | ||
|
||
import Impl.mkFoo // remove to make code compile | ||
object Test extends Trait: | ||
import Impl.mkFoo | ||
val fails: R1 = 1.meth(1) |