diff options
Diffstat (limited to 'test')
40 files changed, 834 insertions, 115 deletions
diff --git a/test/files/buildmanager/t2650_3/t2650_3.check b/test/files/buildmanager/t2650_3/t2650_3.check index c109800d9c..5c6326d59f 100644 --- a/test/files/buildmanager/t2650_3/t2650_3.check +++ b/test/files/buildmanager/t2650_3/t2650_3.check @@ -10,6 +10,5 @@ B.scala:2: error: type mismatch; found : a.T (which expands to) Long required: Int - possible cause: missing arguments for method or constructor def x(a: A): Int = a.x ^ diff --git a/test/files/buildmanager/t2650_4/t2650_4.check b/test/files/buildmanager/t2650_4/t2650_4.check index 89536776bd..a4aeaddfbb 100644 --- a/test/files/buildmanager/t2650_4/t2650_4.check +++ b/test/files/buildmanager/t2650_4/t2650_4.check @@ -10,6 +10,5 @@ B.scala:2: error: type mismatch; found : a.T2 (which expands to) Long required: Int - possible cause: missing arguments for method or constructor def x(a: A): Int = a.x ^ diff --git a/test/files/jvm/duration-java.check b/test/files/jvm/duration-java.check new file mode 100644 index 0000000000..7ae257dcc0 --- /dev/null +++ b/test/files/jvm/duration-java.check @@ -0,0 +1,362 @@ + 0.0 nanoseconds => 0 days + 1.0 nanoseconds => 1 nanosecond + 7.0 nanoseconds => 7 nanoseconds + 10.0 nanoseconds => 10 nanoseconds + 12.0 nanoseconds => 12 nanoseconds + 24.0 nanoseconds => 24 nanoseconds + 30.0 nanoseconds => 30 nanoseconds + 49.0 nanoseconds => 49 nanoseconds + 60.0 nanoseconds => 60 nanoseconds + 70.0 nanoseconds => 70 nanoseconds + 84.0 nanoseconds => 84 nanoseconds + 100.0 nanoseconds => 100 nanoseconds + 120.0 nanoseconds => 120 nanoseconds + 144.0 nanoseconds => 144 nanoseconds + 168.0 nanoseconds => 168 nanoseconds + 210.0 nanoseconds => 210 nanoseconds + 240.0 nanoseconds => 240 nanoseconds + 288.0 nanoseconds => 288 nanoseconds + 300.0 nanoseconds => 300 nanoseconds + 360.0 nanoseconds => 360 nanoseconds + 420.0 nanoseconds => 420 nanoseconds + 576.0 nanoseconds => 576 nanoseconds + 600.0 nanoseconds => 600 nanoseconds + 700.0 nanoseconds => 700 nanoseconds + 720.0 nanoseconds => 720 nanoseconds + 900.0 nanoseconds => 900 nanoseconds + 1000.0 nanoseconds => 1 microsecond + 1200.0 nanoseconds => 1200 nanoseconds + 1440.0 nanoseconds => 1440 nanoseconds + 1800.0 nanoseconds => 1800 nanoseconds + 2400.0 nanoseconds => 2400 nanoseconds + 3000.0 nanoseconds => 3 microseconds + 3600.0 nanoseconds => 3600 nanoseconds + 6000.0 nanoseconds => 6 microseconds + 7000.0 nanoseconds => 7 microseconds + 10000.0 nanoseconds => 10 microseconds + 12000.0 nanoseconds => 12 microseconds + 24000.0 nanoseconds => 24 microseconds + 30000.0 nanoseconds => 30 microseconds + 60000.0 nanoseconds => 60 microseconds + 100000.0 nanoseconds => 100 microseconds + 1000000.0 nanoseconds => 1 millisecond + 7000000.0 nanoseconds => 7 milliseconds + 1.0E7 nanoseconds => 10 milliseconds + 1.2E7 nanoseconds => 12 milliseconds + 2.4E7 nanoseconds => 24 milliseconds + 3.0E7 nanoseconds => 30 milliseconds + 6.0E7 nanoseconds => 60 milliseconds + 1.0E8 nanoseconds => 100 milliseconds + 1.0E9 nanoseconds => 1 second + 1.0E12 nanoseconds => 1000 seconds + 0.0 microseconds => 0 days + 1.0 microseconds => 1 microsecond + 7.0 microseconds => 7 microseconds + 10.0 microseconds => 10 microseconds + 12.0 microseconds => 12 microseconds + 24.0 microseconds => 24 microseconds + 30.0 microseconds => 30 microseconds + 49.0 microseconds => 49 microseconds + 60.0 microseconds => 60 microseconds + 70.0 microseconds => 70 microseconds + 84.0 microseconds => 84 microseconds + 100.0 microseconds => 100 microseconds + 120.0 microseconds => 120 microseconds + 144.0 microseconds => 144 microseconds + 168.0 microseconds => 168 microseconds + 210.0 microseconds => 210 microseconds + 240.0 microseconds => 240 microseconds + 288.0 microseconds => 288 microseconds + 300.0 microseconds => 300 microseconds + 360.0 microseconds => 360 microseconds + 420.0 microseconds => 420 microseconds + 576.0 microseconds => 576 microseconds + 600.0 microseconds => 600 microseconds + 700.0 microseconds => 700 microseconds + 720.0 microseconds => 720 microseconds + 900.0 microseconds => 900 microseconds + 1000.0 microseconds => 1 millisecond + 1200.0 microseconds => 1200 microseconds + 1440.0 microseconds => 1440 microseconds + 1800.0 microseconds => 1800 microseconds + 2400.0 microseconds => 2400 microseconds + 3000.0 microseconds => 3 milliseconds + 3600.0 microseconds => 3600 microseconds + 6000.0 microseconds => 6 milliseconds + 7000.0 microseconds => 7 milliseconds + 10000.0 microseconds => 10 milliseconds + 12000.0 microseconds => 12 milliseconds + 24000.0 microseconds => 24 milliseconds + 30000.0 microseconds => 30 milliseconds + 60000.0 microseconds => 60 milliseconds + 100000.0 microseconds => 100 milliseconds + 1000000.0 microseconds => 1 second + 7000000.0 microseconds => 7 seconds + 1.0E7 microseconds => 10 seconds + 1.2E7 microseconds => 12 seconds + 2.4E7 microseconds => 24 seconds + 3.0E7 microseconds => 30 seconds + 6.0E7 microseconds => 1 minute + 1.0E8 microseconds => 100 seconds + 1.0E9 microseconds => 1000 seconds + 1.0E12 microseconds => 1000000 seconds + 0.0 milliseconds => 0 days + 1.0 milliseconds => 1 millisecond + 7.0 milliseconds => 7 milliseconds + 10.0 milliseconds => 10 milliseconds + 12.0 milliseconds => 12 milliseconds + 24.0 milliseconds => 24 milliseconds + 30.0 milliseconds => 30 milliseconds + 49.0 milliseconds => 49 milliseconds + 60.0 milliseconds => 60 milliseconds + 70.0 milliseconds => 70 milliseconds + 84.0 milliseconds => 84 milliseconds + 100.0 milliseconds => 100 milliseconds + 120.0 milliseconds => 120 milliseconds + 144.0 milliseconds => 144 milliseconds + 168.0 milliseconds => 168 milliseconds + 210.0 milliseconds => 210 milliseconds + 240.0 milliseconds => 240 milliseconds + 288.0 milliseconds => 288 milliseconds + 300.0 milliseconds => 300 milliseconds + 360.0 milliseconds => 360 milliseconds + 420.0 milliseconds => 420 milliseconds + 576.0 milliseconds => 576 milliseconds + 600.0 milliseconds => 600 milliseconds + 700.0 milliseconds => 700 milliseconds + 720.0 milliseconds => 720 milliseconds + 900.0 milliseconds => 900 milliseconds + 1000.0 milliseconds => 1 second + 1200.0 milliseconds => 1200 milliseconds + 1440.0 milliseconds => 1440 milliseconds + 1800.0 milliseconds => 1800 milliseconds + 2400.0 milliseconds => 2400 milliseconds + 3000.0 milliseconds => 3 seconds + 3600.0 milliseconds => 3600 milliseconds + 6000.0 milliseconds => 6 seconds + 7000.0 milliseconds => 7 seconds + 10000.0 milliseconds => 10 seconds + 12000.0 milliseconds => 12 seconds + 24000.0 milliseconds => 24 seconds + 30000.0 milliseconds => 30 seconds + 60000.0 milliseconds => 1 minute + 100000.0 milliseconds => 100 seconds + 1000000.0 milliseconds => 1000 seconds + 7000000.0 milliseconds => 7000 seconds + 1.0E7 milliseconds => 10000 seconds + 1.2E7 milliseconds => 200 minutes + 2.4E7 milliseconds => 400 minutes + 3.0E7 milliseconds => 500 minutes + 6.0E7 milliseconds => 1000 minutes + 1.0E8 milliseconds => 100000 seconds + 1.0E9 milliseconds => 1000000 seconds + 1.0E12 milliseconds => 1000000000 seconds + 0.0 seconds => 0 days + 1.0 seconds => 1 second + 7.0 seconds => 7 seconds + 10.0 seconds => 10 seconds + 12.0 seconds => 12 seconds + 24.0 seconds => 24 seconds + 30.0 seconds => 30 seconds + 49.0 seconds => 49 seconds + 60.0 seconds => 1 minute + 70.0 seconds => 70 seconds + 84.0 seconds => 84 seconds + 100.0 seconds => 100 seconds + 120.0 seconds => 2 minutes + 144.0 seconds => 144 seconds + 168.0 seconds => 168 seconds + 210.0 seconds => 210 seconds + 240.0 seconds => 4 minutes + 288.0 seconds => 288 seconds + 300.0 seconds => 5 minutes + 360.0 seconds => 6 minutes + 420.0 seconds => 7 minutes + 576.0 seconds => 576 seconds + 600.0 seconds => 10 minutes + 700.0 seconds => 700 seconds + 720.0 seconds => 12 minutes + 900.0 seconds => 15 minutes + 1000.0 seconds => 1000 seconds + 1200.0 seconds => 20 minutes + 1440.0 seconds => 24 minutes + 1800.0 seconds => 30 minutes + 2400.0 seconds => 40 minutes + 3000.0 seconds => 50 minutes + 3600.0 seconds => 1 hour + 6000.0 seconds => 100 minutes + 7000.0 seconds => 7000 seconds + 10000.0 seconds => 10000 seconds + 12000.0 seconds => 200 minutes + 24000.0 seconds => 400 minutes + 30000.0 seconds => 500 minutes + 60000.0 seconds => 1000 minutes + 100000.0 seconds => 100000 seconds + 1000000.0 seconds => 1000000 seconds + 7000000.0 seconds => 7000000 seconds + 1.0E7 seconds => 10000000 seconds + 1.2E7 seconds => 200000 minutes + 2.4E7 seconds => 400000 minutes + 3.0E7 seconds => 500000 minutes + 6.0E7 seconds => 1000000 minutes + 1.0E8 seconds => 100000000 seconds + 1.0E9 seconds => 1000000000 seconds + 1.0E12 seconds => 9223372036854775807 nanoseconds + 0.0 minutes => 0 days + 1.0 minutes => 1 minute + 7.0 minutes => 7 minutes + 10.0 minutes => 10 minutes + 12.0 minutes => 12 minutes + 24.0 minutes => 24 minutes + 30.0 minutes => 30 minutes + 49.0 minutes => 49 minutes + 60.0 minutes => 1 hour + 70.0 minutes => 70 minutes + 84.0 minutes => 84 minutes + 100.0 minutes => 100 minutes + 120.0 minutes => 2 hours + 144.0 minutes => 144 minutes + 168.0 minutes => 168 minutes + 210.0 minutes => 210 minutes + 240.0 minutes => 4 hours + 288.0 minutes => 288 minutes + 300.0 minutes => 5 hours + 360.0 minutes => 6 hours + 420.0 minutes => 7 hours + 576.0 minutes => 576 minutes + 600.0 minutes => 10 hours + 700.0 minutes => 700 minutes + 720.0 minutes => 12 hours + 900.0 minutes => 15 hours + 1000.0 minutes => 1000 minutes + 1200.0 minutes => 20 hours + 1440.0 minutes => 1 day + 1800.0 minutes => 30 hours + 2400.0 minutes => 40 hours + 3000.0 minutes => 50 hours + 3600.0 minutes => 60 hours + 6000.0 minutes => 100 hours + 7000.0 minutes => 7000 minutes + 10000.0 minutes => 10000 minutes + 12000.0 minutes => 200 hours + 24000.0 minutes => 400 hours + 30000.0 minutes => 500 hours + 60000.0 minutes => 1000 hours + 100000.0 minutes => 100000 minutes + 1000000.0 minutes => 1000000 minutes + 7000000.0 minutes => 7000000 minutes + 1.0E7 minutes => 10000000 minutes + 1.2E7 minutes => 200000 hours + 2.4E7 minutes => 400000 hours + 3.0E7 minutes => 500000 hours + 6.0E7 minutes => 1000000 hours + 1.0E8 minutes => 100000000 minutes + 1.0E9 minutes => 9223372036854775807 nanoseconds + 1.0E12 minutes => 9223372036854775807 nanoseconds + 0.0 hours => 0 days + 1.0 hours => 1 hour + 7.0 hours => 7 hours + 10.0 hours => 10 hours + 12.0 hours => 12 hours + 24.0 hours => 1 day + 30.0 hours => 30 hours + 49.0 hours => 49 hours + 60.0 hours => 60 hours + 70.0 hours => 70 hours + 84.0 hours => 84 hours + 100.0 hours => 100 hours + 120.0 hours => 5 days + 144.0 hours => 6 days + 168.0 hours => 7 days + 210.0 hours => 210 hours + 240.0 hours => 10 days + 288.0 hours => 12 days + 300.0 hours => 300 hours + 360.0 hours => 15 days + 420.0 hours => 420 hours + 576.0 hours => 24 days + 600.0 hours => 25 days + 700.0 hours => 700 hours + 720.0 hours => 30 days + 900.0 hours => 900 hours + 1000.0 hours => 1000 hours + 1200.0 hours => 50 days + 1440.0 hours => 60 days + 1800.0 hours => 75 days + 2400.0 hours => 100 days + 3000.0 hours => 125 days + 3600.0 hours => 150 days + 6000.0 hours => 250 days + 7000.0 hours => 7000 hours + 10000.0 hours => 10000 hours + 12000.0 hours => 500 days + 24000.0 hours => 1000 days + 30000.0 hours => 1250 days + 60000.0 hours => 2500 days + 100000.0 hours => 100000 hours + 1000000.0 hours => 1000000 hours + 7000000.0 hours => 9223372036854775807 nanoseconds + 1.0E7 hours => 9223372036854775807 nanoseconds + 1.2E7 hours => 9223372036854775807 nanoseconds + 2.4E7 hours => 9223372036854775807 nanoseconds + 3.0E7 hours => 9223372036854775807 nanoseconds + 6.0E7 hours => 9223372036854775807 nanoseconds + 1.0E8 hours => 9223372036854775807 nanoseconds + 1.0E9 hours => 9223372036854775807 nanoseconds + 1.0E12 hours => 9223372036854775807 nanoseconds + 0.0 days => 0 days + 1.0 days => 1 day + 7.0 days => 7 days + 10.0 days => 10 days + 12.0 days => 12 days + 24.0 days => 24 days + 30.0 days => 30 days + 49.0 days => 49 days + 60.0 days => 60 days + 70.0 days => 70 days + 84.0 days => 84 days + 100.0 days => 100 days + 120.0 days => 120 days + 144.0 days => 144 days + 168.0 days => 168 days + 210.0 days => 210 days + 240.0 days => 240 days + 288.0 days => 288 days + 300.0 days => 300 days + 360.0 days => 360 days + 420.0 days => 420 days + 576.0 days => 576 days + 600.0 days => 600 days + 700.0 days => 700 days + 720.0 days => 720 days + 900.0 days => 900 days + 1000.0 days => 1000 days + 1200.0 days => 1200 days + 1440.0 days => 1440 days + 1800.0 days => 1800 days + 2400.0 days => 2400 days + 3000.0 days => 3000 days + 3600.0 days => 3600 days + 6000.0 days => 6000 days + 7000.0 days => 7000 days + 10000.0 days => 10000 days + 12000.0 days => 12000 days + 24000.0 days => 24000 days + 30000.0 days => 30000 days + 60000.0 days => 60000 days + 100000.0 days => 100000 days + 1000000.0 days => 9223372036854775807 nanoseconds + 7000000.0 days => 9223372036854775807 nanoseconds + 1.0E7 days => 9223372036854775807 nanoseconds + 1.2E7 days => 9223372036854775807 nanoseconds + 2.4E7 days => 9223372036854775807 nanoseconds + 3.0E7 days => 9223372036854775807 nanoseconds + 6.0E7 days => 9223372036854775807 nanoseconds + 1.0E8 days => 9223372036854775807 nanoseconds + 1.0E9 days => 9223372036854775807 nanoseconds + 1.0E12 days => 9223372036854775807 nanoseconds + Inf => Duration.Inf + -Inf => Duration.MinusInf + +Inf => Duration.Inf + PlusInf => Duration.Inf + MinusInf => Duration.MinusInf diff --git a/test/files/jvm/duration-java/Test.java b/test/files/jvm/duration-java/Test.java new file mode 100644 index 0000000000..02feb522b8 --- /dev/null +++ b/test/files/jvm/duration-java/Test.java @@ -0,0 +1,38 @@ +import scala.concurrent.util.Duration; +import java.util.*; +import java.util.concurrent.TimeUnit; +import static java.util.concurrent.TimeUnit.*; + +public class Test { + public static List<Double> inputs = Arrays.asList(0d, 1d, 7d, 10d, 12d, 24d, 30d, 60d, 100d, 1000d, 1e6); + public static List<Double> makeNumbers() { + ArrayList<Double> xs = new ArrayList<Double>(); + for (Double n1: inputs) { + for (Double n2: inputs) { + Double n = n1 * n2; + if (!xs.contains(n)) + xs.add(n); + } + } + Double[] arr = xs.toArray(new Double[0]); + Arrays.sort(arr); + return Arrays.asList(arr); + } + + public static void p(Object x) { + System.out.println(x); + } + public static void main(String[] args) { + for (TimeUnit t : TimeUnit.values()) { + for (Double n: makeNumbers()) { + String s = "" + n + " " + t.toString().toLowerCase(); + Duration d = Duration.create(n, t); + p(String.format("%25s => %s", s, d)); + } + } + for (String s: Arrays.asList("Inf", "-Inf", "+Inf", "PlusInf", "MinusInf")) { + Duration d = Duration.create(s); + p(String.format("%25s => %s", s, d)); + } + } +} diff --git a/test/files/neg/any-vs-anyref.check b/test/files/neg/any-vs-anyref.check new file mode 100644 index 0000000000..63c4853130 --- /dev/null +++ b/test/files/neg/any-vs-anyref.check @@ -0,0 +1,64 @@ +any-vs-anyref.scala:6: error: type mismatch; + found : a.type (with underlying type A) + required: AnyRef +Note that A is bounded only by Equals, which means AnyRef is not a known parent. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo1[A <: Product](a: A) = { type X = a.type } + ^ +any-vs-anyref.scala:7: error: type mismatch; + found : a.type (with underlying type A) + required: AnyRef +Note that A is bounded only by Product, Quux, which means AnyRef is not a known parent. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo2[A <: Product with Quux](a: A) = { type X = a.type } + ^ +any-vs-anyref.scala:8: error: type mismatch; + found : a.type (with underlying type Product) + required: AnyRef +Note that Product extends Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo3(a: Product) = { type X = a.type } + ^ +any-vs-anyref.scala:9: error: type mismatch; + found : Product with Quux + required: AnyRef +Note that the parents of this type (Product, Quux) extend Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo4(a: Product with Quux) = { type X = a.type } + ^ +any-vs-anyref.scala:10: error: value eq is not a member of Quux with Product +Note that the parents of this type (Quux, Product) extend Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo5(x: Quux with Product) = (x eq "abc") && ("abc" eq x) + ^ +any-vs-anyref.scala:11: error: value eq is not a member of Quux with Product{def f: Int} +Note that the parents of this type (Quux, Product) extend Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo6(x: Quux with Product { def f: Int }) = (x eq "abc") && ("abc" eq x) + ^ +any-vs-anyref.scala:12: error: type mismatch; + found : Quux with Product{def eq(other: String): Boolean} + required: AnyRef +Note that the parents of this type (Quux, Product) extend Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo7(x: Quux with Product { def eq(other: String): Boolean }) = (x eq "abc") && ("abc" eq x) + ^ +any-vs-anyref.scala:22: error: value eq is not a member of Bippy +Note that Bippy extends Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def bad1(x: Bippy, y: Bippy) = x eq y + ^ +any-vs-anyref.scala:27: error: type mismatch; + found : Quux{def g(x: String): String} + required: Quux{def g(x: Int): Int} + f(new Quux { def g(x: String) = x }) + ^ +9 errors found diff --git a/test/files/neg/any-vs-anyref.scala b/test/files/neg/any-vs-anyref.scala new file mode 100644 index 0000000000..8d237fbaec --- /dev/null +++ b/test/files/neg/any-vs-anyref.scala @@ -0,0 +1,29 @@ +trait Quux extends Any +trait QuuxRef extends AnyRef +final class Bippy(val x: Any) extends AnyVal with Quux + +object Foo { + def foo1[A <: Product](a: A) = { type X = a.type } + def foo2[A <: Product with Quux](a: A) = { type X = a.type } + def foo3(a: Product) = { type X = a.type } + def foo4(a: Product with Quux) = { type X = a.type } + def foo5(x: Quux with Product) = (x eq "abc") && ("abc" eq x) + def foo6(x: Quux with Product { def f: Int }) = (x eq "abc") && ("abc" eq x) + def foo7(x: Quux with Product { def eq(other: String): Boolean }) = (x eq "abc") && ("abc" eq x) + + def ok1[A <: QuuxRef](a: A) = { type X = a.type } + def ok2[A <: Product with QuuxRef](a: A) = { type X = a.type } + def ok3(a: QuuxRef) = { type X = a.type } + def ok4(a: Product with QuuxRef) = { type X = a.type } + def ok5(x: QuuxRef with Product) = (x eq "abc") && ("abc" eq x) + def ok6(x: QuuxRef with Product { def f: Int }) = (x eq "abc") && ("abc" eq x) + def ok7(x: QuuxRef { def eq(other: String): Boolean }) = (x eq "abc") && ("abc" eq x) + + def bad1(x: Bippy, y: Bippy) = x eq y +} + +object Bar { + def f(x: Quux { def g(x: Int): Int }): Int = x g 5 + f(new Quux { def g(x: String) = x }) + f(new Quux { def g(x: Int) = x }) +} diff --git a/test/files/neg/not-possible-cause.check b/test/files/neg/not-possible-cause.check new file mode 100644 index 0000000000..5c09fa1545 --- /dev/null +++ b/test/files/neg/not-possible-cause.check @@ -0,0 +1,9 @@ +not-possible-cause.scala:2: error: type mismatch; + found : a.type (with underlying type A) + required: AnyRef +Note that A is bounded only by Equals, which means AnyRef is not a known parent. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + def foo[A <: Product](a: A) { type X = a.type } + ^ +one error found diff --git a/test/files/neg/not-possible-cause.scala b/test/files/neg/not-possible-cause.scala new file mode 100644 index 0000000000..83ec24dec8 --- /dev/null +++ b/test/files/neg/not-possible-cause.scala @@ -0,0 +1,3 @@ +object Foo { + def foo[A <: Product](a: A) { type X = a.type } +} diff --git a/test/files/neg/static-annot.check b/test/files/neg/static-annot.check index 66efebdcee..c98e7d9658 100644 --- a/test/files/neg/static-annot.check +++ b/test/files/neg/static-annot.check @@ -13,7 +13,10 @@ static-annot.scala:38: error: The @static annotation is only allowed on public m static-annot.scala:39: error: The @static annotation is not allowed on lazy members. @static lazy val bam = 3 ^ +static-annot.scala:52: error: The @static annotation is not allowed on method definitions. + @static def x = 42 + ^ static-annot.scala:14: error: Only members of top-level objects and their nested objects can be annotated with @static. @static val blah = 2 ^ -6 errors found
\ No newline at end of file +7 errors found diff --git a/test/files/neg/t3614.check b/test/files/neg/t3614.check index 5fdb5cbf1f..0f9c83aa0d 100644 --- a/test/files/neg/t3614.check +++ b/test/files/neg/t3614.check @@ -1,4 +1,4 @@ -t3614.scala:2: error: class type required but AnyRef{def a: <?>} found +t3614.scala:2: error: class type required but AnyRef{def a: Int} found def v = new ({ def a=0 }) ^ -one error found
\ No newline at end of file +one error found diff --git a/test/files/neg/t4581.check b/test/files/neg/t4581.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/neg/t4581.check diff --git a/test/files/neg/t4581/static-declaration_1.scala b/test/files/neg/t4581/static-declaration_1.scala new file mode 100644 index 0000000000..f9a66b29c1 --- /dev/null +++ b/test/files/neg/t4581/static-declaration_1.scala @@ -0,0 +1,14 @@ + + + + + +object Constants { + import scala.annotation.static + @static val Const: Int = 0 // should generate a static final field + @static final val FinalConst: Int = 0 // ditto + @static var MutableField: Int = 0 // should not be final +} + + + diff --git a/test/files/neg/t4581/static_2.java b/test/files/neg/t4581/static_2.java new file mode 100644 index 0000000000..2fd5bf1d82 --- /dev/null +++ b/test/files/neg/t4581/static_2.java @@ -0,0 +1,15 @@ + + + + +public class static_2 { + public static void main(String[] args) { + Constants.Const = 17; + Constants.FinalConst = 99; + Constants.MutableField = 199; + } +} + + + + diff --git a/test/files/neg/t5510.check b/test/files/neg/t5510.check index 60da3bed40..04220e79bb 100644 --- a/test/files/neg/t5510.check +++ b/test/files/neg/t5510.check @@ -13,7 +13,7 @@ t5510.scala:5: error: unclosed string literal t5510.scala:6: error: unclosed multi-line string literal val s5 = ""s""" $s1 $s2 s" ^ -t5510.scala:7: error: '}' expected but eof found. +t5510.scala:7: error: unclosed multi-line string literal } ^ 6 errors found diff --git a/test/files/neg/t6263.check b/test/files/neg/t6263.check new file mode 100644 index 0000000000..9e9c7c615b --- /dev/null +++ b/test/files/neg/t6263.check @@ -0,0 +1,9 @@ +t6263.scala:5: error: type mismatch; + found : A.this.c.type (with underlying type C) + required: AnyRef +Note that C extends Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + type t = c.type + ^ +one error found diff --git a/test/files/neg/t6263.scala b/test/files/neg/t6263.scala new file mode 100644 index 0000000000..6575185b5c --- /dev/null +++ b/test/files/neg/t6263.scala @@ -0,0 +1,6 @@ +class C(val a: Any) extends AnyVal +class A { + implicit def c2AnyRef(c: C): AnyRef = new {} + val c = new C(0) + type t = c.type +} diff --git a/test/files/neg/t900.check b/test/files/neg/t900.check index ff5304a135..6fe26a31ac 100644 --- a/test/files/neg/t900.check +++ b/test/files/neg/t900.check @@ -1,6 +1,9 @@ t900.scala:4: error: type mismatch; found : Foo.this.x.type (with underlying type Foo.this.bar) required: AnyRef +Note that bar is unbounded, which means AnyRef is not a known parent. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. def break(): x.type ^ one error found diff --git a/test/files/pos/t6034.scala b/test/files/pos/t6034.scala new file mode 100644 index 0000000000..3558d7ff0b --- /dev/null +++ b/test/files/pos/t6034.scala @@ -0,0 +1 @@ +final class OptPlus[+A](val x: A) extends AnyVal { } diff --git a/test/files/pos/t6274.scala b/test/files/pos/t6274.scala new file mode 100644 index 0000000000..cf769fc72d --- /dev/null +++ b/test/files/pos/t6274.scala @@ -0,0 +1,13 @@ +trait Crash { + + def foo(i: => Int) (j: Int): Int + + def t = { + // var count = 0 + foo { + var count = 0 + count + } _ + } + +} diff --git a/test/files/pos/t6294.scala b/test/files/pos/t6294.scala new file mode 100644 index 0000000000..c6d39a9cc8 --- /dev/null +++ b/test/files/pos/t6294.scala @@ -0,0 +1,14 @@ + + + +object A { + @annotation.static final val x = 123 +} + + +object B { + println(A.x) +} + + + diff --git a/test/files/presentation/recursive-ask.check b/test/files/presentation/recursive-ask.check new file mode 100644 index 0000000000..357d2cf879 --- /dev/null +++ b/test/files/presentation/recursive-ask.check @@ -0,0 +1,4 @@ +[ outer] askForResponse +[nested] askForResponse +passed +done diff --git a/test/files/presentation/recursive-ask/RecursiveAsk.scala b/test/files/presentation/recursive-ask/RecursiveAsk.scala new file mode 100644 index 0000000000..b0e29b3fd3 --- /dev/null +++ b/test/files/presentation/recursive-ask/RecursiveAsk.scala @@ -0,0 +1,20 @@ +import scala.tools.nsc.interactive.tests._ + +object Test extends InteractiveTest { + override def execute(): Unit = recursiveAskForResponse() + + def recursiveAskForResponse() { + val res0 = compiler.askForResponse( () => { + println("[ outer] askForResponse") + val res = compiler.askForResponse( () => { println("[nested] askForResponse") }) + println (res.get(5000) match { + case Some(_) => "passed" + case None => "timeout" + }) + }) + + res0.get + + println("done") + } +} diff --git a/test/files/run/dynamic-anyval.check b/test/files/run/dynamic-anyval.check new file mode 100644 index 0000000000..dee7bef8e8 --- /dev/null +++ b/test/files/run/dynamic-anyval.check @@ -0,0 +1,4 @@ +().dingo(bippy, 5) +List(1, 2, 3).dingo(bippy, 5) +().dingo(bippy, 5) +List(1, 2, 3).dingo(bippy, 5) diff --git a/test/files/run/dynamic-anyval.scala b/test/files/run/dynamic-anyval.scala new file mode 100644 index 0000000000..605503d377 --- /dev/null +++ b/test/files/run/dynamic-anyval.scala @@ -0,0 +1,22 @@ +import scala.language.dynamics + +object Test { + implicit class DynamicValue[T](val value: T) extends AnyVal with Dynamic { + def applyDynamic(name: String)(args: Any*) = println(s"""$this.$name(${args mkString ", "})""") + override def toString = "" + value + } + implicit class DynamicValue2[T](val value: T) extends Dynamic { + def applyDynamic(name: String)(args: Any*) = println(s"""$this.$name(${args mkString ", "})""") + override def toString = "" + value + } + + def f[T](x: DynamicValue[T]) = x.dingo("bippy", 5) + def g[T](x: DynamicValue2[T]) = x.dingo("bippy", 5) + + def main(args: Array[String]): Unit = { + f(()) + f(List(1, 2, 3)) + g(()) + g(List(1, 2, 3)) + } +} diff --git a/test/files/run/reflection-equality.check b/test/files/run/reflection-equality.check index be531fbbd3..17c1f6dd70 100644 --- a/test/files/run/reflection-equality.check +++ b/test/files/run/reflection-equality.check @@ -1,53 +1,53 @@ -Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> class X {
- def methodIntIntInt(x: Int, y: Int) = x+y
-}
-defined class X
-
-scala>
-
-scala> import scala.reflect.runtime.universe._
-import scala.reflect.runtime.universe._
-
-scala> import scala.reflect.runtime.{ currentMirror => cm }
-import scala.reflect.runtime.{currentMirror=>cm}
-
-scala> def im: InstanceMirror = cm.reflect(new X)
-im: reflect.runtime.universe.InstanceMirror
-
-scala> val cs: ClassSymbol = im.symbol
-cs: reflect.runtime.universe.ClassSymbol = class X
-
-scala> val ts: Type = cs.typeSignature
-ts: reflect.runtime.universe.Type =
-java.lang.Object {
- def <init>: <?>
- def methodIntIntInt: <?>
-}
-
-scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod
-ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt
-
-scala> val MethodType( _, t1 ) = ms.typeSignature
-t1: reflect.runtime.universe.Type = scala.Int
-
-scala> val t2 = typeOf[scala.Int]
-t2: reflect.runtime.universe.Type = Int
-
-scala> t1 == t2
-res0: Boolean = false
-
-scala> t1 =:= t2
-res1: Boolean = true
-
-scala> t1 <:< t2
-res2: Boolean = true
-
-scala> t2 <:< t1
-res3: Boolean = true
-
-scala>
+Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> class X { + def methodIntIntInt(x: Int, y: Int) = x+y +} +defined class X + +scala> + +scala> import scala.reflect.runtime.universe._ +import scala.reflect.runtime.universe._ + +scala> import scala.reflect.runtime.{ currentMirror => cm } +import scala.reflect.runtime.{currentMirror=>cm} + +scala> def im: InstanceMirror = cm.reflect(new X) +im: reflect.runtime.universe.InstanceMirror + +scala> val cs: ClassSymbol = im.symbol +cs: reflect.runtime.universe.ClassSymbol = class X + +scala> val ts: Type = cs.typeSignature +ts: reflect.runtime.universe.Type = +java.lang.Object { + def <init>(): X + def methodIntIntInt(x: scala.Int,y: scala.Int): scala.Int +} + +scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod +ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt + +scala> val MethodType( _, t1 ) = ms.typeSignature +t1: reflect.runtime.universe.Type = scala.Int + +scala> val t2 = typeOf[scala.Int] +t2: reflect.runtime.universe.Type = Int + +scala> t1 == t2 +res0: Boolean = false + +scala> t1 =:= t2 +res1: Boolean = true + +scala> t1 <:< t2 +res2: Boolean = true + +scala> t2 <:< t1 +res3: Boolean = true + +scala> diff --git a/test/files/run/reflection-fieldmirror-accessorsareokay.scala b/test/files/run/reflection-fieldmirror-accessorsareokay.scala index 9590cbe811..16354025f3 100644 --- a/test/files/run/reflection-fieldmirror-accessorsareokay.scala +++ b/test/files/run/reflection-fieldmirror-accessorsareokay.scala @@ -14,7 +14,7 @@ object Test extends App { def test(f: Symbol) = { try { val fm: FieldMirror = im.reflectField(f.asTerm) - println(fm.symbol.isVariable) + println(fm.symbol.isVar) println(fm.get) fm.set(2) println(fm.get) diff --git a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala index 5cfe583ed5..2b4a9bb55e 100644 --- a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala +++ b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala @@ -12,5 +12,5 @@ object Test extends App { val cs = im.symbol val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) - println(fm.symbol.isVariable) + println(fm.symbol.isVar) } diff --git a/test/files/run/reflection-fieldmirror-privatethis.scala b/test/files/run/reflection-fieldmirror-privatethis.scala index 7aa179958d..ab838dbb1b 100644 --- a/test/files/run/reflection-fieldmirror-privatethis.scala +++ b/test/files/run/reflection-fieldmirror-privatethis.scala @@ -12,7 +12,7 @@ object Test extends App { val cs = im.symbol val f = cs.typeSignature.declaration(newTermName("x")).asTerm val fm: FieldMirror = im.reflectField(f) - println(fm.symbol.isVariable) + println(fm.symbol.isVar) println(fm.get) fm.set(2) println(fm.get) diff --git a/test/files/run/reflection-fieldsymbol-navigation.scala b/test/files/run/reflection-fieldsymbol-navigation.scala index da4612a564..4448724988 100644 --- a/test/files/run/reflection-fieldsymbol-navigation.scala +++ b/test/files/run/reflection-fieldsymbol-navigation.scala @@ -7,9 +7,9 @@ class C { object Test extends App { val x = typeOf[C].member(newTermName("x")).asTerm println(x) - println(x.isVariable) + println(x.isVar) println(x.accessed) - println(x.accessed.asTerm.isVariable) + println(x.accessed.asTerm.isVar) println(x.getter) println(x.setter) }
\ No newline at end of file diff --git a/test/files/run/static-annot-repl.check b/test/files/run/static-annot-repl.check index d1029a9809..3a1532b823 100644 --- a/test/files/run/static-annot-repl.check +++ b/test/files/run/static-annot-repl.check @@ -13,7 +13,9 @@ scala> @static val x2 = 43 x2: Int = 43 scala> @static def x3 = 44 -x3: Int +<console>:8: error: The @static annotation is not allowed on method definitions. + @static def x3 = 44 + ^ scala> x1 res0: Int = 42 @@ -22,11 +24,15 @@ scala> x2 res1: Int = 43 scala> x3 -res2: Int = 44 +<console>:9: error: not found: value x3 + x3 + ^ scala> class Test { @static def x = 42 } -defined class Test +<console>:9: error: The @static annotation is not allowed on method definitions. + @static def x = 42 + ^ scala>
\ No newline at end of file diff --git a/test/files/run/t5064.check b/test/files/run/t5064.check new file mode 100644 index 0000000000..077006abd9 --- /dev/null +++ b/test/files/run/t5064.check @@ -0,0 +1,25 @@ +[12] T5064.super.<init>() +[12] T5064.super.<init> +[12] this +[16:23] immutable.this.List.apply(scala.this.Predef.wrapIntArray(Array[Int]{1})) +[16:20] immutable.this.List.apply +<16:20> immutable.this.List +<16:20> immutable.this +[16:23] scala.this.Predef.wrapIntArray(Array[Int]{1}) +[20] scala.this.Predef.wrapIntArray +[20] scala.this.Predef +[20] scala.this +[26:32] collection.this.Seq.apply(scala.this.Predef.wrapIntArray(Array[Int]{1})) +[26:29] collection.this.Seq.apply +<26:29> collection.this.Seq +<26:29> collection.this +[26:32] scala.this.Predef.wrapIntArray(Array[Int]{1}) +[29] scala.this.Predef.wrapIntArray +[29] scala.this.Predef +[29] scala.this +[35:39] immutable.this.List +<35:39> immutable.this +[42:45] collection.this.Seq +<42:45> collection.this +[48:51] immutable.this.Nil +<48:51> immutable.this diff --git a/test/files/run/t5064.scala b/test/files/run/t5064.scala new file mode 100644 index 0000000000..35f0951765 --- /dev/null +++ b/test/files/run/t5064.scala @@ -0,0 +1,23 @@ +import scala.tools.partest._ + +object Test extends CompilerTest { + import global._ + override def extraSettings = super.extraSettings + " -Yrangepos" + override def sources = List( + """|class T5064 { + | List(1) + | Seq(1) + | List + | Seq + | Nil + |}""".stripMargin + ) + def check(source: String, unit: CompilationUnit) { + for (ClassDef(_, _, _, Template(_, _, stats)) <- unit.body ; stat <- stats ; t <- stat) { + t match { + case _: Select | _: Apply | _: This => println("%-15s %s".format(t.pos.show, t)) + case _ => + } + } + } +}
\ No newline at end of file diff --git a/test/files/run/t5256a.check b/test/files/run/t5256a.check index 518663b3da..7e60139db3 100644 --- a/test/files/run/t5256a.check +++ b/test/files/run/t5256a.check @@ -1,6 +1,6 @@ -class A
-A
+class A +A Object { - def <init>: <?> - def foo: <?> -}
+ def <init>(): A + def foo: Nothing +} diff --git a/test/files/run/t5256b.check b/test/files/run/t5256b.check index d6015f2743..a80df6eb30 100644 --- a/test/files/run/t5256b.check +++ b/test/files/run/t5256b.check @@ -1,6 +1,6 @@ -class A
-Test.A
+class A +Test.A Object { - def <init>: <?> - def foo: <?> -}
+ def <init>(): Test.A + def foo: Nothing +} diff --git a/test/files/run/t5256d.check b/test/files/run/t5256d.check index dd32c05a93..9742ae572e 100644 --- a/test/files/run/t5256d.check +++ b/test/files/run/t5256d.check @@ -1,32 +1,32 @@ -Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> import scala.reflect.runtime.universe._
-import scala.reflect.runtime.universe._
-
-scala> import scala.reflect.runtime.{currentMirror => cm}
-import scala.reflect.runtime.{currentMirror=>cm}
-
-scala> class A { def foo = ??? }
-defined class A
-
-scala> val c = cm.classSymbol(classOf[A])
-c: reflect.runtime.universe.ClassSymbol = class A
-
-scala> println(c)
-class A
-
-scala> println(c.fullName)
-$line8.$read.$iw.$iw.$iw.$iw.A
-
-scala> println(c.typeSignature)
-java.lang.Object {
- def <init>: <?>
- def foo: <?>
-}
-
-scala>
-
-scala>
+Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> import scala.reflect.runtime.universe._ +import scala.reflect.runtime.universe._ + +scala> import scala.reflect.runtime.{currentMirror => cm} +import scala.reflect.runtime.{currentMirror=>cm} + +scala> class A { def foo = ??? } +defined class A + +scala> val c = cm.classSymbol(classOf[A]) +c: reflect.runtime.universe.ClassSymbol = class A + +scala> println(c) +class A + +scala> println(c.fullName) +$line8.$read.$iw.$iw.$iw.$iw.A + +scala> println(c.typeSignature) +java.lang.Object { + def <init>(): A + def foo: scala.Nothing +} + +scala> + +scala> diff --git a/test/files/run/t5256e.check b/test/files/run/t5256e.check index 6c6de90acc..011115720c 100644 --- a/test/files/run/t5256e.check +++ b/test/files/run/t5256e.check @@ -1,6 +1,6 @@ class A Test.C.A Object { - def <init>: <?> - def foo: <?> + def <init>(): C.this.A + def foo: Nothing } diff --git a/test/files/run/t5256f.check b/test/files/run/t5256f.check index c840793fd5..e0fec85596 100644 --- a/test/files/run/t5256f.check +++ b/test/files/run/t5256f.check @@ -1,12 +1,12 @@ class A1 Test.A1 Object { - def <init>: <?> - def foo: <?> + def <init>(): Test.A1 + def foo: Nothing } class A2 Test.A2 Object { - def <init>: <?> - def foo: <?> + def <init>(): Test.this.A2 + def foo: Nothing } diff --git a/test/files/run/t6273.check b/test/files/run/t6273.check new file mode 100644 index 0000000000..c1c18daac2 --- /dev/null +++ b/test/files/run/t6273.check @@ -0,0 +1,19 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> val y = 55 +y: Int = 55 + +scala> val x = s""" + y = $y +""" +x: String = +" + y = 55 +" + +scala> + +scala> diff --git a/test/files/run/t6273.scala b/test/files/run/t6273.scala new file mode 100644 index 0000000000..ed0fd452e0 --- /dev/null +++ b/test/files/run/t6273.scala @@ -0,0 +1,11 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def tq = "\"\"\"" + def code = s""" +val y = 55 +val x = s$tq + y = $$y +$tq + """ +} diff --git a/test/files/run/t6290.scala b/test/files/run/t6290.scala new file mode 100644 index 0000000000..9d05db0d18 --- /dev/null +++ b/test/files/run/t6290.scala @@ -0,0 +1,4 @@ +object Test { + implicit val foo = language.dynamics + def main(args: Array[String]): Unit = () +} |