-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Instantiate argument type vars before implicit search #19096
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
67ae357
Instantiate type vars which occur in arguments applications
EugeneFlesselle 1df7d83
Add test from i7586
EugeneFlesselle 700fa5e
Fix libretto community-project
EugeneFlesselle a77a69a
mend
EugeneFlesselle 5e8f8f6
Community-build update
EugeneFlesselle 21520f4
update doc
EugeneFlesselle 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
trait Animal | ||
class Dog extends Animal | ||
|
||
trait Ev[T] | ||
|
||
given Ev[Dog] = ??? | ||
given Ev[Animal] = ??? | ||
given[T: Ev]: Ev[Set[T]] = ??? | ||
|
||
def f[T: Ev](v: T): Unit = ??? | ||
|
||
def main = | ||
val s = Set(new Dog) | ||
f(s) // Ok | ||
f(Set(new Dog)) // Error before changes: Ambiguous given instances: both given instance given_Ev_Dog and given instance given_Ev_Animal match type Ev[T] | ||
|
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,38 @@ | ||
|
||
trait Nat | ||
case object Z extends Nat | ||
case class S[N <: Nat](pred: N) extends Nat | ||
|
||
type Z = Z.type | ||
given zero: Z = Z | ||
given succ[N <: Nat](using n: N): S[N] = S(n) | ||
|
||
case class Sum[N <: Nat, M <: Nat, R <: Nat](result: R) | ||
|
||
given sumZ[N <: Nat](using n: N): Sum[Z, N, N] = Sum(n) | ||
given sumS[N <: Nat, M <: Nat, R <: Nat]( | ||
using sum: Sum[N, M, R] | ||
): Sum[S[N], M, S[R]] = Sum(S(sum.result)) | ||
|
||
def add[N <: Nat, M <: Nat, R <: Nat](n: N, m: M)( | ||
using sum: Sum[N, M, R] | ||
): R = sum.result | ||
|
||
case class Prod[N <: Nat, M <: Nat, R <: Nat](result: R) | ||
|
||
|
||
@main def Test: Unit = | ||
|
||
val n1: S[Z] = add(Z, S(Z)) | ||
summon[n1.type <:< S[Z]] // OK | ||
|
||
val n3: S[S[S[Z]]] = add(S(S(Z)), S(Z)) | ||
summon[n3.type <:< S[S[S[Z]]]] // Ok | ||
|
||
val m3_2 = add(S(Z), S(S(Z))) | ||
summon[m3_2.type <:< S[S[S[Z]]]] // Error before changes: Cannot prove that (m3_2 : S[S[Nat]]) <:< S[S[S[Z]]] | ||
|
||
val m4_2 = add(S(Z), S(S(S(Z)))) | ||
summon[m4_2.type <:< S[S[S[S[Z]]]]] | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the documentation comment of
tvarsInParams
needs to be updated to account for these changes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed !