-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6140 from milessabin/topic/si-10528
Use solved type vars to improve bounds of undetermined vars
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 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
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,35 @@ | ||
object Test { | ||
trait Holder[A] | ||
trait NilHolder[A] extends Holder[A] | ||
|
||
trait Solve[A, H <: Holder[A]] { | ||
type Output <: Holder[A] | ||
} | ||
type SolveAux[A, H <: Holder[A], O <: Holder[A]] = Solve[A, H] {type Output = O} | ||
|
||
implicit def nilSolve[A] = new Solve[A, NilHolder[A]] { | ||
override type Output = NilHolder[A] | ||
} | ||
|
||
trait WrapSolve[A, H <: Holder[A]] { | ||
type Output <: Holder[A] | ||
} | ||
|
||
implicit def wrapAux[A, H <: Holder[A], O <: Holder[A]](implicit one : SolveAux[A, H, O]) = | ||
new WrapSolve[A, H] { | ||
override type Output = O | ||
} | ||
|
||
val wrapped = implicitly[WrapSolve[String, NilHolder[String]]] | ||
} | ||
|
||
object Test2 { | ||
class Inv[T] | ||
class Foo[T, U <: Inv[T]] | ||
|
||
implicit def foo[T]: Foo[T, Inv[T]] = new Foo[T, Inv[T]] | ||
|
||
def bar[T, U <: Inv[T]](implicit foo: Foo[T, U]): Inv[T] = new Inv[T] | ||
|
||
val baz: Inv[Int] = bar | ||
} |