diff options
author | odersky <odersky@gmail.com> | 2017-02-08 22:21:05 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 22:21:05 +1100 |
commit | 18d5913821064fffa0c74524ba1a8ead9a7def31 (patch) | |
tree | 502b93ffc33390ec0f433dfa5b71b7e9c384edd2 /tests | |
parent | 99679cffc0a5d20e7e7f3c090eb310a6134eeee7 (diff) | |
parent | abbee9e28ef3f0150c9afa48f485ecc49e0e3787 (diff) | |
download | dotty-18d5913821064fffa0c74524ba1a8ead9a7def31.tar.gz dotty-18d5913821064fffa0c74524ba1a8ead9a7def31.tar.bz2 dotty-18d5913821064fffa0c74524ba1a8ead9a7def31.zip |
Merge pull request #1921 from dotty-staging/fix-#1907
Fix #1907: Improve error message
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/i1802.scala | 4 | ||||
-rw-r--r-- | tests/neg/i1907.scala | 7 | ||||
-rw-r--r-- | tests/neg/undet-classtag.scala | 27 | ||||
-rw-r--r-- | tests/pos/t3859.scala | 2 | ||||
-rw-r--r-- | tests/pos/t5859.scala | 4 | ||||
-rw-r--r-- | tests/run/array-addition.scala | 4 |
6 files changed, 41 insertions, 7 deletions
diff --git a/tests/neg/i1802.scala b/tests/neg/i1802.scala index 56da672a8..93e790f18 100644 --- a/tests/neg/i1802.scala +++ b/tests/neg/i1802.scala @@ -14,8 +14,8 @@ object Exception { def apply(x: Throwable): T = f(downcast(x).get) } - def mkThrowableCatcher[T](isDef: Throwable => Boolean, f: Throwable => T) = mkCatcher(isDef, f) + def mkThrowableCatcher[T](isDef: Throwable => Boolean, f: Throwable => T) = mkCatcher(isDef, f) // error: undetermined ClassTag - implicit def throwableSubtypeToCatcher[Ex <: Throwable: ClassTag, T](pf: PartialFunction[Ex, T]) = // error: cyclic reference + implicit def throwableSubtypeToCatcher[Ex <: Throwable: ClassTag, T](pf: PartialFunction[Ex, T]) = mkCatcher(pf.isDefinedAt _, pf.apply _) } diff --git a/tests/neg/i1907.scala b/tests/neg/i1907.scala new file mode 100644 index 000000000..6bc3bb56f --- /dev/null +++ b/tests/neg/i1907.scala @@ -0,0 +1,7 @@ +import java.io.File + +object Test { + Some(new File(".")) + .map(_.listFiles).getOrElse(Array.empty) // error: undetermined ClassTag + .map(_.listFiles) +} diff --git a/tests/neg/undet-classtag.scala b/tests/neg/undet-classtag.scala new file mode 100644 index 000000000..dfe0eb2db --- /dev/null +++ b/tests/neg/undet-classtag.scala @@ -0,0 +1,27 @@ +import scala.reflect.ClassTag + +object Test { + def f[T: reflect.ClassTag](x: T) = ??? + + f(???) // error: undetermined ClassTag +} + +// SI 9754 +object Program { + def test[T: ClassTag](x: T) = { + val arr = new Array[T](1) + println(arr.getClass) + println(x.getClass) + arr(0) = x + } + + def main(args: Array[String]): Unit = { + test(new Array[Nothing](0)) // error: undetermined ClassTag + } +} + +// SI 5353 +object t5353 { + if (false) Array("qwe") else Array() // error: undetermined ClassTag +} + diff --git a/tests/pos/t3859.scala b/tests/pos/t3859.scala index 992207301..486c1d4b2 100644 --- a/tests/pos/t3859.scala +++ b/tests/pos/t3859.scala @@ -1,4 +1,4 @@ class Test { - def foo: Unit = bar(Array(): _*) + def foo: Unit = bar(Array[AnyRef](): _*) def bar(values: AnyRef*): Unit = () } diff --git a/tests/pos/t5859.scala b/tests/pos/t5859.scala index 2a31e68ee..60ec8b4cb 100644 --- a/tests/pos/t5859.scala +++ b/tests/pos/t5859.scala @@ -7,9 +7,9 @@ class A { f(List[AnyRef](): _*) f(List(): _*) f(Nil: _*) - f(Array(): _*) + // f(Array(): _*) // undetermined ClassTag f(Array[AnyRef](): _*) f(List(1)) f(List(1), Nil: _*) - f(List(1), Array(): _*) + // f(List(1), Array(): _*) // undetermined ClassTag } diff --git a/tests/run/array-addition.scala b/tests/run/array-addition.scala index 8def48e85..09a1b0bad 100644 --- a/tests/run/array-addition.scala +++ b/tests/run/array-addition.scala @@ -4,8 +4,8 @@ object Test { def main(args: Array[String]): Unit = { prettyPrintArray(Array(1,2,3) :+ 4) prettyPrintArray(1 +: Array(2,3,4)) - prettyPrintArray(Array() :+ 1) - prettyPrintArray(1 +: Array()) + prettyPrintArray(Array[Int]() :+ 1) + prettyPrintArray(1 +: Array[Int]()) } } |