diff options
author | Martin Odersky <odersky@gmail.com> | 2015-06-25 09:31:34 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-06-25 09:37:13 +0200 |
commit | f3f75cad600d616db43138b09b01fcea93affd58 (patch) | |
tree | 89f2625d5cfa853b3ac7d272a2d0c032dd3b8898 /tests | |
parent | bb90c8457ab91e3c4cd707fa1a68e75e6dd96128 (diff) | |
download | dotty-f3f75cad600d616db43138b09b01fcea93affd58.tar.gz dotty-f3f75cad600d616db43138b09b01fcea93affd58.tar.bz2 dotty-f3f75cad600d616db43138b09b01fcea93affd58.zip |
Sharpen prototypes of implicit methods.
Necessary to make implicit resolution of type-level peano numbers work.
The current commit makes takes the inimal steps to make this happen. We
could also consider sharpening using followAlias every type we constrain
a result, or every time we adapt a type.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/implicitNums.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/pos/implicitNums.scala b/tests/pos/implicitNums.scala new file mode 100644 index 000000000..48c5302f7 --- /dev/null +++ b/tests/pos/implicitNums.scala @@ -0,0 +1,15 @@ +object Test { + + trait Number + trait Zero extends Number + trait Succ[N <: Number](n: N) extends Number + + implicit def succ[N <: Number](implicit n: N): Succ[N] = new Succ[N](n) {} + implicit def zero: Zero = new Zero{} + + implicitly[Zero] + implicitly[Succ[Zero]] + implicitly[Succ[Succ[Zero]]] + implicitly[Succ[Succ[Succ[Zero]]]] + +} |