-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #5773: Apply more context info to avoid ambiguous implicits #5836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f0c1894
Take implicit methods into account when computing candidates for exte…
odersky f5b6463
Pick most significant error in implicit search
odersky 03e0900
Report failed extension method constructions as addendums to error me…
odersky 6d50a34
Keep constraints for subtype tests with ProtoTypes
odersky 8e22afd
Don't cache unforced typedArgs
odersky 6800e09
Drop all IgnoredProto parts before implicit search
odersky 7d7e35e
Recursively drop IgnoredProto parts
odersky e7086ef
Fix test
odersky 30396ea
Go back to only revealing one level of IgnoredProto
odersky 4d85a7d
Deepen prototype on AmbiguousImplicits
odersky 73c155a
Another test
odersky fb58de1
Add comments
odersky 75178c4
Update compiler/src/dotty/tools/dotc/typer/Typer.scala
smarter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,32 @@ | ||
trait Semigroup[T] { | ||
def (lhs: T) append (rhs: T): T | ||
} | ||
|
||
object Semigroup { | ||
implicit object stringAppend extends Semigroup[String] { | ||
override def (lhs: String) append (rhs: String): String = lhs + rhs | ||
} | ||
|
||
implicit def sumSemigroup[N](implicit N: Numeric[N]): Semigroup[N] = new { | ||
override def (lhs: N) append (rhs: N): N = ??? // N.plus(lhs, rhs) | ||
} | ||
|
||
implicit class SumSemigroupDeco[N](implicit N: Numeric[N]) extends Semigroup[N] { | ||
override def (lhs: N) append (rhs: N): N = ??? // N.plus(lhs, rhs) | ||
} | ||
} | ||
|
||
|
||
object Main { | ||
import Semigroup.sumSemigroup // this is not sufficient | ||
def f1 = { | ||
import Semigroup.stringAppend // necessary to make the extension method visible | ||
println("Hi" append " mum") // ok | ||
println(1 append 2) // error: this won't compile | ||
} | ||
|
||
def f2 = { | ||
implicit val intSumAppend: Semigroup[Int] = sumSemigroup[Int] | ||
println(3 append 4) // this will | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.