diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-05-28 10:31:50 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-05-28 11:31:19 +0200 |
commit | 8d4ce1da77bd6bf4a2311c9e30bd815a9aedae1b (patch) | |
tree | aa71561fb510c71f1a31500a9277202ccb8a3bbd /test/files | |
parent | bcc82808ecf056affecf11b14f3ad850ad21d773 (diff) | |
download | scala-8d4ce1da77bd6bf4a2311c9e30bd815a9aedae1b.tar.gz scala-8d4ce1da77bd6bf4a2311c9e30bd815a9aedae1b.tar.bz2 scala-8d4ce1da77bd6bf4a2311c9e30bd815a9aedae1b.zip |
SI-5845 Advances the example from a crasher to an inference failure.
The inference failure itself seems like an instance of of SI-3346.
But dependent method types (which triggered the crash), can be employed
to avoid inferring the type constructor CC.
class Num[T] {
def mkOps = new Ops
class Ops { def +++(rhs: T) = () }
}
class A {
implicit def infixOps[T](lhs: T)(implicit num: Num[T]): num.Ops = num.mkOps
implicit val n1: Num[Int] = new Num[Int] { }
5 +++ 5
}
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t5845.check | 7 | ||||
-rw-r--r-- | test/files/neg/t5845.scala | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/files/neg/t5845.check b/test/files/neg/t5845.check new file mode 100644 index 0000000000..8c6100d6de --- /dev/null +++ b/test/files/neg/t5845.check @@ -0,0 +1,7 @@ +t5845.scala:9: error: value +++ is not a member of Int + println(5 +++ 5) + ^ +t5845.scala:15: error: value +++ is not a member of Int + println(5 +++ 5) + ^ +two errors found diff --git a/test/files/neg/t5845.scala b/test/files/neg/t5845.scala new file mode 100644 index 0000000000..823c722c14 --- /dev/null +++ b/test/files/neg/t5845.scala @@ -0,0 +1,16 @@ +class Num[T] { + def mkOps = new Ops + class Ops { def +++(rhs: T) = () } +} + +class A { + implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) = num.mkOps + implicit val n1 = new Num[Int] { } + println(5 +++ 5) +} + +class B { + implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) : CC[T]#Ops = num.mkOps + implicit val n1 = new Num[Int] {} + println(5 +++ 5) +} |