From 10830eaae2955766378369b8d1bcc0e6963b9b7f Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Fri, 15 May 2009 15:44:54 +0000 Subject: 1.4-related cleanup and reorganization. Removed a bunch of now useless 1.4 code, merged back jvm5-specific partest tests into the general jvm tests, documentation updates. --- test/files/jvm/NestedAnnotations.java | 25 +++ test/files/jvm/OuterEnum.java | 5 + test/files/jvm/OuterTParams.java | 6 + test/files/jvm/SourceAnnotation.java | 9 + test/files/jvm/annotations.check | 35 +++ test/files/jvm/annotations.scala | 159 ++++++++++++++ test/files/jvm/bug676.check | 1 + test/files/jvm/bug676.scala | 8 + test/files/jvm/bug680.check | 0 test/files/jvm/bug680.scala | 6 + test/files/jvm/console.check | 3 + test/files/jvm/console.scala | 14 ++ test/files/jvm/genericNest.scala | 13 ++ test/files/jvm/interpreter.check | 218 +++++++++++++++++++ test/files/jvm/interpreter.scala | 179 +++++++++++++++ test/files/jvm/mkAnnotationsJar.sh | 29 +++ test/files/jvm/outerEnum.check | 1 + test/files/jvm/outerEnum.scala | 9 + test/files/jvm/stringbuilder.scala | 100 +++++++++ test/files/jvm/sync-var.check | 1 + test/files/jvm/sync-var.scala | 53 +++++ test/files/jvm/t0014.check | 1 + test/files/jvm/t0014.scala | 5 + test/files/jvm/t1461.scala | 18 ++ test/files/jvm/t1464.check | 1 + test/files/jvm/t1464/MyTrait.scala | 5 + test/files/jvm/t1464/Test.java | 6 + test/files/jvm/throws-annot.check | 21 ++ test/files/jvm/throws-annot.scala | 74 +++++++ test/files/jvm/typerep.check | 2 + test/files/jvm/typerep.scala | 25 ++- test/files/jvm5/NestedAnnotations.java | 25 --- test/files/jvm5/OuterEnum.java | 5 - test/files/jvm5/OuterTParams.java | 6 - test/files/jvm5/SourceAnnotation.java | 9 - test/files/jvm5/annotations.check | 35 --- test/files/jvm5/annotations.scala | 159 -------------- test/files/jvm5/bug676.check | 1 - test/files/jvm5/bug676.scala | 8 - test/files/jvm5/bug680.check | 0 test/files/jvm5/bug680.scala | 6 - test/files/jvm5/console.check | 3 - test/files/jvm5/console.scala | 14 -- test/files/jvm5/genericNest.scala | 13 -- test/files/jvm5/interpreter.check | 218 ------------------- test/files/jvm5/interpreter.scala | 179 --------------- test/files/jvm5/mkAnnotationsJar.sh | 29 --- test/files/jvm5/outerEnum.check | 1 - test/files/jvm5/outerEnum.scala | 9 - test/files/jvm5/stringbuilder.scala | 100 --------- test/files/jvm5/sync-var.check | 1 - test/files/jvm5/sync-var.scala | 53 ----- test/files/jvm5/t0014.check | 1 - test/files/jvm5/t0014.scala | 5 - test/files/jvm5/t1461.scala | 18 -- test/files/jvm5/t1464.check | 1 - test/files/jvm5/t1464/MyTrait.scala | 5 - test/files/jvm5/t1464/Test.java | 6 - test/files/jvm5/throws-annot.check | 21 -- test/files/jvm5/throws-annot.scala | 74 ------- test/files/jvm5/typerep.check | 49 ----- test/files/jvm5/typerep.scala | 383 --------------------------------- test/files/pos/chang/Outer.java | 11 + test/files/pos/chang/Test.scala | 3 + test/files/pos/ilya/J.java | 14 ++ test/files/pos/ilya/S.scala | 5 + test/files/pos/ilya2/A.scala | 3 + test/files/pos/ilya2/B.java | 6 + test/files/pos/ilya2/Nullable.java | 7 + test/files/pos/signatures/Test.java | 11 + test/files/pos/signatures/sig.scala | 12 ++ test/files/pos/t0695/JavaClass.java | 5 + test/files/pos/t0695/Test.scala | 3 + test/files/pos/t1101/J.java | 1 + test/files/pos/t1101/S.scala | 1 + test/files/pos/t1102/J.java | 4 + test/files/pos/t1102/S.scala | 1 + test/files/pos/t1150/J.java | 4 + test/files/pos/t1150/S.scala | 4 + test/files/pos/t1152/J.java | 1 + test/files/pos/t1152/S.scala | 2 + test/files/pos/t1176/J.java | 4 + test/files/pos/t1176/S.scala | 1 + test/files/pos/t1186/t1186.java | 8 + test/files/pos/t1196/J.java | 1 + test/files/pos/t1196/S.scala | 1 + test/files/pos/t1197/J.java | 2 + test/files/pos/t1197/S.scala | 2 + test/files/pos/t1203/J.java | 1 + test/files/pos/t1203/S.scala | 1 + test/files/pos/t1230/J.java | 1 + test/files/pos/t1230/S.scala | 1 + test/files/pos/t1231/J.java | 1 + test/files/pos/t1231/S.scala | 1 + test/files/pos/t1232/J.java | 2 + test/files/pos/t1232/J2.java | 2 + test/files/pos/t1232/S.scala | 2 + test/files/pos/t1235/Test.java | 9 + test/files/pos/t1254/t1254.java | 28 +++ test/files/pos/t1263/Test.java | 16 ++ test/files/pos/t1263/test.scala | 10 + test/files/pos/t1711/Seq.scala | 12 ++ test/files/pos/t1711/Test.java | 6 + test/files/pos5/chang/Outer.java | 11 - test/files/pos5/chang/Test.scala | 3 - test/files/pos5/ilya/J.java | 14 -- test/files/pos5/ilya/S.scala | 5 - test/files/pos5/ilya2/A.scala | 3 - test/files/pos5/ilya2/B.java | 6 - test/files/pos5/ilya2/Nullable.java | 7 - test/files/pos5/signatures/Test.java | 11 - test/files/pos5/signatures/sig.scala | 12 -- test/files/pos5/t0695/JavaClass.java | 5 - test/files/pos5/t0695/Test.scala | 3 - test/files/pos5/t1101/J.java | 1 - test/files/pos5/t1101/S.scala | 1 - test/files/pos5/t1102/J.java | 4 - test/files/pos5/t1102/S.scala | 1 - test/files/pos5/t1150/J.java | 4 - test/files/pos5/t1150/S.scala | 4 - test/files/pos5/t1152/J.java | 1 - test/files/pos5/t1152/S.scala | 2 - test/files/pos5/t1176/J.java | 4 - test/files/pos5/t1176/S.scala | 1 - test/files/pos5/t1186/t1186.java | 8 - test/files/pos5/t1196/J.java | 1 - test/files/pos5/t1196/S.scala | 1 - test/files/pos5/t1197/J.java | 2 - test/files/pos5/t1197/S.scala | 2 - test/files/pos5/t1203/J.java | 1 - test/files/pos5/t1203/S.scala | 1 - test/files/pos5/t1230/J.java | 1 - test/files/pos5/t1230/S.scala | 1 - test/files/pos5/t1231/J.java | 1 - test/files/pos5/t1231/S.scala | 1 - test/files/pos5/t1232/J.java | 2 - test/files/pos5/t1232/J2.java | 2 - test/files/pos5/t1232/S.scala | 2 - test/files/pos5/t1235/Test.java | 9 - test/files/pos5/t1254/t1254.java | 28 --- test/files/pos5/t1263/Test.java | 16 -- test/files/pos5/t1263/test.scala | 10 - test/files/pos5/t1711/Seq.scala | 12 -- test/files/pos5/t1711/Test.java | 6 - 144 files changed, 1234 insertions(+), 1655 deletions(-) create mode 100644 test/files/jvm/NestedAnnotations.java create mode 100644 test/files/jvm/OuterEnum.java create mode 100644 test/files/jvm/OuterTParams.java create mode 100644 test/files/jvm/SourceAnnotation.java create mode 100644 test/files/jvm/annotations.check create mode 100644 test/files/jvm/annotations.scala create mode 100644 test/files/jvm/bug676.check create mode 100644 test/files/jvm/bug676.scala create mode 100644 test/files/jvm/bug680.check create mode 100644 test/files/jvm/bug680.scala create mode 100644 test/files/jvm/console.check create mode 100644 test/files/jvm/console.scala create mode 100644 test/files/jvm/genericNest.scala create mode 100644 test/files/jvm/interpreter.check create mode 100644 test/files/jvm/interpreter.scala create mode 100755 test/files/jvm/mkAnnotationsJar.sh create mode 100644 test/files/jvm/outerEnum.check create mode 100644 test/files/jvm/outerEnum.scala create mode 100644 test/files/jvm/stringbuilder.scala create mode 100644 test/files/jvm/sync-var.check create mode 100644 test/files/jvm/sync-var.scala create mode 100644 test/files/jvm/t0014.check create mode 100644 test/files/jvm/t0014.scala create mode 100644 test/files/jvm/t1461.scala create mode 100644 test/files/jvm/t1464.check create mode 100644 test/files/jvm/t1464/MyTrait.scala create mode 100644 test/files/jvm/t1464/Test.java create mode 100644 test/files/jvm/throws-annot.check create mode 100644 test/files/jvm/throws-annot.scala mode change 100644 => 100755 test/files/jvm/typerep.check mode change 100644 => 100755 test/files/jvm/typerep.scala delete mode 100644 test/files/jvm5/NestedAnnotations.java delete mode 100644 test/files/jvm5/OuterEnum.java delete mode 100644 test/files/jvm5/OuterTParams.java delete mode 100644 test/files/jvm5/SourceAnnotation.java delete mode 100644 test/files/jvm5/annotations.check delete mode 100644 test/files/jvm5/annotations.scala delete mode 100644 test/files/jvm5/bug676.check delete mode 100644 test/files/jvm5/bug676.scala delete mode 100644 test/files/jvm5/bug680.check delete mode 100644 test/files/jvm5/bug680.scala delete mode 100644 test/files/jvm5/console.check delete mode 100644 test/files/jvm5/console.scala delete mode 100644 test/files/jvm5/genericNest.scala delete mode 100644 test/files/jvm5/interpreter.check delete mode 100644 test/files/jvm5/interpreter.scala delete mode 100755 test/files/jvm5/mkAnnotationsJar.sh delete mode 100644 test/files/jvm5/outerEnum.check delete mode 100644 test/files/jvm5/outerEnum.scala delete mode 100644 test/files/jvm5/stringbuilder.scala delete mode 100644 test/files/jvm5/sync-var.check delete mode 100644 test/files/jvm5/sync-var.scala delete mode 100644 test/files/jvm5/t0014.check delete mode 100644 test/files/jvm5/t0014.scala delete mode 100644 test/files/jvm5/t1461.scala delete mode 100644 test/files/jvm5/t1464.check delete mode 100644 test/files/jvm5/t1464/MyTrait.scala delete mode 100644 test/files/jvm5/t1464/Test.java delete mode 100644 test/files/jvm5/throws-annot.check delete mode 100644 test/files/jvm5/throws-annot.scala delete mode 100755 test/files/jvm5/typerep.check delete mode 100755 test/files/jvm5/typerep.scala create mode 100644 test/files/pos/chang/Outer.java create mode 100644 test/files/pos/chang/Test.scala create mode 100644 test/files/pos/ilya/J.java create mode 100644 test/files/pos/ilya/S.scala create mode 100644 test/files/pos/ilya2/A.scala create mode 100644 test/files/pos/ilya2/B.java create mode 100644 test/files/pos/ilya2/Nullable.java create mode 100644 test/files/pos/signatures/Test.java create mode 100644 test/files/pos/signatures/sig.scala create mode 100644 test/files/pos/t0695/JavaClass.java create mode 100644 test/files/pos/t0695/Test.scala create mode 100644 test/files/pos/t1101/J.java create mode 100644 test/files/pos/t1101/S.scala create mode 100644 test/files/pos/t1102/J.java create mode 100644 test/files/pos/t1102/S.scala create mode 100644 test/files/pos/t1150/J.java create mode 100644 test/files/pos/t1150/S.scala create mode 100644 test/files/pos/t1152/J.java create mode 100644 test/files/pos/t1152/S.scala create mode 100644 test/files/pos/t1176/J.java create mode 100644 test/files/pos/t1176/S.scala create mode 100644 test/files/pos/t1186/t1186.java create mode 100644 test/files/pos/t1196/J.java create mode 100644 test/files/pos/t1196/S.scala create mode 100644 test/files/pos/t1197/J.java create mode 100644 test/files/pos/t1197/S.scala create mode 100644 test/files/pos/t1203/J.java create mode 100644 test/files/pos/t1203/S.scala create mode 100644 test/files/pos/t1230/J.java create mode 100644 test/files/pos/t1230/S.scala create mode 100644 test/files/pos/t1231/J.java create mode 100644 test/files/pos/t1231/S.scala create mode 100755 test/files/pos/t1232/J.java create mode 100755 test/files/pos/t1232/J2.java create mode 100755 test/files/pos/t1232/S.scala create mode 100644 test/files/pos/t1235/Test.java create mode 100644 test/files/pos/t1254/t1254.java create mode 100644 test/files/pos/t1263/Test.java create mode 100644 test/files/pos/t1263/test.scala create mode 100644 test/files/pos/t1711/Seq.scala create mode 100644 test/files/pos/t1711/Test.java delete mode 100644 test/files/pos5/chang/Outer.java delete mode 100644 test/files/pos5/chang/Test.scala delete mode 100644 test/files/pos5/ilya/J.java delete mode 100644 test/files/pos5/ilya/S.scala delete mode 100644 test/files/pos5/ilya2/A.scala delete mode 100644 test/files/pos5/ilya2/B.java delete mode 100644 test/files/pos5/ilya2/Nullable.java delete mode 100644 test/files/pos5/signatures/Test.java delete mode 100644 test/files/pos5/signatures/sig.scala delete mode 100644 test/files/pos5/t0695/JavaClass.java delete mode 100644 test/files/pos5/t0695/Test.scala delete mode 100644 test/files/pos5/t1101/J.java delete mode 100644 test/files/pos5/t1101/S.scala delete mode 100644 test/files/pos5/t1102/J.java delete mode 100644 test/files/pos5/t1102/S.scala delete mode 100644 test/files/pos5/t1150/J.java delete mode 100644 test/files/pos5/t1150/S.scala delete mode 100644 test/files/pos5/t1152/J.java delete mode 100644 test/files/pos5/t1152/S.scala delete mode 100644 test/files/pos5/t1176/J.java delete mode 100644 test/files/pos5/t1176/S.scala delete mode 100644 test/files/pos5/t1186/t1186.java delete mode 100644 test/files/pos5/t1196/J.java delete mode 100644 test/files/pos5/t1196/S.scala delete mode 100644 test/files/pos5/t1197/J.java delete mode 100644 test/files/pos5/t1197/S.scala delete mode 100644 test/files/pos5/t1203/J.java delete mode 100644 test/files/pos5/t1203/S.scala delete mode 100644 test/files/pos5/t1230/J.java delete mode 100644 test/files/pos5/t1230/S.scala delete mode 100644 test/files/pos5/t1231/J.java delete mode 100644 test/files/pos5/t1231/S.scala delete mode 100755 test/files/pos5/t1232/J.java delete mode 100755 test/files/pos5/t1232/J2.java delete mode 100755 test/files/pos5/t1232/S.scala delete mode 100644 test/files/pos5/t1235/Test.java delete mode 100644 test/files/pos5/t1254/t1254.java delete mode 100644 test/files/pos5/t1263/Test.java delete mode 100644 test/files/pos5/t1263/test.scala delete mode 100644 test/files/pos5/t1711/Seq.scala delete mode 100644 test/files/pos5/t1711/Test.java (limited to 'test/files') diff --git a/test/files/jvm/NestedAnnotations.java b/test/files/jvm/NestedAnnotations.java new file mode 100644 index 0000000000..8f2327dcce --- /dev/null +++ b/test/files/jvm/NestedAnnotations.java @@ -0,0 +1,25 @@ +package test; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +public class NestedAnnotations { + + @OuterAnno(inner=@InnerAnno(name="inner")) + String field; + + @Target({FIELD}) + @Retention(RUNTIME) + public static @interface InnerAnno { + String name(); + } + + @Target({FIELD}) + @Retention(RUNTIME) + public static @interface OuterAnno { + InnerAnno inner(); + } +} diff --git a/test/files/jvm/OuterEnum.java b/test/files/jvm/OuterEnum.java new file mode 100644 index 0000000000..75d3f34223 --- /dev/null +++ b/test/files/jvm/OuterEnum.java @@ -0,0 +1,5 @@ +package enums; + +public class OuterEnum { + public enum Foo { Bar } +} diff --git a/test/files/jvm/OuterTParams.java b/test/files/jvm/OuterTParams.java new file mode 100644 index 0000000000..1d3db49fcf --- /dev/null +++ b/test/files/jvm/OuterTParams.java @@ -0,0 +1,6 @@ +public class OuterTParams { + class InnerClass { + // Cannot parse method signature: "()TA;" + public A method() { return null; } + } +} diff --git a/test/files/jvm/SourceAnnotation.java b/test/files/jvm/SourceAnnotation.java new file mode 100644 index 0000000000..047751ddfe --- /dev/null +++ b/test/files/jvm/SourceAnnotation.java @@ -0,0 +1,9 @@ +package test; + +import java.lang.annotation.*; + +@Retention(value=RetentionPolicy.RUNTIME) +public @interface SourceAnnotation { + public String value(); + public String[] mails() default { "bill.gates@bloodsuckers.com" }; +} diff --git a/test/files/jvm/annotations.check b/test/files/jvm/annotations.check new file mode 100644 index 0000000000..418301331f --- /dev/null +++ b/test/files/jvm/annotations.check @@ -0,0 +1,35 @@ +class java.rmi.RemoteException +class java.io.IOException +@java.lang.Deprecated() +@test.SourceAnnotation(mails={scala@lists.epfl.ch,scala-lounge@lists.epfl.ch}, value=http://scala-lang.org) +class Test4$Foo1 + +@test.SourceAnnotation(mails={you@bloodsuckers.com}, value=http://bloodsuckers.com) +class Test4$Foo2 + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=http://bloodsuckers.com) +class Test4$Foo3 + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/null) +private final int Test4$Foo4.x + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/null) +public int Test4$Foo4.x() + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/zero) +public int Test4$Foo5.bar() + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=primary constructor) +public Test4$Foo6(java.lang.String) + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=secondary constructor) +public Test4$Foo7() + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=constructor val) +private final int Test4$Foo8.n + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=constructor val) +public int Test4$Foo8.n() + +0 +99 diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala new file mode 100644 index 0000000000..9af2d333ba --- /dev/null +++ b/test/files/jvm/annotations.scala @@ -0,0 +1,159 @@ +object Test1 { + class Foo { + @remote + def foo: Unit = () + } + def run { + val method = classOf[Foo].getMethod("foo") + method.getExceptionTypes foreach println + } +} + +object Test2 { + import java.io.{BufferedReader,FileReader, IOException} + class Reader(fname: String) { + private val in = new BufferedReader(new FileReader(fname)) + + @throws(classOf[IOException]) + def read() = in.read() + } + def run { + val method = classOf[Reader].getMethod("read") + method.getExceptionTypes foreach println + } +} + +/* Java: +public class Main { + @Deprecated + public void foo() {} + public static void main(String[] args) throws Exception { + Method method = Class.forName("test.Main").getMethod("foo", new Class[]{}); + Annotation annotation = method.getAnnotation(Deprecated.class); + System.out.println(annotation); // @java.lang.Deprecated() + } +} +*/ +object Test3 { + import java.lang.Deprecated + class Foo { + @Deprecated + def foo: Unit = () + } + def run { + val method = classOf[Foo].getMethod("foo") + val annotation = method.getAnnotation(classOf[Deprecated]) + println(annotation) + } +} + +/* Java: +@Retention(value=RetentionPolicy.RUNTIME) +@interface Source { + public String url(); + public String mail(); +} +@Source(url="http://scala.epfl.ch", mail="scala@lists.epfl.ch") +class Foo {} +public class Main { + public static void main(String[] args) throws Exception { + Class clazz = Class.forName("test.Foo"); + Annotation[] annotations = clazz.getAnnotations(); + for (int i = 0; i < annotations.length; i++) + System.out.println(annotations[i]); + // @test.Main$Source(url=http://scala-lang.org, mail=scala@lists.epfl.ch) + } +} +*/ +object Test4 { + import test.SourceAnnotation // defined in SourceAnnotation.java + @SourceAnnotation{val value = "http://scala-lang.org", + val mails = Array("scala@lists.epfl.ch", "scala-lounge@lists.epfl.ch")} + class Foo1 + @SourceAnnotation("http://bloodsuckers.com") { val mails = Array("you@bloodsuckers.com") } + class Foo2 + @SourceAnnotation("http://bloodsuckers.com") + class Foo3 + class Foo4 { + @SourceAnnotation("file:///dev/null") + val x = 1 + } + class Foo5 { + @SourceAnnotation("file:///dev/zero") + def bar: Int = 0 + } + class Foo6 @SourceAnnotation("primary constructor")(s: String) { + // to guarantee that primary constructor annotations + // are not applied to secondary constructors + def this() = this("") + } + class Foo7(s: String) { + @SourceAnnotation("secondary constructor") + def this() = this("") + } + class Foo8(@SourceAnnotation("constructor val") val n: Int) {} + def run { + import java.lang.annotation.Annotation + import java.lang.reflect.AnnotatedElement + def printSourceAnnotations(target: AnnotatedElement) { + //print SourceAnnotation in a predefined way to insure + // against difference in the JVMs (e.g. Sun's vs IBM's) + def printSourceAnnotation(a: Annotation) { + val ann = a.asInstanceOf[SourceAnnotation] + println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") + + ", value=" + ann.value + ")") + } + val anns = target.getAnnotations() + anns foreach printSourceAnnotation + if (anns.length > 0) { + println(target) + println + } + } + printSourceAnnotations(classOf[Foo1]) + printSourceAnnotations(classOf[Foo2]) + printSourceAnnotations(classOf[Foo3]) + classOf[Foo4].getDeclaredFields foreach printSourceAnnotations + classOf[Foo4].getDeclaredMethods foreach printSourceAnnotations + classOf[Foo5].getDeclaredMethods foreach printSourceAnnotations + classOf[Foo6].getDeclaredConstructors foreach printSourceAnnotations + classOf[Foo7].getDeclaredConstructors foreach printSourceAnnotations + classOf[Foo8].getDeclaredFields foreach printSourceAnnotations + classOf[Foo8].getDeclaredMethods foreach printSourceAnnotations + } +} + +object Test5 { + import scala.reflect.BeanProperty + import java.lang.Integer + + class Count { + // we use "Integer" instead of "Int" because of Java reflection + @BeanProperty + private var count: Integer = 0 + + private val getter = + getClass().getMethod("getCount") + private val setter = + getClass().getMethod("setCount", classOf[Integer]) + + def get = getter.invoke(this).asInstanceOf[Integer].intValue + def set(n: Int) = setter.invoke(this, new Integer(n)) + } + def run { + val count = new Count + println(count.get) + count.set(99) + println(count.get) + } +} + +object Test { + def main(args: Array[String]) { + Test1.run + Test2.run + Test3.run // requires the use of -target:jvm-1.5 + Test4.run + Test5.run + } +} diff --git a/test/files/jvm/bug676.check b/test/files/jvm/bug676.check new file mode 100644 index 0000000000..5d1c9925f9 --- /dev/null +++ b/test/files/jvm/bug676.check @@ -0,0 +1 @@ +RUNTIME diff --git a/test/files/jvm/bug676.scala b/test/files/jvm/bug676.scala new file mode 100644 index 0000000000..bcd27e4e21 --- /dev/null +++ b/test/files/jvm/bug676.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + import java.lang.annotation.Retention; + val c = classOf[Retention] + val r: Retention = c.getAnnotation(c).asInstanceOf[Retention]; + Console.println(r.value) + } +} diff --git a/test/files/jvm/bug680.check b/test/files/jvm/bug680.check new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/files/jvm/bug680.scala b/test/files/jvm/bug680.scala new file mode 100644 index 0000000000..b0b0c9f7c0 --- /dev/null +++ b/test/files/jvm/bug680.scala @@ -0,0 +1,6 @@ +object Test { + def main(args:Array[String]) { + val sb = new java.lang.StringBuilder() // use Java 1.5 + sb.setLength(0) + } +} diff --git a/test/files/jvm/console.check b/test/files/jvm/console.check new file mode 100644 index 0000000000..ef7c169844 --- /dev/null +++ b/test/files/jvm/console.check @@ -0,0 +1,3 @@ +true11.0.. +1 +Argument nr. 1 has value 3.33 diff --git a/test/files/jvm/console.scala b/test/files/jvm/console.scala new file mode 100644 index 0000000000..b07765675c --- /dev/null +++ b/test/files/jvm/console.scala @@ -0,0 +1,14 @@ + +/** Test scala.Console functionality. */ +object Test extends Application { + + import Console._ + print(true) + print(1) + print(1.0) + flush + println("..") + println(1) + printf("Argument nr. %d has value %1.2f\n", + 1, 10.0/3) +} diff --git a/test/files/jvm/genericNest.scala b/test/files/jvm/genericNest.scala new file mode 100644 index 0000000000..c1b0210117 --- /dev/null +++ b/test/files/jvm/genericNest.scala @@ -0,0 +1,13 @@ +/** found in genericNest.jar, compiled from OuterTParams.java */ +import nestpkg._; + +// bug #695 +object ForceParse extends OuterTParams[AnyRef] { + // Force import of HarderToParse.InnerClass, + // which has confusing method signature. + var field: InnerClass = null +} + +object Test extends Application { + ForceParse +} diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check new file mode 100644 index 0000000000..86d6adbbec --- /dev/null +++ b/test/files/jvm/interpreter.check @@ -0,0 +1,218 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> +scala> +scala> res0: Int = 7 + +scala> | | | | gcd: (Int,Int)Int + +scala> five: Int = 5 + +scala> x: Int = 1 + +scala> x: Int = 2 + +scala> three: Int = 3 + +scala> defined type alias anotherint + +scala> four: anotherint = 4 + +scala> :5: error: type mismatch; + found : java.lang.String("hello") + required: anotherint + val bogus: anotherint = "hello" + ^ + +scala> defined trait PointlessTrait + +scala> x: Int = 2 +y: Int = 3 + +scala> hello + +scala> +scala> +scala> t1513: Array[Null] = Array(null) + +scala> +scala> atom: scala.xml.Atom[Unit] = () + +scala> +scala> defined class S + +scala> fish: S = fish + +scala> +scala> arr: Array[java.lang.String] = Array(What's, up, doc?) + +scala> +scala> arrInt: Any = Array(1, 2, 3) + +scala> +scala> arrArrInt: Any = Array(Array(1, 2), Array(3, 4)) + +scala> +scala> +scala> defined class Foo + +scala> defined class Bar + +scala> foo2bar: (Foo)Bar + +scala> bar: Bar = Bar(3) + +scala> +scala> +scala> import bar._ + +scala> m: Int = 3 + +scala> +scala> +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> one: Int = 1 + +scala> +scala> +scala> x1: Int = 1 + +scala> x2: Int = 1 + +scala> x3: Int = 1 + +scala> x4: Int = 1 + +scala> x5: Int = 1 + +scala> x6: Int = 1 + +scala> x7: Int = 1 + +scala> x8: Int = 1 + +scala> x9: Int = 1 + +scala> x10: Int = 1 + +scala> x11: Int = 1 + +scala> x12: Int = 1 + +scala> x13: Int = 1 + +scala> x14: Int = 1 + +scala> x15: Int = 1 + +scala> x16: Int = 1 + +scala> x17: Int = 1 + +scala> x18: Int = 1 + +scala> x19: Int = 1 + +scala> x20: Int = 1 + +scala> +scala> two: Int = 2 + +scala> +scala> +scala> +scala> +scala> :1: error: '=' expected but '=>' found. + def x => y => z + ^ + +scala> :1: error: expected start of definition + [1,2,3] + ^ + +scala> +scala> +scala> +scala> | | | | res3: scala.xml.Elem = + + + +scala> +scala> +scala> | | | | +scala> +scala> +scala> +scala> | | | res4: java.lang.String = + + hello + there + + +scala> +scala> | | You typed two blank lines. Starting a new command. + +scala> +scala> match: Int + +scala> x: Int = 1 + +scala> +scala> +scala> defined class Exp +defined class Fact +defined class Term + +scala> | | :15: warning: match is not exhaustive! +missing combination Term + + def f(e: Exp) = e match { // non-exhaustive warning here + ^ +f: (Exp)Int + +scala> +scala> +plusOne: (Int)Int +res0: Int = 6 +res0: java.lang.String = after reset +:5: error: not found: value plusOne + plusOne(5) // should be undefined now + ^ diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala new file mode 100644 index 0000000000..21c88734e0 --- /dev/null +++ b/test/files/jvm/interpreter.scala @@ -0,0 +1,179 @@ +import scala.tools.nsc._ +import java.io.{BufferedReader, StringReader, PrintWriter, + Writer, OutputStreamWriter} + +object Test { + val testCodeString = +// basics +3+4 +def gcd(x: Int, y: Int): Int = {{ + if (x == 0) y + else if (y == 0) x + else gcd(y%x, x) +}} +val five = gcd(15,35) +var x = 1 +x = 2 +val three = x+1 +type anotherint = Int +val four: anotherint = 4 +val bogus: anotherint = "hello" +trait PointlessTrait +val (x,y) = (2,3) +println("hello") + +// ticket #1513 +val t1513 = Array(null) +// ambiguous toString problem from #547 +val atom = new scala.xml.Atom() +// overriding toString problem from #1404 +class S(override val toString : String) +val fish = new S("fish") +// Test that arrays pretty print nicely. +val arr = Array("What's", "up", "doc?") +// Test that arrays pretty print nicely, even when we give them type Any +val arrInt : Any = Array(1,2,3) +// Test that nested arrays are pretty-printed correctly +val arrArrInt : Any = Array(Array(1, 2), Array(3, 4)) + +// implicit conversions +case class Foo(n: Int) +case class Bar(n: Int) +implicit def foo2bar(foo: Foo) = Bar(foo.n) +val bar: Bar = Foo(3) + +// importing from a previous result +import bar._ +val m = n + +// stressing the imports mechanism +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 +val one = 1 + + +val x1 = 1 +val x2 = 1 +val x3 = 1 +val x4 = 1 +val x5 = 1 +val x6 = 1 +val x7 = 1 +val x8 = 1 +val x9 = 1 +val x10 = 1 +val x11 = 1 +val x12 = 1 +val x13 = 1 +val x14 = 1 +val x15 = 1 +val x16 = 1 +val x17 = 1 +val x18 = 1 +val x19 = 1 +val x20 = 1 + +val two = one + x5 + + +// interior syntax errors should *not* go into multi-line input mode. +// both of the following should abort immediately: +def x => y => z +[1,2,3] + + +// multi-line XML +<a> +<b + c="c" + d="dd" +/></a> + + +/* + /* + multi-line comment + */ +*/ + + +// multi-line string +""" +hello +there +""" + +(1 + // give up early by typing two blank lines + + +// defining and using quoted names should work (ticket #323) +def `match` = 1 +val x = `match` + +// multiple classes defined on one line +sealed class Exp; class Fact extends Exp; class Term extends Exp +def f(e: Exp) = e match {{ // non-exhaustive warning here + case _:Fact => 3 +}} + +.text + + /** A writer that skips the first line of text. The first + * line of interpreter output is skipped because it includes + * a version number. */ + class Skip1Writer(writer: Writer) extends Writer { + var seenNL = false + + def write(cbuf: Array[Char], off: Int, len: Int) { + if (seenNL) + writer.write(cbuf, off, len) + else { + val slice : Array[Char] = cbuf.slice(off, off+len) + val i = slice.indexOf('\n') + if (i >= 0) { + seenNL = true + writer.write(slice, i+1, slice.length-(i+1)) + } else { + // skip it + } + } + } + + def close() { writer.close() } + def flush() { writer.flush() } + } + + + def main(args: Array[String]) { + val input = new BufferedReader(new StringReader(testCodeString)) + val output = new PrintWriter( + new Skip1Writer(new OutputStreamWriter(Console.out))) + val repl = new InterpreterLoop(input, output) + repl.main(new Settings) + println() + + val interp = new Interpreter(new Settings) + interp.interpret("def plusOne(x: Int) = x + 1") + interp.interpret("plusOne(5)") + interp.reset() + interp.interpret("\"after reset\"") + interp.interpret("plusOne(5) // should be undefined now") + } +} diff --git a/test/files/jvm/mkAnnotationsJar.sh b/test/files/jvm/mkAnnotationsJar.sh new file mode 100755 index 0000000000..0cd5e631a7 --- /dev/null +++ b/test/files/jvm/mkAnnotationsJar.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +############################################################################## +# Author : Nikolay Mihaylov +# Revision: $Id$ +############################################################################## + +############################################################################## +# variables + +OBJDIR=./classes + +if [ -z "${JAVA_HOME}" ]; then + echo "environment variable JAVA_HOME is undefined." + exit +fi + +JAVAC=${JAVA_HOME}/bin/javac +JAVAC_OPTIONS="-source 1.5 -target 1.5" + +JAR=${JAVA_HOME}/bin/jar + +############################################################################## +# commands + +mkdir -p ${OBJDIR} +${JAVAC} ${JAVAC_OPTIONS} -d ${OBJDIR} SourceAnnotation.java NestedAnnotations.java +${JAR} cf ../lib/annotations.jar -C ${OBJDIR} . +rm -rf ${OBJDIR} diff --git a/test/files/jvm/outerEnum.check b/test/files/jvm/outerEnum.check new file mode 100644 index 0000000000..ebd7525b33 --- /dev/null +++ b/test/files/jvm/outerEnum.check @@ -0,0 +1 @@ +Bar diff --git a/test/files/jvm/outerEnum.scala b/test/files/jvm/outerEnum.scala new file mode 100644 index 0000000000..18794b7dbe --- /dev/null +++ b/test/files/jvm/outerEnum.scala @@ -0,0 +1,9 @@ +import enums._ + +object Test extends Application { + def foo { + val res: OuterEnum.Foo = OuterEnum.Foo.Bar + println(res) + } + foo +} diff --git a/test/files/jvm/stringbuilder.scala b/test/files/jvm/stringbuilder.scala new file mode 100644 index 0000000000..cbbfa022b0 --- /dev/null +++ b/test/files/jvm/stringbuilder.scala @@ -0,0 +1,100 @@ +/* $Id$ */ + +import testing.SUnit._ + +/** Test the Scala implementation of class scala.StringBuilder. + * + * @author Stephane Micheloud + */ +object Test extends TestConsoleMain { + def suite = new TestSuite( + Test1, //ctor, reverse + Test2, //append + Test3, //insert + Test4 //indexOf, lastIndexOf + ) +} + +object Test1 extends TestCase("ctor") with Assert { + override def enableStackTrace = false + override def runTest { + val j0 = new java.lang.StringBuilder("abc") // Java 1.5+ + val s0 = new StringBuilder("abc") + assertEquals("s0 equals j0", false, s0 equals j0) + assertEquals("s0.toString equals j0.toString", true, s0.toString equals j0.toString) + + val str = """ +Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages. It is also fully interoperable with Java.""" + val j1 = new java.lang.StringBuilder(100) append str + val s1 = new java.lang.StringBuilder(100) append str + assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString) + + val j2 = j0 reverse + val s2 = s0 reverse; + //println("j2="+j2+", s2="+s2)//debug + assertEquals("s2.toString equals j2.toString", true, s2.toString equals j2.toString) + + val j3 = j2; j3 setCharAt (0, j3 charAt 2) + val s3 = s2; s3(0) = s3(2) + //println("j3="+j3+", s3="+s3)//debug + assertEquals("s3.toString equals j3.toString", true, s3.toString equals j3.toString) + } +} + +object Test2 extends TestCase("append") with Assert { + override def enableStackTrace = false + override def runTest { + val j0 = new java.lang.StringBuilder("abc") // Java 1.5+ + val s0 = new StringBuilder("abc") + + j0 append true append (1.toByte) append 'a' append 9 append -1L append 1.2e-10f append -2.1e+100d + s0 append true append (1.toByte) append 'a' append 9 append -1L append 1.2e-10f append -2.1e+100d + + assertEquals("s0.toString equals j0.toString", true, s0.toString equals j0.toString) + + val j1 = new java.lang.StringBuilder // Java 1.5+ + val s1 = new StringBuilder + j1 append "###" append Array('0', '1', '2') append "xyz".subSequence(0, 3) + s1 append "###" append Array('0', '1', '2') append List('x', 'y', 'z') + assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString) + } +} + +object Test3 extends TestCase("insert") with Assert { + override def enableStackTrace = false + override def runTest { + val j0 = new java.lang.StringBuilder("abc") // Java 1.5+ + val s0 = new StringBuilder("abc") + + j0 insert (0, true) insert (0, 1.toByte) insert (0, 'a') insert (0, 88.toShort) insert (0, 9) insert (0, -1L) + s0 insert (0, true) insert (0, 1.toByte) insert (0, 'a') insert (0, 88.toShort) insert (0, 9) insert (0, -1L) + //println("j0="+j0+", s0="+s0)//debug + assertEquals("s0.toString equals j0.toString", true, s0.toString equals j0.toString) + + val j1 = new java.lang.StringBuilder // Java 1.5+ + val s1 = new StringBuilder + j1 insert (0, "###") insert (0, Array('0', '1', '2')) insert (0, "xyz".subSequence(0, 3)) + s1 insert (0, "###") insert (0, Array('0', '1', '2')) insert (0, List('x', 'y', 'z')) + //println("j1="+j1+", s1="+s1)//debug + assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString) + + } +} + +object Test4 extends TestCase("indefOf") with Assert { + override def enableStackTrace = false + override def runTest { + val j0 = new java.lang.StringBuilder("abc") // Java 1.5+ + val s0 = new StringBuilder("abc") + + val j1 = j0 indexOf("c") + val s1 = s0 indexOf("c") + //println("j1="+j1+", s1="+s1)//debug + assertEquals("s1 == j1", true, s1 == j1) + + val j2 = j0 append "123abc" lastIndexOf("c") + val s2 = s0 append "123abc" lastIndexOf("c") + //println("j2="+j2+", s2="+s2)//debug + assertEquals("s2 == j2", true, s2 == j2) + } +} diff --git a/test/files/jvm/sync-var.check b/test/files/jvm/sync-var.check new file mode 100644 index 0000000000..e77aa319a5 --- /dev/null +++ b/test/files/jvm/sync-var.check @@ -0,0 +1 @@ +50005000 50005000 true diff --git a/test/files/jvm/sync-var.scala b/test/files/jvm/sync-var.scala new file mode 100644 index 0000000000..aa6ae9fa34 --- /dev/null +++ b/test/files/jvm/sync-var.scala @@ -0,0 +1,53 @@ +import java.util.concurrent._ +import java.util.concurrent.atomic._ + +object Test { def main(args: Array[String]) { + +val n = 10000 +val i = new AtomicInteger(n) +val j = new AtomicInteger(n) +val sum = new AtomicInteger + +val q = new scala.concurrent.SyncVar[Int] + +val producers = (1 to 3).force map { z => new Thread { + override def run() { + var again = true + while (again) { + val x = i.getAndDecrement() + if (x > 0) + q put x + else + again = false + } + } +} } + +val summers = (1 to 7).force map { z => new Thread { + override def run() { + val x = j.decrementAndGet() + if (x >= 0) { + sum addAndGet q.take() + } + if (x > 0) { + run() + } else { + // done + } + } +} } + +summers foreach { _.start() } +producers foreach { _.start() } + +summers foreach { _.join() } + +val got = sum.get +val expected = (n + 1) * n / 2 +println(got + " " + expected + " " + (got == expected)) + +producers foreach { _.join() } + +} } + +// vim: set ts=2 sw=2 et: diff --git a/test/files/jvm/t0014.check b/test/files/jvm/t0014.check new file mode 100644 index 0000000000..bece7db7af --- /dev/null +++ b/test/files/jvm/t0014.check @@ -0,0 +1 @@ +test.NestedAnnotations diff --git a/test/files/jvm/t0014.scala b/test/files/jvm/t0014.scala new file mode 100644 index 0000000000..a1948702dc --- /dev/null +++ b/test/files/jvm/t0014.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]) { + println(classOf[test.NestedAnnotations].getName) + } +} diff --git a/test/files/jvm/t1461.scala b/test/files/jvm/t1461.scala new file mode 100644 index 0000000000..f0e3cea6cd --- /dev/null +++ b/test/files/jvm/t1461.scala @@ -0,0 +1,18 @@ + +object Test { + def main(args: Array[String]) { + val jl = classOf[Foo].getMethod("jl", classOf[Baz[_]]) + jl.getGenericParameterTypes // works fine + + val l = classOf[Foo].getMethod("l", classOf[Baz[_]]) + // By debugger inspection l.signature is (Ltest/Baz;)V + l.getGenericParameterTypes // throws GenericSignatureFormatError + } +} + +class Baz[T] + +class Foo { + def l(b: Baz[Long]) { } + def jl(b: Baz[java.lang.Long]) { } +} diff --git a/test/files/jvm/t1464.check b/test/files/jvm/t1464.check new file mode 100644 index 0000000000..c508d5366f --- /dev/null +++ b/test/files/jvm/t1464.check @@ -0,0 +1 @@ +false diff --git a/test/files/jvm/t1464/MyTrait.scala b/test/files/jvm/t1464/MyTrait.scala new file mode 100644 index 0000000000..0b8ccc412b --- /dev/null +++ b/test/files/jvm/t1464/MyTrait.scala @@ -0,0 +1,5 @@ +trait MyTrait { + type K + def findChildByClass[T <: K with MyTrait]: Unit + +} diff --git a/test/files/jvm/t1464/Test.java b/test/files/jvm/t1464/Test.java new file mode 100644 index 0000000000..235848b1df --- /dev/null +++ b/test/files/jvm/t1464/Test.java @@ -0,0 +1,6 @@ +public class Test { + public static void main(String[] args) { + Object o = new Object(); + System.out.println(o instanceof MyTrait); + } +} diff --git a/test/files/jvm/throws-annot.check b/test/files/jvm/throws-annot.check new file mode 100644 index 0000000000..a0ed82b106 --- /dev/null +++ b/test/files/jvm/throws-annot.check @@ -0,0 +1,21 @@ +read throws: class java.io.IOException +read annotations: +readWith2 throws: class java.lang.ClassCastException, class java.io.IOException +readWith2 annotations: +readMixed throws: class java.io.IOException, class java.lang.NullPointerException +readMixed annotations: @java.lang.Deprecated() +readMixed2 throws: class java.io.IOException, class java.lang.NullPointerException +readMixed2 annotations: @java.lang.Deprecated() +readNoEx throws: +readNoEx annotations: @java.lang.Deprecated() +Testing mirror class +read throws: class java.io.IOException +read annotations: +readWith2 throws: class java.lang.ClassCastException, class java.io.IOException +readWith2 annotations: +readMixed throws: class java.io.IOException, class java.lang.NullPointerException +readMixed annotations: @java.lang.Deprecated() +readMixed2 throws: class java.io.IOException, class java.lang.NullPointerException +readMixed2 annotations: @java.lang.Deprecated() +readNoEx throws: +readNoEx annotations: @java.lang.Deprecated() diff --git a/test/files/jvm/throws-annot.scala b/test/files/jvm/throws-annot.scala new file mode 100644 index 0000000000..90b58b9976 --- /dev/null +++ b/test/files/jvm/throws-annot.scala @@ -0,0 +1,74 @@ +/** Test the @throws annotation */ +import java.io.IOException + +object TestThrows { + + abstract class Foo { + + @throws(classOf[IOException]) + def read(): Int + + @throws(classOf[ClassCastException]) + @throws(classOf[IOException]) + def readWith2(): Int + + @throws(classOf[IOException]) + @Deprecated + @throws(classOf[NullPointerException]) + def readMixed(): Int + + @Deprecated + @throws(classOf[IOException]) + @throws(classOf[NullPointerException]) + def readMixed2(): Int + + @Deprecated + def readNoEx(): Int + } + + def checkMethod(cls: Class[_], name: String) { + val method = cls.getMethod(name) + println(name + " throws: " + method.getExceptionTypes.mkString("", ", ", "")) + println(name + " annotations: " + method.getDeclaredAnnotations.mkString("", ", ", "")) + } + + def run(cls: Class[_]) { + checkMethod(cls, "read") + checkMethod(cls, "readWith2") + checkMethod(cls, "readMixed") + checkMethod(cls, "readMixed2") + checkMethod(cls, "readNoEx") + } +} + +/** Test the top-level mirror that is has the annotations. */ +object TL { + + @throws(classOf[IOException]) + def read(): Int = 0 + + @throws(classOf[ClassCastException]) + @throws(classOf[IOException]) + def readWith2(): Int = 0 + + @throws(classOf[IOException]) + @Deprecated + @throws(classOf[NullPointerException]) + def readMixed(): Int = 0 + + @Deprecated + @throws(classOf[IOException]) + @throws(classOf[NullPointerException]) + def readMixed2(): Int = 0 + + @Deprecated + def readNoEx(): Int = 0 +} + +object Test { + def main(args: Array[String]) { + TestThrows.run(classOf[TestThrows.Foo]) + println("Testing mirror class") + TestThrows.run(Class.forName("TL")) + } +} diff --git a/test/files/jvm/typerep.check b/test/files/jvm/typerep.check old mode 100644 new mode 100755 index ff98348304..ca93180946 --- a/test/files/jvm/typerep.check +++ b/test/files/jvm/typerep.check @@ -9,10 +9,12 @@ Float Double String Unit +Class[Int] Some[Int] Some[Int] Some[Some[Int]] +Some[List[Int]] None None diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala old mode 100644 new mode 100755 index 47bd335d32..fc94817adf --- a/test/files/jvm/typerep.scala +++ b/test/files/jvm/typerep.scala @@ -49,7 +49,7 @@ object testPrimitives { println(getType(0.0d)) println(getType("abc")) println(getType(())) // Unit -// println(getType(classOf[Int])) // Class + println(getType(classOf[Int])) // Class println } @@ -58,6 +58,8 @@ object testOptions { val x: Option[Int] = Some(2) println(getType(x)) println(getType(Some(Some(3)))) + println(getType(Some(List(3)))) + //println(getType(Some(None: List[Int]))) // error: no implicit argument matching parameter type TypeRep[object None] was foun println(getType(None: Option[Int])) val y: Option[Int] = None println(getType(y)) @@ -156,7 +158,7 @@ object TypeRep { def getType[A](x: Option[A])(implicit rep: TypeRep[A]): TypeRep[Option[A]] = (x match { case Some(v) => SomeRep(rep) - case None => NoneRep // or NoneRep(rep) + case None => NoneRep }).asInstanceOf[TypeRep[Option[A]]] def getType[A](x: List[A])(implicit rep: TypeRep[A]): TypeRep[List[A]] = (x match { @@ -174,12 +176,14 @@ object TypeRep { implicit def doubleRep: TypeRep[Double] = DoubleRep implicit def unitRep: TypeRep[Unit] = UnitRep -// implicit def classRep: TypeRep[Class] = ClassRep implicit def stringRep: TypeRep[String] = StringRep - implicit def noneRep: TypeRep[Option[Nothing]] = NoneRep[Nothing](NothingRep.asInstanceOf[TypeRep[Nothing]]) + //implicit def noneRep: TypeRep[None.type] = NoneRep//[Nothing](NothingRep.asInstanceOf[TypeRep[Nothing]]) implicit def anyRep: TypeRep[Any] = AnyRep implicit def nothingRep: TypeRep[Nothing] = NothingRep + implicit def classRep[A](implicit elemrep: TypeRep[A]): TypeRep[Class[A]] = + ClassRep(elemrep) + implicit def someRep[A](implicit elemrep: TypeRep[A]): TypeRep[Some[A]] = SomeRep(elemrep) @@ -189,9 +193,10 @@ object TypeRep { implicit def arrayRep[A](implicit elemrep: TypeRep[A]): TypeRep[Array[A]] = ArrayRep(elemrep) - implicit def tuple2Rep[A1, A2](implicit _1: TypeRep[A1], _2: TypeRep[A2]): TypeRep[Tuple2[A1, A2]] = + implicit def tuple2Rep[A1, A2](implicit _1: TypeRep[A1], _2: TypeRep[A2]): TypeRep[(A1, A2)] = Tuple2Rep(_1, _2) - implicit def tuple3Rep[A1, A2, A3](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3]): TypeRep[Tuple3[A1, A2, A3]] = + + implicit def tuple3Rep[A1, A2, A3](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3]): TypeRep[(A1, A2, A3)] = Tuple3Rep(_1, _2, _3) implicit def tuple4Rep[A1, A2, A3, A4](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4]): TypeRep[Tuple4[A1, A2, A3, A4]] = Tuple4Rep(_1, _2, _3, _4) @@ -263,7 +268,7 @@ object TypeRep { case object StringRep extends TypeRep[String] { override def toString = "String" } - case object NoneRep extends TypeRep[Option[Nothing]] { + case object NoneRep extends TypeRep[None.type] { override def toString = "None" } case object NilRep extends TypeRep[Nil.type] { @@ -276,6 +281,10 @@ object TypeRep { override def toString = "Nothing" } + @serializable + case class ClassRep[A](elemRep: TypeRep[A]) extends TypeRep[Class[A]] { + override def toString = "Class[" + elemRep + "]" + } @serializable case class SomeRep[A](elemRep: TypeRep[A]) extends TypeRep[Some[A]] { override def toString = "Some[" + elemRep + "]" @@ -296,7 +305,7 @@ object TypeRep { } @serializable - case class Tuple2Rep[A1, A2](_1: TypeRep[A1], _2: TypeRep[A2]) extends TypeRep[Tuple2[A1, A2]] { + case class Tuple2Rep[A1, A2](_1: TypeRep[A1], _2: TypeRep[A2]) extends TypeRep[(A1, A2)] { override def toString = "Tuple2[" + _1 + ", " + _2 + "]" } @serializable diff --git a/test/files/jvm5/NestedAnnotations.java b/test/files/jvm5/NestedAnnotations.java deleted file mode 100644 index 8f2327dcce..0000000000 --- a/test/files/jvm5/NestedAnnotations.java +++ /dev/null @@ -1,25 +0,0 @@ -package test; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -public class NestedAnnotations { - - @OuterAnno(inner=@InnerAnno(name="inner")) - String field; - - @Target({FIELD}) - @Retention(RUNTIME) - public static @interface InnerAnno { - String name(); - } - - @Target({FIELD}) - @Retention(RUNTIME) - public static @interface OuterAnno { - InnerAnno inner(); - } -} diff --git a/test/files/jvm5/OuterEnum.java b/test/files/jvm5/OuterEnum.java deleted file mode 100644 index 75d3f34223..0000000000 --- a/test/files/jvm5/OuterEnum.java +++ /dev/null @@ -1,5 +0,0 @@ -package enums; - -public class OuterEnum { - public enum Foo { Bar } -} diff --git a/test/files/jvm5/OuterTParams.java b/test/files/jvm5/OuterTParams.java deleted file mode 100644 index 1d3db49fcf..0000000000 --- a/test/files/jvm5/OuterTParams.java +++ /dev/null @@ -1,6 +0,0 @@ -public class OuterTParams { - class InnerClass { - // Cannot parse method signature: "()TA;" - public A method() { return null; } - } -} diff --git a/test/files/jvm5/SourceAnnotation.java b/test/files/jvm5/SourceAnnotation.java deleted file mode 100644 index 047751ddfe..0000000000 --- a/test/files/jvm5/SourceAnnotation.java +++ /dev/null @@ -1,9 +0,0 @@ -package test; - -import java.lang.annotation.*; - -@Retention(value=RetentionPolicy.RUNTIME) -public @interface SourceAnnotation { - public String value(); - public String[] mails() default { "bill.gates@bloodsuckers.com" }; -} diff --git a/test/files/jvm5/annotations.check b/test/files/jvm5/annotations.check deleted file mode 100644 index 418301331f..0000000000 --- a/test/files/jvm5/annotations.check +++ /dev/null @@ -1,35 +0,0 @@ -class java.rmi.RemoteException -class java.io.IOException -@java.lang.Deprecated() -@test.SourceAnnotation(mails={scala@lists.epfl.ch,scala-lounge@lists.epfl.ch}, value=http://scala-lang.org) -class Test4$Foo1 - -@test.SourceAnnotation(mails={you@bloodsuckers.com}, value=http://bloodsuckers.com) -class Test4$Foo2 - -@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=http://bloodsuckers.com) -class Test4$Foo3 - -@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/null) -private final int Test4$Foo4.x - -@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/null) -public int Test4$Foo4.x() - -@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/zero) -public int Test4$Foo5.bar() - -@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=primary constructor) -public Test4$Foo6(java.lang.String) - -@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=secondary constructor) -public Test4$Foo7() - -@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=constructor val) -private final int Test4$Foo8.n - -@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=constructor val) -public int Test4$Foo8.n() - -0 -99 diff --git a/test/files/jvm5/annotations.scala b/test/files/jvm5/annotations.scala deleted file mode 100644 index 9af2d333ba..0000000000 --- a/test/files/jvm5/annotations.scala +++ /dev/null @@ -1,159 +0,0 @@ -object Test1 { - class Foo { - @remote - def foo: Unit = () - } - def run { - val method = classOf[Foo].getMethod("foo") - method.getExceptionTypes foreach println - } -} - -object Test2 { - import java.io.{BufferedReader,FileReader, IOException} - class Reader(fname: String) { - private val in = new BufferedReader(new FileReader(fname)) - - @throws(classOf[IOException]) - def read() = in.read() - } - def run { - val method = classOf[Reader].getMethod("read") - method.getExceptionTypes foreach println - } -} - -/* Java: -public class Main { - @Deprecated - public void foo() {} - public static void main(String[] args) throws Exception { - Method method = Class.forName("test.Main").getMethod("foo", new Class[]{}); - Annotation annotation = method.getAnnotation(Deprecated.class); - System.out.println(annotation); // @java.lang.Deprecated() - } -} -*/ -object Test3 { - import java.lang.Deprecated - class Foo { - @Deprecated - def foo: Unit = () - } - def run { - val method = classOf[Foo].getMethod("foo") - val annotation = method.getAnnotation(classOf[Deprecated]) - println(annotation) - } -} - -/* Java: -@Retention(value=RetentionPolicy.RUNTIME) -@interface Source { - public String url(); - public String mail(); -} -@Source(url="http://scala.epfl.ch", mail="scala@lists.epfl.ch") -class Foo {} -public class Main { - public static void main(String[] args) throws Exception { - Class clazz = Class.forName("test.Foo"); - Annotation[] annotations = clazz.getAnnotations(); - for (int i = 0; i < annotations.length; i++) - System.out.println(annotations[i]); - // @test.Main$Source(url=http://scala-lang.org, mail=scala@lists.epfl.ch) - } -} -*/ -object Test4 { - import test.SourceAnnotation // defined in SourceAnnotation.java - @SourceAnnotation{val value = "http://scala-lang.org", - val mails = Array("scala@lists.epfl.ch", "scala-lounge@lists.epfl.ch")} - class Foo1 - @SourceAnnotation("http://bloodsuckers.com") { val mails = Array("you@bloodsuckers.com") } - class Foo2 - @SourceAnnotation("http://bloodsuckers.com") - class Foo3 - class Foo4 { - @SourceAnnotation("file:///dev/null") - val x = 1 - } - class Foo5 { - @SourceAnnotation("file:///dev/zero") - def bar: Int = 0 - } - class Foo6 @SourceAnnotation("primary constructor")(s: String) { - // to guarantee that primary constructor annotations - // are not applied to secondary constructors - def this() = this("") - } - class Foo7(s: String) { - @SourceAnnotation("secondary constructor") - def this() = this("") - } - class Foo8(@SourceAnnotation("constructor val") val n: Int) {} - def run { - import java.lang.annotation.Annotation - import java.lang.reflect.AnnotatedElement - def printSourceAnnotations(target: AnnotatedElement) { - //print SourceAnnotation in a predefined way to insure - // against difference in the JVMs (e.g. Sun's vs IBM's) - def printSourceAnnotation(a: Annotation) { - val ann = a.asInstanceOf[SourceAnnotation] - println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") + - ", value=" + ann.value + ")") - } - val anns = target.getAnnotations() - anns foreach printSourceAnnotation - if (anns.length > 0) { - println(target) - println - } - } - printSourceAnnotations(classOf[Foo1]) - printSourceAnnotations(classOf[Foo2]) - printSourceAnnotations(classOf[Foo3]) - classOf[Foo4].getDeclaredFields foreach printSourceAnnotations - classOf[Foo4].getDeclaredMethods foreach printSourceAnnotations - classOf[Foo5].getDeclaredMethods foreach printSourceAnnotations - classOf[Foo6].getDeclaredConstructors foreach printSourceAnnotations - classOf[Foo7].getDeclaredConstructors foreach printSourceAnnotations - classOf[Foo8].getDeclaredFields foreach printSourceAnnotations - classOf[Foo8].getDeclaredMethods foreach printSourceAnnotations - } -} - -object Test5 { - import scala.reflect.BeanProperty - import java.lang.Integer - - class Count { - // we use "Integer" instead of "Int" because of Java reflection - @BeanProperty - private var count: Integer = 0 - - private val getter = - getClass().getMethod("getCount") - private val setter = - getClass().getMethod("setCount", classOf[Integer]) - - def get = getter.invoke(this).asInstanceOf[Integer].intValue - def set(n: Int) = setter.invoke(this, new Integer(n)) - } - def run { - val count = new Count - println(count.get) - count.set(99) - println(count.get) - } -} - -object Test { - def main(args: Array[String]) { - Test1.run - Test2.run - Test3.run // requires the use of -target:jvm-1.5 - Test4.run - Test5.run - } -} diff --git a/test/files/jvm5/bug676.check b/test/files/jvm5/bug676.check deleted file mode 100644 index 5d1c9925f9..0000000000 --- a/test/files/jvm5/bug676.check +++ /dev/null @@ -1 +0,0 @@ -RUNTIME diff --git a/test/files/jvm5/bug676.scala b/test/files/jvm5/bug676.scala deleted file mode 100644 index bcd27e4e21..0000000000 --- a/test/files/jvm5/bug676.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - import java.lang.annotation.Retention; - val c = classOf[Retention] - val r: Retention = c.getAnnotation(c).asInstanceOf[Retention]; - Console.println(r.value) - } -} diff --git a/test/files/jvm5/bug680.check b/test/files/jvm5/bug680.check deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/files/jvm5/bug680.scala b/test/files/jvm5/bug680.scala deleted file mode 100644 index b0b0c9f7c0..0000000000 --- a/test/files/jvm5/bug680.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test { - def main(args:Array[String]) { - val sb = new java.lang.StringBuilder() // use Java 1.5 - sb.setLength(0) - } -} diff --git a/test/files/jvm5/console.check b/test/files/jvm5/console.check deleted file mode 100644 index ef7c169844..0000000000 --- a/test/files/jvm5/console.check +++ /dev/null @@ -1,3 +0,0 @@ -true11.0.. -1 -Argument nr. 1 has value 3.33 diff --git a/test/files/jvm5/console.scala b/test/files/jvm5/console.scala deleted file mode 100644 index b07765675c..0000000000 --- a/test/files/jvm5/console.scala +++ /dev/null @@ -1,14 +0,0 @@ - -/** Test scala.Console functionality. */ -object Test extends Application { - - import Console._ - print(true) - print(1) - print(1.0) - flush - println("..") - println(1) - printf("Argument nr. %d has value %1.2f\n", - 1, 10.0/3) -} diff --git a/test/files/jvm5/genericNest.scala b/test/files/jvm5/genericNest.scala deleted file mode 100644 index c1b0210117..0000000000 --- a/test/files/jvm5/genericNest.scala +++ /dev/null @@ -1,13 +0,0 @@ -/** found in genericNest.jar, compiled from OuterTParams.java */ -import nestpkg._; - -// bug #695 -object ForceParse extends OuterTParams[AnyRef] { - // Force import of HarderToParse.InnerClass, - // which has confusing method signature. - var field: InnerClass = null -} - -object Test extends Application { - ForceParse -} diff --git a/test/files/jvm5/interpreter.check b/test/files/jvm5/interpreter.check deleted file mode 100644 index 86d6adbbec..0000000000 --- a/test/files/jvm5/interpreter.check +++ /dev/null @@ -1,218 +0,0 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> -scala> -scala> res0: Int = 7 - -scala> | | | | gcd: (Int,Int)Int - -scala> five: Int = 5 - -scala> x: Int = 1 - -scala> x: Int = 2 - -scala> three: Int = 3 - -scala> defined type alias anotherint - -scala> four: anotherint = 4 - -scala> :5: error: type mismatch; - found : java.lang.String("hello") - required: anotherint - val bogus: anotherint = "hello" - ^ - -scala> defined trait PointlessTrait - -scala> x: Int = 2 -y: Int = 3 - -scala> hello - -scala> -scala> -scala> t1513: Array[Null] = Array(null) - -scala> -scala> atom: scala.xml.Atom[Unit] = () - -scala> -scala> defined class S - -scala> fish: S = fish - -scala> -scala> arr: Array[java.lang.String] = Array(What's, up, doc?) - -scala> -scala> arrInt: Any = Array(1, 2, 3) - -scala> -scala> arrArrInt: Any = Array(Array(1, 2), Array(3, 4)) - -scala> -scala> -scala> defined class Foo - -scala> defined class Bar - -scala> foo2bar: (Foo)Bar - -scala> bar: Bar = Bar(3) - -scala> -scala> -scala> import bar._ - -scala> m: Int = 3 - -scala> -scala> -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> one: Int = 1 - -scala> -scala> -scala> x1: Int = 1 - -scala> x2: Int = 1 - -scala> x3: Int = 1 - -scala> x4: Int = 1 - -scala> x5: Int = 1 - -scala> x6: Int = 1 - -scala> x7: Int = 1 - -scala> x8: Int = 1 - -scala> x9: Int = 1 - -scala> x10: Int = 1 - -scala> x11: Int = 1 - -scala> x12: Int = 1 - -scala> x13: Int = 1 - -scala> x14: Int = 1 - -scala> x15: Int = 1 - -scala> x16: Int = 1 - -scala> x17: Int = 1 - -scala> x18: Int = 1 - -scala> x19: Int = 1 - -scala> x20: Int = 1 - -scala> -scala> two: Int = 2 - -scala> -scala> -scala> -scala> -scala> :1: error: '=' expected but '=>' found. - def x => y => z - ^ - -scala> :1: error: expected start of definition - [1,2,3] - ^ - -scala> -scala> -scala> -scala> | | | | res3: scala.xml.Elem = - - - -scala> -scala> -scala> | | | | -scala> -scala> -scala> -scala> | | | res4: java.lang.String = - - hello - there - - -scala> -scala> | | You typed two blank lines. Starting a new command. - -scala> -scala> match: Int - -scala> x: Int = 1 - -scala> -scala> -scala> defined class Exp -defined class Fact -defined class Term - -scala> | | :15: warning: match is not exhaustive! -missing combination Term - - def f(e: Exp) = e match { // non-exhaustive warning here - ^ -f: (Exp)Int - -scala> -scala> -plusOne: (Int)Int -res0: Int = 6 -res0: java.lang.String = after reset -:5: error: not found: value plusOne - plusOne(5) // should be undefined now - ^ diff --git a/test/files/jvm5/interpreter.scala b/test/files/jvm5/interpreter.scala deleted file mode 100644 index 21c88734e0..0000000000 --- a/test/files/jvm5/interpreter.scala +++ /dev/null @@ -1,179 +0,0 @@ -import scala.tools.nsc._ -import java.io.{BufferedReader, StringReader, PrintWriter, - Writer, OutputStreamWriter} - -object Test { - val testCodeString = -// basics -3+4 -def gcd(x: Int, y: Int): Int = {{ - if (x == 0) y - else if (y == 0) x - else gcd(y%x, x) -}} -val five = gcd(15,35) -var x = 1 -x = 2 -val three = x+1 -type anotherint = Int -val four: anotherint = 4 -val bogus: anotherint = "hello" -trait PointlessTrait -val (x,y) = (2,3) -println("hello") - -// ticket #1513 -val t1513 = Array(null) -// ambiguous toString problem from #547 -val atom = new scala.xml.Atom() -// overriding toString problem from #1404 -class S(override val toString : String) -val fish = new S("fish") -// Test that arrays pretty print nicely. -val arr = Array("What's", "up", "doc?") -// Test that arrays pretty print nicely, even when we give them type Any -val arrInt : Any = Array(1,2,3) -// Test that nested arrays are pretty-printed correctly -val arrArrInt : Any = Array(Array(1, 2), Array(3, 4)) - -// implicit conversions -case class Foo(n: Int) -case class Bar(n: Int) -implicit def foo2bar(foo: Foo) = Bar(foo.n) -val bar: Bar = Foo(3) - -// importing from a previous result -import bar._ -val m = n - -// stressing the imports mechanism -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 -val one = 1 - - -val x1 = 1 -val x2 = 1 -val x3 = 1 -val x4 = 1 -val x5 = 1 -val x6 = 1 -val x7 = 1 -val x8 = 1 -val x9 = 1 -val x10 = 1 -val x11 = 1 -val x12 = 1 -val x13 = 1 -val x14 = 1 -val x15 = 1 -val x16 = 1 -val x17 = 1 -val x18 = 1 -val x19 = 1 -val x20 = 1 - -val two = one + x5 - - -// interior syntax errors should *not* go into multi-line input mode. -// both of the following should abort immediately: -def x => y => z -[1,2,3] - - -// multi-line XML -<a> -<b - c="c" - d="dd" -/></a> - - -/* - /* - multi-line comment - */ -*/ - - -// multi-line string -""" -hello -there -""" - -(1 + // give up early by typing two blank lines - - -// defining and using quoted names should work (ticket #323) -def `match` = 1 -val x = `match` - -// multiple classes defined on one line -sealed class Exp; class Fact extends Exp; class Term extends Exp -def f(e: Exp) = e match {{ // non-exhaustive warning here - case _:Fact => 3 -}} - -.text - - /** A writer that skips the first line of text. The first - * line of interpreter output is skipped because it includes - * a version number. */ - class Skip1Writer(writer: Writer) extends Writer { - var seenNL = false - - def write(cbuf: Array[Char], off: Int, len: Int) { - if (seenNL) - writer.write(cbuf, off, len) - else { - val slice : Array[Char] = cbuf.slice(off, off+len) - val i = slice.indexOf('\n') - if (i >= 0) { - seenNL = true - writer.write(slice, i+1, slice.length-(i+1)) - } else { - // skip it - } - } - } - - def close() { writer.close() } - def flush() { writer.flush() } - } - - - def main(args: Array[String]) { - val input = new BufferedReader(new StringReader(testCodeString)) - val output = new PrintWriter( - new Skip1Writer(new OutputStreamWriter(Console.out))) - val repl = new InterpreterLoop(input, output) - repl.main(new Settings) - println() - - val interp = new Interpreter(new Settings) - interp.interpret("def plusOne(x: Int) = x + 1") - interp.interpret("plusOne(5)") - interp.reset() - interp.interpret("\"after reset\"") - interp.interpret("plusOne(5) // should be undefined now") - } -} diff --git a/test/files/jvm5/mkAnnotationsJar.sh b/test/files/jvm5/mkAnnotationsJar.sh deleted file mode 100755 index 0cd5e631a7..0000000000 --- a/test/files/jvm5/mkAnnotationsJar.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -############################################################################## -# Author : Nikolay Mihaylov -# Revision: $Id$ -############################################################################## - -############################################################################## -# variables - -OBJDIR=./classes - -if [ -z "${JAVA_HOME}" ]; then - echo "environment variable JAVA_HOME is undefined." - exit -fi - -JAVAC=${JAVA_HOME}/bin/javac -JAVAC_OPTIONS="-source 1.5 -target 1.5" - -JAR=${JAVA_HOME}/bin/jar - -############################################################################## -# commands - -mkdir -p ${OBJDIR} -${JAVAC} ${JAVAC_OPTIONS} -d ${OBJDIR} SourceAnnotation.java NestedAnnotations.java -${JAR} cf ../lib/annotations.jar -C ${OBJDIR} . -rm -rf ${OBJDIR} diff --git a/test/files/jvm5/outerEnum.check b/test/files/jvm5/outerEnum.check deleted file mode 100644 index ebd7525b33..0000000000 --- a/test/files/jvm5/outerEnum.check +++ /dev/null @@ -1 +0,0 @@ -Bar diff --git a/test/files/jvm5/outerEnum.scala b/test/files/jvm5/outerEnum.scala deleted file mode 100644 index 18794b7dbe..0000000000 --- a/test/files/jvm5/outerEnum.scala +++ /dev/null @@ -1,9 +0,0 @@ -import enums._ - -object Test extends Application { - def foo { - val res: OuterEnum.Foo = OuterEnum.Foo.Bar - println(res) - } - foo -} diff --git a/test/files/jvm5/stringbuilder.scala b/test/files/jvm5/stringbuilder.scala deleted file mode 100644 index cbbfa022b0..0000000000 --- a/test/files/jvm5/stringbuilder.scala +++ /dev/null @@ -1,100 +0,0 @@ -/* $Id$ */ - -import testing.SUnit._ - -/** Test the Scala implementation of class scala.StringBuilder. - * - * @author Stephane Micheloud - */ -object Test extends TestConsoleMain { - def suite = new TestSuite( - Test1, //ctor, reverse - Test2, //append - Test3, //insert - Test4 //indexOf, lastIndexOf - ) -} - -object Test1 extends TestCase("ctor") with Assert { - override def enableStackTrace = false - override def runTest { - val j0 = new java.lang.StringBuilder("abc") // Java 1.5+ - val s0 = new StringBuilder("abc") - assertEquals("s0 equals j0", false, s0 equals j0) - assertEquals("s0.toString equals j0.toString", true, s0.toString equals j0.toString) - - val str = """ -Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages. It is also fully interoperable with Java.""" - val j1 = new java.lang.StringBuilder(100) append str - val s1 = new java.lang.StringBuilder(100) append str - assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString) - - val j2 = j0 reverse - val s2 = s0 reverse; - //println("j2="+j2+", s2="+s2)//debug - assertEquals("s2.toString equals j2.toString", true, s2.toString equals j2.toString) - - val j3 = j2; j3 setCharAt (0, j3 charAt 2) - val s3 = s2; s3(0) = s3(2) - //println("j3="+j3+", s3="+s3)//debug - assertEquals("s3.toString equals j3.toString", true, s3.toString equals j3.toString) - } -} - -object Test2 extends TestCase("append") with Assert { - override def enableStackTrace = false - override def runTest { - val j0 = new java.lang.StringBuilder("abc") // Java 1.5+ - val s0 = new StringBuilder("abc") - - j0 append true append (1.toByte) append 'a' append 9 append -1L append 1.2e-10f append -2.1e+100d - s0 append true append (1.toByte) append 'a' append 9 append -1L append 1.2e-10f append -2.1e+100d - - assertEquals("s0.toString equals j0.toString", true, s0.toString equals j0.toString) - - val j1 = new java.lang.StringBuilder // Java 1.5+ - val s1 = new StringBuilder - j1 append "###" append Array('0', '1', '2') append "xyz".subSequence(0, 3) - s1 append "###" append Array('0', '1', '2') append List('x', 'y', 'z') - assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString) - } -} - -object Test3 extends TestCase("insert") with Assert { - override def enableStackTrace = false - override def runTest { - val j0 = new java.lang.StringBuilder("abc") // Java 1.5+ - val s0 = new StringBuilder("abc") - - j0 insert (0, true) insert (0, 1.toByte) insert (0, 'a') insert (0, 88.toShort) insert (0, 9) insert (0, -1L) - s0 insert (0, true) insert (0, 1.toByte) insert (0, 'a') insert (0, 88.toShort) insert (0, 9) insert (0, -1L) - //println("j0="+j0+", s0="+s0)//debug - assertEquals("s0.toString equals j0.toString", true, s0.toString equals j0.toString) - - val j1 = new java.lang.StringBuilder // Java 1.5+ - val s1 = new StringBuilder - j1 insert (0, "###") insert (0, Array('0', '1', '2')) insert (0, "xyz".subSequence(0, 3)) - s1 insert (0, "###") insert (0, Array('0', '1', '2')) insert (0, List('x', 'y', 'z')) - //println("j1="+j1+", s1="+s1)//debug - assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString) - - } -} - -object Test4 extends TestCase("indefOf") with Assert { - override def enableStackTrace = false - override def runTest { - val j0 = new java.lang.StringBuilder("abc") // Java 1.5+ - val s0 = new StringBuilder("abc") - - val j1 = j0 indexOf("c") - val s1 = s0 indexOf("c") - //println("j1="+j1+", s1="+s1)//debug - assertEquals("s1 == j1", true, s1 == j1) - - val j2 = j0 append "123abc" lastIndexOf("c") - val s2 = s0 append "123abc" lastIndexOf("c") - //println("j2="+j2+", s2="+s2)//debug - assertEquals("s2 == j2", true, s2 == j2) - } -} diff --git a/test/files/jvm5/sync-var.check b/test/files/jvm5/sync-var.check deleted file mode 100644 index e77aa319a5..0000000000 --- a/test/files/jvm5/sync-var.check +++ /dev/null @@ -1 +0,0 @@ -50005000 50005000 true diff --git a/test/files/jvm5/sync-var.scala b/test/files/jvm5/sync-var.scala deleted file mode 100644 index aa6ae9fa34..0000000000 --- a/test/files/jvm5/sync-var.scala +++ /dev/null @@ -1,53 +0,0 @@ -import java.util.concurrent._ -import java.util.concurrent.atomic._ - -object Test { def main(args: Array[String]) { - -val n = 10000 -val i = new AtomicInteger(n) -val j = new AtomicInteger(n) -val sum = new AtomicInteger - -val q = new scala.concurrent.SyncVar[Int] - -val producers = (1 to 3).force map { z => new Thread { - override def run() { - var again = true - while (again) { - val x = i.getAndDecrement() - if (x > 0) - q put x - else - again = false - } - } -} } - -val summers = (1 to 7).force map { z => new Thread { - override def run() { - val x = j.decrementAndGet() - if (x >= 0) { - sum addAndGet q.take() - } - if (x > 0) { - run() - } else { - // done - } - } -} } - -summers foreach { _.start() } -producers foreach { _.start() } - -summers foreach { _.join() } - -val got = sum.get -val expected = (n + 1) * n / 2 -println(got + " " + expected + " " + (got == expected)) - -producers foreach { _.join() } - -} } - -// vim: set ts=2 sw=2 et: diff --git a/test/files/jvm5/t0014.check b/test/files/jvm5/t0014.check deleted file mode 100644 index bece7db7af..0000000000 --- a/test/files/jvm5/t0014.check +++ /dev/null @@ -1 +0,0 @@ -test.NestedAnnotations diff --git a/test/files/jvm5/t0014.scala b/test/files/jvm5/t0014.scala deleted file mode 100644 index a1948702dc..0000000000 --- a/test/files/jvm5/t0014.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test { - def main(args: Array[String]) { - println(classOf[test.NestedAnnotations].getName) - } -} diff --git a/test/files/jvm5/t1461.scala b/test/files/jvm5/t1461.scala deleted file mode 100644 index f0e3cea6cd..0000000000 --- a/test/files/jvm5/t1461.scala +++ /dev/null @@ -1,18 +0,0 @@ - -object Test { - def main(args: Array[String]) { - val jl = classOf[Foo].getMethod("jl", classOf[Baz[_]]) - jl.getGenericParameterTypes // works fine - - val l = classOf[Foo].getMethod("l", classOf[Baz[_]]) - // By debugger inspection l.signature is (Ltest/Baz;)V - l.getGenericParameterTypes // throws GenericSignatureFormatError - } -} - -class Baz[T] - -class Foo { - def l(b: Baz[Long]) { } - def jl(b: Baz[java.lang.Long]) { } -} diff --git a/test/files/jvm5/t1464.check b/test/files/jvm5/t1464.check deleted file mode 100644 index c508d5366f..0000000000 --- a/test/files/jvm5/t1464.check +++ /dev/null @@ -1 +0,0 @@ -false diff --git a/test/files/jvm5/t1464/MyTrait.scala b/test/files/jvm5/t1464/MyTrait.scala deleted file mode 100644 index 0b8ccc412b..0000000000 --- a/test/files/jvm5/t1464/MyTrait.scala +++ /dev/null @@ -1,5 +0,0 @@ -trait MyTrait { - type K - def findChildByClass[T <: K with MyTrait]: Unit - -} diff --git a/test/files/jvm5/t1464/Test.java b/test/files/jvm5/t1464/Test.java deleted file mode 100644 index 235848b1df..0000000000 --- a/test/files/jvm5/t1464/Test.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Test { - public static void main(String[] args) { - Object o = new Object(); - System.out.println(o instanceof MyTrait); - } -} diff --git a/test/files/jvm5/throws-annot.check b/test/files/jvm5/throws-annot.check deleted file mode 100644 index a0ed82b106..0000000000 --- a/test/files/jvm5/throws-annot.check +++ /dev/null @@ -1,21 +0,0 @@ -read throws: class java.io.IOException -read annotations: -readWith2 throws: class java.lang.ClassCastException, class java.io.IOException -readWith2 annotations: -readMixed throws: class java.io.IOException, class java.lang.NullPointerException -readMixed annotations: @java.lang.Deprecated() -readMixed2 throws: class java.io.IOException, class java.lang.NullPointerException -readMixed2 annotations: @java.lang.Deprecated() -readNoEx throws: -readNoEx annotations: @java.lang.Deprecated() -Testing mirror class -read throws: class java.io.IOException -read annotations: -readWith2 throws: class java.lang.ClassCastException, class java.io.IOException -readWith2 annotations: -readMixed throws: class java.io.IOException, class java.lang.NullPointerException -readMixed annotations: @java.lang.Deprecated() -readMixed2 throws: class java.io.IOException, class java.lang.NullPointerException -readMixed2 annotations: @java.lang.Deprecated() -readNoEx throws: -readNoEx annotations: @java.lang.Deprecated() diff --git a/test/files/jvm5/throws-annot.scala b/test/files/jvm5/throws-annot.scala deleted file mode 100644 index 90b58b9976..0000000000 --- a/test/files/jvm5/throws-annot.scala +++ /dev/null @@ -1,74 +0,0 @@ -/** Test the @throws annotation */ -import java.io.IOException - -object TestThrows { - - abstract class Foo { - - @throws(classOf[IOException]) - def read(): Int - - @throws(classOf[ClassCastException]) - @throws(classOf[IOException]) - def readWith2(): Int - - @throws(classOf[IOException]) - @Deprecated - @throws(classOf[NullPointerException]) - def readMixed(): Int - - @Deprecated - @throws(classOf[IOException]) - @throws(classOf[NullPointerException]) - def readMixed2(): Int - - @Deprecated - def readNoEx(): Int - } - - def checkMethod(cls: Class[_], name: String) { - val method = cls.getMethod(name) - println(name + " throws: " + method.getExceptionTypes.mkString("", ", ", "")) - println(name + " annotations: " + method.getDeclaredAnnotations.mkString("", ", ", "")) - } - - def run(cls: Class[_]) { - checkMethod(cls, "read") - checkMethod(cls, "readWith2") - checkMethod(cls, "readMixed") - checkMethod(cls, "readMixed2") - checkMethod(cls, "readNoEx") - } -} - -/** Test the top-level mirror that is has the annotations. */ -object TL { - - @throws(classOf[IOException]) - def read(): Int = 0 - - @throws(classOf[ClassCastException]) - @throws(classOf[IOException]) - def readWith2(): Int = 0 - - @throws(classOf[IOException]) - @Deprecated - @throws(classOf[NullPointerException]) - def readMixed(): Int = 0 - - @Deprecated - @throws(classOf[IOException]) - @throws(classOf[NullPointerException]) - def readMixed2(): Int = 0 - - @Deprecated - def readNoEx(): Int = 0 -} - -object Test { - def main(args: Array[String]) { - TestThrows.run(classOf[TestThrows.Foo]) - println("Testing mirror class") - TestThrows.run(Class.forName("TL")) - } -} diff --git a/test/files/jvm5/typerep.check b/test/files/jvm5/typerep.check deleted file mode 100755 index ca93180946..0000000000 --- a/test/files/jvm5/typerep.check +++ /dev/null @@ -1,49 +0,0 @@ -Boolean -Boolean -true -Byte -Char -Int -Long -Float -Double -String -Unit -Class[Int] - -Some[Int] -Some[Int] -Some[Some[Int]] -Some[List[Int]] -None -None - -List[Int] -List[Int] -List[List[Int]] -Nil -List[Any] - -Array[Int] -Array[Array[Int]] -Array[Int] -Array[Int] -Array[Int] -Array[Int] - -Tuple2[Int, String] -Tuple3[Char, Char, String] -Tuple2[Tuple2[Int, String], Tuple2[Int, String]] -Tuple2[Tuple2[Some[Char], Int], Tuple2[Some[Char], Int]] - -Function1[Int, Int] -Int -Function1[Int, Int] -Int -Function1[Int, Function1[Int, Int]] -Function1[Int, Int] -Int -Function3[Boolean, List[Char], Int, Int] -Function2[Function1[Int, Int], Int, Int] -Int - diff --git a/test/files/jvm5/typerep.scala b/test/files/jvm5/typerep.scala deleted file mode 100755 index fc94817adf..0000000000 --- a/test/files/jvm5/typerep.scala +++ /dev/null @@ -1,383 +0,0 @@ -//############################################################################ -// Type Representation at runtime -//############################################################################ -// $Id: $ - -import TypeRep._ - -object Test extends Application { - testPrimitives - testOptions - testLists - testArrays - testTuples - testFuncs - testClasses -} - -object serialize { - import java.io._ - - @throws(classOf[IOException]) - def write[A](o: A): Array[Byte] = { - val ba = new ByteArrayOutputStream(512) - val out = new ObjectOutputStream(ba) - out.writeObject(o) - out.close() - ba.toByteArray() - } - @throws(classOf[IOException]) - @throws(classOf[ClassNotFoundException]) - def read[A](buffer: Array[Byte]): A = { - val in = - new ObjectInputStream(new ByteArrayInputStream(buffer)) - in.readObject().asInstanceOf[A] - } -} - -object testPrimitives { - println(getType(true)) - val b = false; val bt = getType(b) - println(bt) - val bt1: TypeRep[Boolean] = serialize.read(serialize.write(bt)) - println(bt1 == bt) - println(getType(16.toByte)) - println(getType('a')) - println(getType(3)) - println(getType(3l)) - println(getType(0.0f)) - println(getType(0.0d)) - println(getType("abc")) - println(getType(())) // Unit - println(getType(classOf[Int])) // Class - println -} - -object testOptions { - println(getType(Some(2))) - val x: Option[Int] = Some(2) - println(getType(x)) - println(getType(Some(Some(3)))) - println(getType(Some(List(3)))) - //println(getType(Some(None: List[Int]))) // error: no implicit argument matching parameter type TypeRep[object None] was foun - println(getType(None: Option[Int])) - val y: Option[Int] = None - println(getType(y)) - println -} - -object testLists { - println(getType(List(3))) - println(getType(3 :: Nil)) - println(getType(List(List(3)))) - println(getType(Nil: List[Int])) - println(getType(List(1, "abc"))) - println -} - -object testArrays { - println(getType(Array(3))) - println(getType(Array(Array(3), Array(4)))) - println(getType(new Array[Int](0))) - println(getType(List(1).toArray)) - println(getType(List[Int]().toArray)) - println(getType(Array(3).drop(1).toArray)) // empty - println -} - -object testTuples { - println(getType((3, "abc"))) - println(getType(Triple('a', 'b', "c"))) - println(getType(((3, "abc"), (4, "xyz")))) - println(getType(((Some('b'), 3), (Some('a'), 4)))) - //println(getType(((Some('b'), 3), (None, 4)))) - println -} - -object testFuncs { - def f1(x: Int): Int = 2 * x - println(getType(f1 _)) - println(getType(f1(2))) - val f2 = (x: Int) => 2 * x - println(getType(f2)) - println(getType(f2(2))) - val f3 = (x: Int) => (y: Int) => x + y - println(getType(f3)) - println(getType(f3(2))) - println(getType(f3(2)(2))) - def f4(b: Boolean, c: List[Char], i: Int): Int = i - println(getType(f4 _)) - def f5(f: Int => Int, x: Int) = f(x) - println(getType(f5 _)) - println(getType(f5(f1, 1))) - println -} - -class Foo { - class Bar(x: Int) -} - - -object foo extends Foo - -package pkg1 { - class C1 - object c1 extends C1 -} - -object testClasses { - /* - case object FooRep extends TypeRep[Foo] { - override def toString = "Foo" - } - implicit def fooRep[A](x: A)(implicit rep: TypeRep[foo.type]): TypeRep[foo.type] = rep - println(getType(foo)) - println(getType(new foo.Bar(0))) - val foo2 = new Foo - println(getType(foo2)) - println(getType(new foo2.Bar(1))) - println - - println(getType(pkg1.c1)) - val c1 = new pkg1.C1 - println(getType(c1)) - println - */ -} - - -/** - * @author Stephane Micheloud - * @version 1.0 - */ -abstract class TypeRep[A] - -object TypeRep { - - def getType[A](x: A)(implicit rep: TypeRep[A]): TypeRep[A] = rep - - def getType[A](x: Option[A])(implicit rep: TypeRep[A]): TypeRep[Option[A]] = (x match { - case Some(v) => SomeRep(rep) - case None => NoneRep - }).asInstanceOf[TypeRep[Option[A]]] - - def getType[A](x: List[A])(implicit rep: TypeRep[A]): TypeRep[List[A]] = (x match { - case h :: t => ListRep(getType(h)) - case Nil => NilRep - }).asInstanceOf[TypeRep[List[A]]] - - implicit def boolRep: TypeRep[Boolean] = BooleanRep - implicit def byteRep: TypeRep[Byte] = ByteRep - implicit def charRep: TypeRep[Char] = CharRep - implicit def shortRep: TypeRep[Short] = ShortRep - implicit def intRep: TypeRep[Int] = IntRep - implicit def longRep: TypeRep[Long] = LongRep - implicit def floatRep: TypeRep[Float] = FloatRep - implicit def doubleRep: TypeRep[Double] = DoubleRep - - implicit def unitRep: TypeRep[Unit] = UnitRep - implicit def stringRep: TypeRep[String] = StringRep - //implicit def noneRep: TypeRep[None.type] = NoneRep//[Nothing](NothingRep.asInstanceOf[TypeRep[Nothing]]) - implicit def anyRep: TypeRep[Any] = AnyRep - implicit def nothingRep: TypeRep[Nothing] = NothingRep - - implicit def classRep[A](implicit elemrep: TypeRep[A]): TypeRep[Class[A]] = - ClassRep(elemrep) - - implicit def someRep[A](implicit elemrep: TypeRep[A]): TypeRep[Some[A]] = - SomeRep(elemrep) - - implicit def listRep[A](implicit elemrep: TypeRep[A]): TypeRep[List[A]] = - ListRep(elemrep) - - implicit def arrayRep[A](implicit elemrep: TypeRep[A]): TypeRep[Array[A]] = - ArrayRep(elemrep) - - implicit def tuple2Rep[A1, A2](implicit _1: TypeRep[A1], _2: TypeRep[A2]): TypeRep[(A1, A2)] = - Tuple2Rep(_1, _2) - - implicit def tuple3Rep[A1, A2, A3](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3]): TypeRep[(A1, A2, A3)] = - Tuple3Rep(_1, _2, _3) - implicit def tuple4Rep[A1, A2, A3, A4](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4]): TypeRep[Tuple4[A1, A2, A3, A4]] = - Tuple4Rep(_1, _2, _3, _4) - implicit def tuple5Rep[A1, A2, A3, A4, A5](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5]): TypeRep[Tuple5[A1, A2, A3, A4, A5]] = - Tuple5Rep(_1, _2, _3, _4, _5) - implicit def tuple6Rep[A1, A2, A3, A4, A5, A6](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5], _6: TypeRep[A6]): TypeRep[Tuple6[A1, A2, A3, A4, A5, A6]] = - Tuple6Rep(_1, _2, _3, _4, _5, _6) - implicit def tuple7Rep[A1, A2, A3, A4, A5, A6, A7](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5], _6: TypeRep[A6], _7: TypeRep[A7]): TypeRep[Tuple7[A1, A2, A3, A4, A5, A6, A7]] = - Tuple7Rep(_1, _2, _3, _4, _5, _6, _7) - implicit def tuple8Rep[A1, A2, A3, A4, A5, A6, A7, A8](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5], _6: TypeRep[A6], _7: TypeRep[A7], _8: TypeRep[A8]): TypeRep[Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] = - Tuple8Rep(_1, _2, _3, _4, _5, _6, _7, _8) - implicit def tuple9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9](implicit _1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5], _6: TypeRep[A6], _7: TypeRep[A7], _8: TypeRep[A8], _9: TypeRep[A9]): TypeRep[Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] = - Tuple9Rep(_1, _2, _3, _4, _5, _6, _7, _8, _9) - - implicit def func1Rep[A1, B](implicit a1: TypeRep[A1], b: TypeRep[B]): TypeRep[Function1[A1, B]] = - Function1Rep(a1, b) - implicit def func2Rep[A1, A2, B](implicit a1: TypeRep[A1], a2: TypeRep[A2], b: TypeRep[B]): TypeRep[Function2[A1, A2, B]] = - Function2Rep(a1, a2, b) - implicit def func3Rep[A1, A2, A3, B](implicit a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], b: TypeRep[B]): TypeRep[Function3[A1, A2, A3, B]] = - Function3Rep(a1, a2, a3, b) - implicit def func4Rep[A1, A2, A3, A4, B](implicit a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], b: TypeRep[B]): TypeRep[Function4[A1, A2, A3, A4, B]] = - Function4Rep(a1, a2, a3, a4, b) - implicit def func5Rep[A1, A2, A3, A4, A5, B](implicit a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], b: TypeRep[B]): TypeRep[Function5[A1, A2, A3, A4, A5, B]] = - Function5Rep(a1, a2, a3, a4, a5, b) - implicit def func6Rep[A1, A2, A3, A4, A5, A6, B](implicit a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], b: TypeRep[B]): TypeRep[Function6[A1, A2, A3, A4, A5, A6, B]] = - Function6Rep(a1, a2, a3, a4, a5, a6, b) - implicit def func7Rep[A1, A2, A3, A4, A5, A6, A7, B](implicit a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], b: TypeRep[B]): TypeRep[Function7[A1, A2, A3, A4, A5, A6, A7, B]] = - Function7Rep(a1, a2, a3, a4, a5, a6, a7, b) - implicit def func8Rep[A1, A2, A3, A4, A5, A6, A7, A8, B](implicit a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], b: TypeRep[B]): TypeRep[Function8[A1, A2, A3, A4, A5, A6, A7, A8, B]] = - Function8Rep(a1, a2, a3, a4, a5, a6, a7, a8, b) - implicit def func9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9, B](implicit a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], a9: TypeRep[A9], b: TypeRep[B]): TypeRep[Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, B]] = - Function9Rep(a1, a2, a3, a4, a5, a6, a7, a8, a9, b) -/* - implicit def objectRep[A <: AnyRef](obj: A)(implicit rep: TypeRep[A]): TypeRep[AnyClass] = - ObjectRep(obj.getClass) -*/ - - case object BooleanRep extends TypeRep[Boolean] { - override def toString = "Boolean" - } - case object ByteRep extends TypeRep[Byte] { - override def toString = "Byte" - } - case object CharRep extends TypeRep[Char] { - override def toString = "Char" - } - case object ShortRep extends TypeRep[Short] { - override def toString = "Short" - } - case object IntRep extends TypeRep[Int] { - override def toString = "Int" - } - case object LongRep extends TypeRep[Long] { - override def toString = "Long" - } - case object FloatRep extends TypeRep[Float] { - override def toString = "Float" - } - case object DoubleRep extends TypeRep[Double] { - override def toString = "Double" - } - - case object UnitRep extends TypeRep[Unit] { - override def toString = "Unit" - } -// case object ClassRep extends TypeRep[AnyClass] { -// override def toString = "Class" -// } - case object StringRep extends TypeRep[String] { - override def toString = "String" - } - case object NoneRep extends TypeRep[None.type] { - override def toString = "None" - } - case object NilRep extends TypeRep[Nil.type] { - override def toString = "Nil" - } - case object AnyRep extends TypeRep[Any] { - override def toString = "Any" - } - case object NothingRep extends TypeRep[Nothing] { - override def toString = "Nothing" - } - - @serializable - case class ClassRep[A](elemRep: TypeRep[A]) extends TypeRep[Class[A]] { - override def toString = "Class[" + elemRep + "]" - } - @serializable - case class SomeRep[A](elemRep: TypeRep[A]) extends TypeRep[Some[A]] { - override def toString = "Some[" + elemRep + "]" - } - @serializable - case class NoneRep[A](elemRep: TypeRep[A]) extends TypeRep[Option[A]] { - override def toString = "None[" + elemRep + "]" - } - - @serializable - case class ListRep[A](elemRep: TypeRep[A]) extends TypeRep[List[A]] { - override def toString = "List[" + elemRep + "]" - } - - @serializable - case class ArrayRep[A](elemRep: TypeRep[A]) extends TypeRep[Array[A]] { - override def toString = "Array[" + elemRep + "]" - } - - @serializable - case class Tuple2Rep[A1, A2](_1: TypeRep[A1], _2: TypeRep[A2]) extends TypeRep[(A1, A2)] { - override def toString = "Tuple2[" + _1 + ", " + _2 + "]" - } - @serializable - case class Tuple3Rep[A1, A2, A3](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3]) extends TypeRep[Tuple3[A1, A2, A3]] { - override def toString = "Tuple3[" + _1 + ", " + _2 + ", " + _3 + "]" - } - @serializable - case class Tuple4Rep[A1, A2, A3, A4](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4]) extends TypeRep[Tuple4[A1, A2, A3, A4]] { - override def toString = "Tuple4[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + "]" - } - @serializable - case class Tuple5Rep[A1, A2, A3, A4, A5](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5]) extends TypeRep[Tuple5[A1, A2, A3, A4, A5]] { - override def toString = "Tuple5[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + "]" - } - @serializable - case class Tuple6Rep[A1, A2, A3, A4, A5, A6](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6]) extends TypeRep[Tuple6[A1, A2, A3, A4, A5, A6]] { - override def toString = "Tuple6[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + "]" - } - @serializable - case class Tuple7Rep[A1, A2, A3, A4, A5, A6, A7](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7]) extends TypeRep[Tuple7[A1, A2, A3, A4, A5, A6, A7]] { - override def toString = "Tuple7[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + "]" - } - @serializable - case class Tuple8Rep[A1, A2, A3, A4, A5, A6, A7, A8](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8]) extends TypeRep[Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] { - override def toString = "Tuple8[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + "]" - } - @serializable - case class Tuple9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8], val _9: TypeRep[A9]) extends TypeRep[Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] { - override def toString = "Tuple9[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + ", " + _9 + "]" - } - - @serializable - case class Function1Rep[A1, B](a1: TypeRep[A1], b: TypeRep[B]) extends TypeRep[Function1[A1, B]] { - override def toString = "Function1[" + a1 + ", " + b + "]" - } - @serializable - case class Function2Rep[A1, A2, B](a1: TypeRep[A1], a2: TypeRep[A2], b: TypeRep[B]) extends TypeRep[Function2[A1, A2, B]] { - override def toString = "Function2[" + a1 + ", " + a2 + ", " + b + "]" - } - @serializable - case class Function3Rep[A1, A2, A3, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], b: TypeRep[B]) extends TypeRep[Function3[A1, A2, A3, B]] { - override def toString = "Function3[" + a1 + ", " + a2 + ", " + a3 + ", " + b + "]" - } - @serializable - case class Function4Rep[A1, A2, A3, A4, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], b: TypeRep[B]) extends TypeRep[Function4[A1, A2, A3, A4, B]] { - override def toString = "Function4[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + b + "]" - } - @serializable - case class Function5Rep[A1, A2, A3, A4, A5, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], b: TypeRep[B]) extends TypeRep[Function5[A1, A2, A3, A4, A5, B]] { - override def toString = "Function5[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + b + "]" - } - @serializable - case class Function6Rep[A1, A2, A3, A4, A5, A6, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], b: TypeRep[B]) extends TypeRep[Function6[A1, A2, A3, A4, A5, A6, B]] { - override def toString = "Function6[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + b + "]" - } - @serializable - case class Function7Rep[A1, A2, A3, A4, A5, A6, A7, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], b: TypeRep[B]) extends TypeRep[Function7[A1, A2, A3, A4, A5, A6, A7, B]] { - override def toString = "Function7[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + b + "]" - } - @serializable - case class Function8Rep[A1, A2, A3, A4, A5, A6, A7, A8, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], b: TypeRep[B]) extends TypeRep[Function8[A1, A2, A3, A4, A5, A6, A7, A8, B]] { - override def toString = "Function8[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + b + "]" - } - @serializable - case class Function9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], a9: TypeRep[A9], b: TypeRep[B]) extends TypeRep[Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, B]] { - override def toString = "Function9[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + ", " + b + "]" - } -/* - @serializable - case class ObjectRep[A](c: Class) extends TypeRep[A] { - override def toString = c.getName - } -*/ -} - diff --git a/test/files/pos/chang/Outer.java b/test/files/pos/chang/Outer.java new file mode 100644 index 0000000000..acdb4e2904 --- /dev/null +++ b/test/files/pos/chang/Outer.java @@ -0,0 +1,11 @@ +package com.netgents.hello; + +public class Outer { + + public Inner inner = new Inner(); + + public class Inner { + + public A a; + } +} diff --git a/test/files/pos/chang/Test.scala b/test/files/pos/chang/Test.scala new file mode 100644 index 0000000000..9bb745e377 --- /dev/null +++ b/test/files/pos/chang/Test.scala @@ -0,0 +1,3 @@ +object Test extends Application { + new com.netgents.hello.Outer[String] +} diff --git a/test/files/pos/ilya/J.java b/test/files/pos/ilya/J.java new file mode 100644 index 0000000000..c44169ca1b --- /dev/null +++ b/test/files/pos/ilya/J.java @@ -0,0 +1,14 @@ +package test; + +class Foo { +} + +class Boo{} + +class Bar, FooT extends Foo>{ + private final int myInt; + + public Bar(int i) { + myInt = i; + } +} \ No newline at end of file diff --git a/test/files/pos/ilya/S.scala b/test/files/pos/ilya/S.scala new file mode 100644 index 0000000000..952c004ccc --- /dev/null +++ b/test/files/pos/ilya/S.scala @@ -0,0 +1,5 @@ +package test + +class ScBar[BooT <: Boo[FooT], FooT <: Foo](i: Int) extends Bar[BooT, FooT](i) { + +} diff --git a/test/files/pos/ilya2/A.scala b/test/files/pos/ilya2/A.scala new file mode 100644 index 0000000000..923b50f04d --- /dev/null +++ b/test/files/pos/ilya2/A.scala @@ -0,0 +1,3 @@ +class A { + def foo = new B().bar(null) +} diff --git a/test/files/pos/ilya2/B.java b/test/files/pos/ilya2/B.java new file mode 100644 index 0000000000..4771493fdd --- /dev/null +++ b/test/files/pos/ilya2/B.java @@ -0,0 +1,6 @@ +public class B { + public int bar(@Nullable final Object o) { + return 42; + } + +} diff --git a/test/files/pos/ilya2/Nullable.java b/test/files/pos/ilya2/Nullable.java new file mode 100644 index 0000000000..ebbb013d7e --- /dev/null +++ b/test/files/pos/ilya2/Nullable.java @@ -0,0 +1,7 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) +public @interface Nullable { + String value() default ""; +} diff --git a/test/files/pos/signatures/Test.java b/test/files/pos/signatures/Test.java new file mode 100644 index 0000000000..8ecac29910 --- /dev/null +++ b/test/files/pos/signatures/Test.java @@ -0,0 +1,11 @@ +import scala.collection.mutable.Vector; +import test.Outer; + +/* Test correct generation of java signatures. The Outer class should not + * have a Java signature attribute for the inner method definition. Trait + * Mutable should have one, even though it is also a nested definition. + * (but for classes there is a way to tell about nesting to the JVM). + */ +class Test { + Outer o = new Outer(); +} \ No newline at end of file diff --git a/test/files/pos/signatures/sig.scala b/test/files/pos/signatures/sig.scala new file mode 100644 index 0000000000..4236f27bed --- /dev/null +++ b/test/files/pos/signatures/sig.scala @@ -0,0 +1,12 @@ +package test + +/* Tests correct generation of Java signatures. The local method 'bar' should + * not get a generic signature, as it may refer to type parameters of the enclosing + * method, and the JVM does not know about nested methods. + */ +class Outer { + def foo[A, B](x: A, y: B) = { + def bar[X](x1: A, y1: B, z1: X) = z1 + bar(x, y, 10) + } +} diff --git a/test/files/pos/t0695/JavaClass.java b/test/files/pos/t0695/JavaClass.java new file mode 100644 index 0000000000..a765f7e324 --- /dev/null +++ b/test/files/pos/t0695/JavaClass.java @@ -0,0 +1,5 @@ +public class JavaClass { + class InnerClass { + public A method() { return null; } + } +} diff --git a/test/files/pos/t0695/Test.scala b/test/files/pos/t0695/Test.scala new file mode 100644 index 0000000000..7318867bf7 --- /dev/null +++ b/test/files/pos/t0695/Test.scala @@ -0,0 +1,3 @@ +object Test extends JavaClass[AnyRef] { + var field: InnerClass = null +} diff --git a/test/files/pos/t1101/J.java b/test/files/pos/t1101/J.java new file mode 100644 index 0000000000..2bc1d53e09 --- /dev/null +++ b/test/files/pos/t1101/J.java @@ -0,0 +1 @@ +class J { enum E { E1 } } diff --git a/test/files/pos/t1101/S.scala b/test/files/pos/t1101/S.scala new file mode 100644 index 0000000000..af7a591e58 --- /dev/null +++ b/test/files/pos/t1101/S.scala @@ -0,0 +1 @@ +class S { val x: J.E = null; System.out.println(J.E.E1) } diff --git a/test/files/pos/t1102/J.java b/test/files/pos/t1102/J.java new file mode 100644 index 0000000000..530102b91c --- /dev/null +++ b/test/files/pos/t1102/J.java @@ -0,0 +1,4 @@ +class J { + enum E { E1 } + void foo(E e) { } +} diff --git a/test/files/pos/t1102/S.scala b/test/files/pos/t1102/S.scala new file mode 100644 index 0000000000..9beee8d901 --- /dev/null +++ b/test/files/pos/t1102/S.scala @@ -0,0 +1 @@ +class S(j:J) { j.foo(J.E.E1) } diff --git a/test/files/pos/t1150/J.java b/test/files/pos/t1150/J.java new file mode 100644 index 0000000000..68fa04a178 --- /dev/null +++ b/test/files/pos/t1150/J.java @@ -0,0 +1,4 @@ +class J { + static void bbb (Boolean b) { } + static void ddd (Double d) { } +} diff --git a/test/files/pos/t1150/S.scala b/test/files/pos/t1150/S.scala new file mode 100644 index 0000000000..41dd064037 --- /dev/null +++ b/test/files/pos/t1150/S.scala @@ -0,0 +1,4 @@ +object S { + J.bbb(new java.lang.Boolean(true)) + J.ddd(new java.lang.Double(0)) +} diff --git a/test/files/pos/t1152/J.java b/test/files/pos/t1152/J.java new file mode 100644 index 0000000000..6e562e573d --- /dev/null +++ b/test/files/pos/t1152/J.java @@ -0,0 +1 @@ +class J { java.util.List k = null; } diff --git a/test/files/pos/t1152/S.scala b/test/files/pos/t1152/S.scala new file mode 100644 index 0000000000..7f751c5090 --- /dev/null +++ b/test/files/pos/t1152/S.scala @@ -0,0 +1,2 @@ +class S2(fn:(J)=>Any) +object S { new S2(_.k) } diff --git a/test/files/pos/t1176/J.java b/test/files/pos/t1176/J.java new file mode 100644 index 0000000000..0d82c75fcb --- /dev/null +++ b/test/files/pos/t1176/J.java @@ -0,0 +1,4 @@ +class J { + J() { } + J( java.util.Collection collection ) { } +} diff --git a/test/files/pos/t1176/S.scala b/test/files/pos/t1176/S.scala new file mode 100644 index 0000000000..a7fc3e0cea --- /dev/null +++ b/test/files/pos/t1176/S.scala @@ -0,0 +1 @@ +class S { new J } diff --git a/test/files/pos/t1186/t1186.java b/test/files/pos/t1186/t1186.java new file mode 100644 index 0000000000..c1bfcecab8 --- /dev/null +++ b/test/files/pos/t1186/t1186.java @@ -0,0 +1,8 @@ +import scala.collection.immutable.Map; + +class Test { + + void foo() { + Map map = null; + } +} \ No newline at end of file diff --git a/test/files/pos/t1196/J.java b/test/files/pos/t1196/J.java new file mode 100644 index 0000000000..2ec7a711bb --- /dev/null +++ b/test/files/pos/t1196/J.java @@ -0,0 +1 @@ +class J { static void foo(Class c) { } } diff --git a/test/files/pos/t1196/S.scala b/test/files/pos/t1196/S.scala new file mode 100644 index 0000000000..f17cd249a7 --- /dev/null +++ b/test/files/pos/t1196/S.scala @@ -0,0 +1 @@ +object S { J.foo(null) } diff --git a/test/files/pos/t1197/J.java b/test/files/pos/t1197/J.java new file mode 100644 index 0000000000..b4e0a4255c --- /dev/null +++ b/test/files/pos/t1197/J.java @@ -0,0 +1,2 @@ +class J { interface K { } } + diff --git a/test/files/pos/t1197/S.scala b/test/files/pos/t1197/S.scala new file mode 100644 index 0000000000..7c9c15440f --- /dev/null +++ b/test/files/pos/t1197/S.scala @@ -0,0 +1,2 @@ +object S extends J.K + diff --git a/test/files/pos/t1203/J.java b/test/files/pos/t1203/J.java new file mode 100644 index 0000000000..7fae118e04 --- /dev/null +++ b/test/files/pos/t1203/J.java @@ -0,0 +1 @@ +interface J { int j = 200 ; } diff --git a/test/files/pos/t1203/S.scala b/test/files/pos/t1203/S.scala new file mode 100644 index 0000000000..68eac4bf6d --- /dev/null +++ b/test/files/pos/t1203/S.scala @@ -0,0 +1 @@ +object S { J.j } diff --git a/test/files/pos/t1230/J.java b/test/files/pos/t1230/J.java new file mode 100644 index 0000000000..35aefd2505 --- /dev/null +++ b/test/files/pos/t1230/J.java @@ -0,0 +1 @@ +class J { public int foo ; } diff --git a/test/files/pos/t1230/S.scala b/test/files/pos/t1230/S.scala new file mode 100644 index 0000000000..f8a691b6de --- /dev/null +++ b/test/files/pos/t1230/S.scala @@ -0,0 +1 @@ +object S extends Application { (new J).foo = 5 } diff --git a/test/files/pos/t1231/J.java b/test/files/pos/t1231/J.java new file mode 100644 index 0000000000..1dfc9490eb --- /dev/null +++ b/test/files/pos/t1231/J.java @@ -0,0 +1 @@ +enum J { j1 } \ No newline at end of file diff --git a/test/files/pos/t1231/S.scala b/test/files/pos/t1231/S.scala new file mode 100644 index 0000000000..ee08866e04 --- /dev/null +++ b/test/files/pos/t1231/S.scala @@ -0,0 +1 @@ +object S extends Application { println(J.j1) } diff --git a/test/files/pos/t1232/J.java b/test/files/pos/t1232/J.java new file mode 100755 index 0000000000..af3aad928d --- /dev/null +++ b/test/files/pos/t1232/J.java @@ -0,0 +1,2 @@ +package j; +public class J { public enum E { e1 } } \ No newline at end of file diff --git a/test/files/pos/t1232/J2.java b/test/files/pos/t1232/J2.java new file mode 100755 index 0000000000..dc117d360f --- /dev/null +++ b/test/files/pos/t1232/J2.java @@ -0,0 +1,2 @@ +import s.S; +class J2 { } \ No newline at end of file diff --git a/test/files/pos/t1232/S.scala b/test/files/pos/t1232/S.scala new file mode 100755 index 0000000000..1b6bca7327 --- /dev/null +++ b/test/files/pos/t1232/S.scala @@ -0,0 +1,2 @@ +package s +class S { j.J.E.e1 } diff --git a/test/files/pos/t1235/Test.java b/test/files/pos/t1235/Test.java new file mode 100644 index 0000000000..7bb83a8491 --- /dev/null +++ b/test/files/pos/t1235/Test.java @@ -0,0 +1,9 @@ +import scala.collection.immutable.HashMap; + +public class Test { + + void foo() { + new HashMap(); + } +} + diff --git a/test/files/pos/t1254/t1254.java b/test/files/pos/t1254/t1254.java new file mode 100644 index 0000000000..25b733cf28 --- /dev/null +++ b/test/files/pos/t1254/t1254.java @@ -0,0 +1,28 @@ +/* Taken from ticket #1254. Tests Java signatures in mirror classes and that + Nothing is translated to Nothing$. +*/ + +import scala.None; + +// This compiles with javac but fails with Eclipse java compiler: +// 'The type scala.Nothing cannot be resolved. It is indirectly referenced from required .class files' +class NothingBug3 { + public NothingBug3() { + scala.Option o = scala.None$.MODULE$; + + test(o); + None.toLeft(new scala.Function0() { + public Integer apply() { return 0; } + }); + } + + public void test(scala.Option f) {} +} + +// This compiles with javac but fails with Eclipse java compiler: +// 'The type scala.Nothing cannot be resolved. It is indirectly referenced from required .class files' +class NothingBug4 { + public NothingBug4() { + scala.Option o = scala.None$.MODULE$; + } +} diff --git a/test/files/pos/t1263/Test.java b/test/files/pos/t1263/Test.java new file mode 100644 index 0000000000..0eb43e881a --- /dev/null +++ b/test/files/pos/t1263/Test.java @@ -0,0 +1,16 @@ +package test; + +import java.rmi.RemoteException; + +import test.Map; + +public class Test implements Map { + public Map.MapTo plus(String o) { + return null; + } + + public int $tag() throws RemoteException { + return 0; + } +} + diff --git a/test/files/pos/t1263/test.scala b/test/files/pos/t1263/test.scala new file mode 100644 index 0000000000..92d8c1cdfa --- /dev/null +++ b/test/files/pos/t1263/test.scala @@ -0,0 +1,10 @@ +package test + +trait Map[A, +B] { + def plus(key: A): MapTo = new MapTo(key) + + class MapTo(key: A) { + def arrow [B1 >: B](value: B1) = null + } +} + diff --git a/test/files/pos/t1711/Seq.scala b/test/files/pos/t1711/Seq.scala new file mode 100644 index 0000000000..c18f05cd73 --- /dev/null +++ b/test/files/pos/t1711/Seq.scala @@ -0,0 +1,12 @@ +package com + +object Sequence { + + def filteringFunction[V](filter: V => Boolean): List[V] => List[V] = { + def include(v: V) = + filter(v) + (l: List[V]) => l.filter(include) + } + +} + diff --git a/test/files/pos/t1711/Test.java b/test/files/pos/t1711/Test.java new file mode 100644 index 0000000000..5ec0f2297c --- /dev/null +++ b/test/files/pos/t1711/Test.java @@ -0,0 +1,6 @@ +import com.Sequence; + +public class Test { + void foo() { + } +} diff --git a/test/files/pos5/chang/Outer.java b/test/files/pos5/chang/Outer.java deleted file mode 100644 index acdb4e2904..0000000000 --- a/test/files/pos5/chang/Outer.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.netgents.hello; - -public class Outer { - - public Inner inner = new Inner(); - - public class Inner { - - public A a; - } -} diff --git a/test/files/pos5/chang/Test.scala b/test/files/pos5/chang/Test.scala deleted file mode 100644 index 9bb745e377..0000000000 --- a/test/files/pos5/chang/Test.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends Application { - new com.netgents.hello.Outer[String] -} diff --git a/test/files/pos5/ilya/J.java b/test/files/pos5/ilya/J.java deleted file mode 100644 index c44169ca1b..0000000000 --- a/test/files/pos5/ilya/J.java +++ /dev/null @@ -1,14 +0,0 @@ -package test; - -class Foo { -} - -class Boo{} - -class Bar, FooT extends Foo>{ - private final int myInt; - - public Bar(int i) { - myInt = i; - } -} \ No newline at end of file diff --git a/test/files/pos5/ilya/S.scala b/test/files/pos5/ilya/S.scala deleted file mode 100644 index 952c004ccc..0000000000 --- a/test/files/pos5/ilya/S.scala +++ /dev/null @@ -1,5 +0,0 @@ -package test - -class ScBar[BooT <: Boo[FooT], FooT <: Foo](i: Int) extends Bar[BooT, FooT](i) { - -} diff --git a/test/files/pos5/ilya2/A.scala b/test/files/pos5/ilya2/A.scala deleted file mode 100644 index 923b50f04d..0000000000 --- a/test/files/pos5/ilya2/A.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - def foo = new B().bar(null) -} diff --git a/test/files/pos5/ilya2/B.java b/test/files/pos5/ilya2/B.java deleted file mode 100644 index 4771493fdd..0000000000 --- a/test/files/pos5/ilya2/B.java +++ /dev/null @@ -1,6 +0,0 @@ -public class B { - public int bar(@Nullable final Object o) { - return 42; - } - -} diff --git a/test/files/pos5/ilya2/Nullable.java b/test/files/pos5/ilya2/Nullable.java deleted file mode 100644 index ebbb013d7e..0000000000 --- a/test/files/pos5/ilya2/Nullable.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.lang.annotation.*; - -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) -public @interface Nullable { - String value() default ""; -} diff --git a/test/files/pos5/signatures/Test.java b/test/files/pos5/signatures/Test.java deleted file mode 100644 index 8ecac29910..0000000000 --- a/test/files/pos5/signatures/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import scala.collection.mutable.Vector; -import test.Outer; - -/* Test correct generation of java signatures. The Outer class should not - * have a Java signature attribute for the inner method definition. Trait - * Mutable should have one, even though it is also a nested definition. - * (but for classes there is a way to tell about nesting to the JVM). - */ -class Test { - Outer o = new Outer(); -} \ No newline at end of file diff --git a/test/files/pos5/signatures/sig.scala b/test/files/pos5/signatures/sig.scala deleted file mode 100644 index 4236f27bed..0000000000 --- a/test/files/pos5/signatures/sig.scala +++ /dev/null @@ -1,12 +0,0 @@ -package test - -/* Tests correct generation of Java signatures. The local method 'bar' should - * not get a generic signature, as it may refer to type parameters of the enclosing - * method, and the JVM does not know about nested methods. - */ -class Outer { - def foo[A, B](x: A, y: B) = { - def bar[X](x1: A, y1: B, z1: X) = z1 - bar(x, y, 10) - } -} diff --git a/test/files/pos5/t0695/JavaClass.java b/test/files/pos5/t0695/JavaClass.java deleted file mode 100644 index a765f7e324..0000000000 --- a/test/files/pos5/t0695/JavaClass.java +++ /dev/null @@ -1,5 +0,0 @@ -public class JavaClass { - class InnerClass { - public A method() { return null; } - } -} diff --git a/test/files/pos5/t0695/Test.scala b/test/files/pos5/t0695/Test.scala deleted file mode 100644 index 7318867bf7..0000000000 --- a/test/files/pos5/t0695/Test.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends JavaClass[AnyRef] { - var field: InnerClass = null -} diff --git a/test/files/pos5/t1101/J.java b/test/files/pos5/t1101/J.java deleted file mode 100644 index 2bc1d53e09..0000000000 --- a/test/files/pos5/t1101/J.java +++ /dev/null @@ -1 +0,0 @@ -class J { enum E { E1 } } diff --git a/test/files/pos5/t1101/S.scala b/test/files/pos5/t1101/S.scala deleted file mode 100644 index af7a591e58..0000000000 --- a/test/files/pos5/t1101/S.scala +++ /dev/null @@ -1 +0,0 @@ -class S { val x: J.E = null; System.out.println(J.E.E1) } diff --git a/test/files/pos5/t1102/J.java b/test/files/pos5/t1102/J.java deleted file mode 100644 index 530102b91c..0000000000 --- a/test/files/pos5/t1102/J.java +++ /dev/null @@ -1,4 +0,0 @@ -class J { - enum E { E1 } - void foo(E e) { } -} diff --git a/test/files/pos5/t1102/S.scala b/test/files/pos5/t1102/S.scala deleted file mode 100644 index 9beee8d901..0000000000 --- a/test/files/pos5/t1102/S.scala +++ /dev/null @@ -1 +0,0 @@ -class S(j:J) { j.foo(J.E.E1) } diff --git a/test/files/pos5/t1150/J.java b/test/files/pos5/t1150/J.java deleted file mode 100644 index 68fa04a178..0000000000 --- a/test/files/pos5/t1150/J.java +++ /dev/null @@ -1,4 +0,0 @@ -class J { - static void bbb (Boolean b) { } - static void ddd (Double d) { } -} diff --git a/test/files/pos5/t1150/S.scala b/test/files/pos5/t1150/S.scala deleted file mode 100644 index 41dd064037..0000000000 --- a/test/files/pos5/t1150/S.scala +++ /dev/null @@ -1,4 +0,0 @@ -object S { - J.bbb(new java.lang.Boolean(true)) - J.ddd(new java.lang.Double(0)) -} diff --git a/test/files/pos5/t1152/J.java b/test/files/pos5/t1152/J.java deleted file mode 100644 index 6e562e573d..0000000000 --- a/test/files/pos5/t1152/J.java +++ /dev/null @@ -1 +0,0 @@ -class J { java.util.List k = null; } diff --git a/test/files/pos5/t1152/S.scala b/test/files/pos5/t1152/S.scala deleted file mode 100644 index 7f751c5090..0000000000 --- a/test/files/pos5/t1152/S.scala +++ /dev/null @@ -1,2 +0,0 @@ -class S2(fn:(J)=>Any) -object S { new S2(_.k) } diff --git a/test/files/pos5/t1176/J.java b/test/files/pos5/t1176/J.java deleted file mode 100644 index 0d82c75fcb..0000000000 --- a/test/files/pos5/t1176/J.java +++ /dev/null @@ -1,4 +0,0 @@ -class J { - J() { } - J( java.util.Collection collection ) { } -} diff --git a/test/files/pos5/t1176/S.scala b/test/files/pos5/t1176/S.scala deleted file mode 100644 index a7fc3e0cea..0000000000 --- a/test/files/pos5/t1176/S.scala +++ /dev/null @@ -1 +0,0 @@ -class S { new J } diff --git a/test/files/pos5/t1186/t1186.java b/test/files/pos5/t1186/t1186.java deleted file mode 100644 index c1bfcecab8..0000000000 --- a/test/files/pos5/t1186/t1186.java +++ /dev/null @@ -1,8 +0,0 @@ -import scala.collection.immutable.Map; - -class Test { - - void foo() { - Map map = null; - } -} \ No newline at end of file diff --git a/test/files/pos5/t1196/J.java b/test/files/pos5/t1196/J.java deleted file mode 100644 index 2ec7a711bb..0000000000 --- a/test/files/pos5/t1196/J.java +++ /dev/null @@ -1 +0,0 @@ -class J { static void foo(Class c) { } } diff --git a/test/files/pos5/t1196/S.scala b/test/files/pos5/t1196/S.scala deleted file mode 100644 index f17cd249a7..0000000000 --- a/test/files/pos5/t1196/S.scala +++ /dev/null @@ -1 +0,0 @@ -object S { J.foo(null) } diff --git a/test/files/pos5/t1197/J.java b/test/files/pos5/t1197/J.java deleted file mode 100644 index b4e0a4255c..0000000000 --- a/test/files/pos5/t1197/J.java +++ /dev/null @@ -1,2 +0,0 @@ -class J { interface K { } } - diff --git a/test/files/pos5/t1197/S.scala b/test/files/pos5/t1197/S.scala deleted file mode 100644 index 7c9c15440f..0000000000 --- a/test/files/pos5/t1197/S.scala +++ /dev/null @@ -1,2 +0,0 @@ -object S extends J.K - diff --git a/test/files/pos5/t1203/J.java b/test/files/pos5/t1203/J.java deleted file mode 100644 index 7fae118e04..0000000000 --- a/test/files/pos5/t1203/J.java +++ /dev/null @@ -1 +0,0 @@ -interface J { int j = 200 ; } diff --git a/test/files/pos5/t1203/S.scala b/test/files/pos5/t1203/S.scala deleted file mode 100644 index 68eac4bf6d..0000000000 --- a/test/files/pos5/t1203/S.scala +++ /dev/null @@ -1 +0,0 @@ -object S { J.j } diff --git a/test/files/pos5/t1230/J.java b/test/files/pos5/t1230/J.java deleted file mode 100644 index 35aefd2505..0000000000 --- a/test/files/pos5/t1230/J.java +++ /dev/null @@ -1 +0,0 @@ -class J { public int foo ; } diff --git a/test/files/pos5/t1230/S.scala b/test/files/pos5/t1230/S.scala deleted file mode 100644 index f8a691b6de..0000000000 --- a/test/files/pos5/t1230/S.scala +++ /dev/null @@ -1 +0,0 @@ -object S extends Application { (new J).foo = 5 } diff --git a/test/files/pos5/t1231/J.java b/test/files/pos5/t1231/J.java deleted file mode 100644 index 1dfc9490eb..0000000000 --- a/test/files/pos5/t1231/J.java +++ /dev/null @@ -1 +0,0 @@ -enum J { j1 } \ No newline at end of file diff --git a/test/files/pos5/t1231/S.scala b/test/files/pos5/t1231/S.scala deleted file mode 100644 index ee08866e04..0000000000 --- a/test/files/pos5/t1231/S.scala +++ /dev/null @@ -1 +0,0 @@ -object S extends Application { println(J.j1) } diff --git a/test/files/pos5/t1232/J.java b/test/files/pos5/t1232/J.java deleted file mode 100755 index af3aad928d..0000000000 --- a/test/files/pos5/t1232/J.java +++ /dev/null @@ -1,2 +0,0 @@ -package j; -public class J { public enum E { e1 } } \ No newline at end of file diff --git a/test/files/pos5/t1232/J2.java b/test/files/pos5/t1232/J2.java deleted file mode 100755 index dc117d360f..0000000000 --- a/test/files/pos5/t1232/J2.java +++ /dev/null @@ -1,2 +0,0 @@ -import s.S; -class J2 { } \ No newline at end of file diff --git a/test/files/pos5/t1232/S.scala b/test/files/pos5/t1232/S.scala deleted file mode 100755 index 1b6bca7327..0000000000 --- a/test/files/pos5/t1232/S.scala +++ /dev/null @@ -1,2 +0,0 @@ -package s -class S { j.J.E.e1 } diff --git a/test/files/pos5/t1235/Test.java b/test/files/pos5/t1235/Test.java deleted file mode 100644 index 7bb83a8491..0000000000 --- a/test/files/pos5/t1235/Test.java +++ /dev/null @@ -1,9 +0,0 @@ -import scala.collection.immutable.HashMap; - -public class Test { - - void foo() { - new HashMap(); - } -} - diff --git a/test/files/pos5/t1254/t1254.java b/test/files/pos5/t1254/t1254.java deleted file mode 100644 index 25b733cf28..0000000000 --- a/test/files/pos5/t1254/t1254.java +++ /dev/null @@ -1,28 +0,0 @@ -/* Taken from ticket #1254. Tests Java signatures in mirror classes and that - Nothing is translated to Nothing$. -*/ - -import scala.None; - -// This compiles with javac but fails with Eclipse java compiler: -// 'The type scala.Nothing cannot be resolved. It is indirectly referenced from required .class files' -class NothingBug3 { - public NothingBug3() { - scala.Option o = scala.None$.MODULE$; - - test(o); - None.toLeft(new scala.Function0() { - public Integer apply() { return 0; } - }); - } - - public void test(scala.Option f) {} -} - -// This compiles with javac but fails with Eclipse java compiler: -// 'The type scala.Nothing cannot be resolved. It is indirectly referenced from required .class files' -class NothingBug4 { - public NothingBug4() { - scala.Option o = scala.None$.MODULE$; - } -} diff --git a/test/files/pos5/t1263/Test.java b/test/files/pos5/t1263/Test.java deleted file mode 100644 index 0eb43e881a..0000000000 --- a/test/files/pos5/t1263/Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test; - -import java.rmi.RemoteException; - -import test.Map; - -public class Test implements Map { - public Map.MapTo plus(String o) { - return null; - } - - public int $tag() throws RemoteException { - return 0; - } -} - diff --git a/test/files/pos5/t1263/test.scala b/test/files/pos5/t1263/test.scala deleted file mode 100644 index 92d8c1cdfa..0000000000 --- a/test/files/pos5/t1263/test.scala +++ /dev/null @@ -1,10 +0,0 @@ -package test - -trait Map[A, +B] { - def plus(key: A): MapTo = new MapTo(key) - - class MapTo(key: A) { - def arrow [B1 >: B](value: B1) = null - } -} - diff --git a/test/files/pos5/t1711/Seq.scala b/test/files/pos5/t1711/Seq.scala deleted file mode 100644 index c18f05cd73..0000000000 --- a/test/files/pos5/t1711/Seq.scala +++ /dev/null @@ -1,12 +0,0 @@ -package com - -object Sequence { - - def filteringFunction[V](filter: V => Boolean): List[V] => List[V] = { - def include(v: V) = - filter(v) - (l: List[V]) => l.filter(include) - } - -} - diff --git a/test/files/pos5/t1711/Test.java b/test/files/pos5/t1711/Test.java deleted file mode 100644 index 5ec0f2297c..0000000000 --- a/test/files/pos5/t1711/Test.java +++ /dev/null @@ -1,6 +0,0 @@ -import com.Sequence; - -public class Test { - void foo() { - } -} -- cgit v1.2.3