diff options
Diffstat (limited to 'test')
99 files changed, 965 insertions, 276 deletions
diff --git a/test/files/jvm/manifests-new.check b/test/files/jvm/manifests-new.check index 9fca856970..896a5c1cef 100644 --- a/test/files/jvm/manifests-new.check +++ b/test/files/jvm/manifests-new.check @@ -1,58 +1,58 @@ -x=(), t=ConcreteTypeTag[Unit], k=TypeRef, s=class Unit
-x=true, t=ConcreteTypeTag[Boolean], k=TypeRef, s=class Boolean
-x=a, t=ConcreteTypeTag[Char], k=TypeRef, s=class Char
-x=1, t=ConcreteTypeTag[Int], k=TypeRef, s=class Int
-x=abc, t=ConcreteTypeTag[String], k=TypeRef, s=class String
-x='abc, t=ConcreteTypeTag[Symbol], k=TypeRef, s=class Symbol
-
-x=List(()), t=ConcreteTypeTag[List[Unit]], k=TypeRef, s=class List
-x=List(true), t=ConcreteTypeTag[List[Boolean]], k=TypeRef, s=class List
-x=List(1), t=ConcreteTypeTag[List[Int]], k=TypeRef, s=class List
-x=List(abc), t=ConcreteTypeTag[List[String]], k=TypeRef, s=class List
-x=List('abc), t=ConcreteTypeTag[List[Symbol]], k=TypeRef, s=class List
-
-x=[Z, t=ConcreteTypeTag[Array[Boolean]], k=TypeRef, s=class Array
-x=[C, t=ConcreteTypeTag[Array[Char]], k=TypeRef, s=class Array
-x=[I, t=ConcreteTypeTag[Array[Int]], k=TypeRef, s=class Array
-x=[Ljava.lang.String;, t=ConcreteTypeTag[Array[String]], k=TypeRef, s=class Array
-x=[Lscala.Symbol;, t=ConcreteTypeTag[Array[Symbol]], k=TypeRef, s=class Array
-
-x=((),()), t=ConcreteTypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2
-x=(true,false), t=ConcreteTypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2
-x=(1,2), t=ConcreteTypeTag[(Int, Int)], k=TypeRef, s=class Tuple2
-x=(abc,xyz), t=ConcreteTypeTag[(String, String)], k=TypeRef, s=class Tuple2
-x=('abc,'xyz), t=ConcreteTypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2
-
-x=Test$, t=ConcreteTypeTag[Test.type], k=TypeRef, s=object Test
-x=scala.collection.immutable.List$, t=ConcreteTypeTag[scala.collection.immutable.List.type], k=TypeRef, s=object List
-
-x=Foo, t=ConcreteTypeTag[Foo[Int]], k=TypeRef, s=class Foo
-x=Foo, t=ConcreteTypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo
-x=Foo, t=ConcreteTypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo
-x=Foo, t=ConcreteTypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo
-
-x=Test1$$anon$1, t=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1>
-x=Test1$$anon$2, t=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1>
-
-()=()
-true=true
-a=a
-1=1
-'abc='abc
-
-List(())=List(())
-List(true)=List(true)
-List('abc)=List('abc)
-
-Array()=Array()
-Array(true)=Array(true)
-Array(a)=Array(a)
-Array(1)=Array(1)
-
-((),())=((),())
-(true,false)=(true,false)
-
-List(List(1), List(2))=List(List(1), List(2))
-
-Array(Array(1), Array(2))=Array(Array(1), Array(2))
-
+x=(), t=ConcreteTypeTag[Unit], k=TypeRef, s=class Unit +x=true, t=ConcreteTypeTag[Boolean], k=TypeRef, s=class Boolean +x=a, t=ConcreteTypeTag[Char], k=TypeRef, s=class Char +x=1, t=ConcreteTypeTag[Int], k=TypeRef, s=class Int +x=abc, t=ConcreteTypeTag[String], k=TypeRef, s=class String +x='abc, t=ConcreteTypeTag[Symbol], k=TypeRef, s=class Symbol + +x=List(()), t=ConcreteTypeTag[List[Unit]], k=TypeRef, s=class List +x=List(true), t=ConcreteTypeTag[List[Boolean]], k=TypeRef, s=class List +x=List(1), t=ConcreteTypeTag[List[Int]], k=TypeRef, s=class List +x=List(abc), t=ConcreteTypeTag[List[String]], k=TypeRef, s=class List +x=List('abc), t=ConcreteTypeTag[List[Symbol]], k=TypeRef, s=class List + +x=[Z, t=ConcreteTypeTag[Array[Boolean]], k=TypeRef, s=class Array +x=[C, t=ConcreteTypeTag[Array[Char]], k=TypeRef, s=class Array +x=[I, t=ConcreteTypeTag[Array[Int]], k=TypeRef, s=class Array +x=[Ljava.lang.String;, t=ConcreteTypeTag[Array[String]], k=TypeRef, s=class Array +x=[Lscala.Symbol;, t=ConcreteTypeTag[Array[Symbol]], k=TypeRef, s=class Array + +x=((),()), t=ConcreteTypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2 +x=(true,false), t=ConcreteTypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2 +x=(1,2), t=ConcreteTypeTag[(Int, Int)], k=TypeRef, s=class Tuple2 +x=(abc,xyz), t=ConcreteTypeTag[(String, String)], k=TypeRef, s=class Tuple2 +x=('abc,'xyz), t=ConcreteTypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2 + +x=Test$, t=ConcreteTypeTag[Test.type], k=SingleType, s=object Test +x=scala.collection.immutable.List$, t=ConcreteTypeTag[scala.collection.immutable.List.type], k=SingleType, s=object List + +x=Foo, t=ConcreteTypeTag[Foo[Int]], k=TypeRef, s=class Foo +x=Foo, t=ConcreteTypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo +x=Foo, t=ConcreteTypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo +x=Foo, t=ConcreteTypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo + +x=Test1$$anon$1, t=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1> +x=Test1$$anon$2, t=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1> + +()=() +true=true +a=a +1=1 +'abc='abc + +List(())=List(()) +List(true)=List(true) +List('abc)=List('abc) + +Array()=Array() +Array(true)=Array(true) +Array(a)=Array(a) +Array(1)=Array(1) + +((),())=((),()) +(true,false)=(true,false) + +List(List(1), List(2))=List(List(1), List(2)) + +Array(Array(1), Array(2))=Array(Array(1), Array(2)) + diff --git a/test/files/neg/t4098.check b/test/files/neg/t4098.check new file mode 100644 index 0000000000..7d69cf151c --- /dev/null +++ b/test/files/neg/t4098.check @@ -0,0 +1,13 @@ +t4098.scala:3: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:8: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:13: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:18: error: forward reference not allowed from self constructor invocation + this(b) + ^ +four errors found diff --git a/test/files/neg/t4098.scala b/test/files/neg/t4098.scala new file mode 100644 index 0000000000..744d6191b5 --- /dev/null +++ b/test/files/neg/t4098.scala @@ -0,0 +1,22 @@ +class A(a: Any) { + def this() = { + this(b) + def b = new {} + } + + def this(x: Int) = { + this(b) + lazy val b = new {} + } + + def this(x: Int, y: Int) = { + this(b) + val b = new {} + } + + def this(x: Int, y: Int, z: Int) = { + this(b) + println(".") + def b = new {} + } +} diff --git a/test/files/neg/t5564.check b/test/files/neg/t5564.check new file mode 100644 index 0000000000..e7e13ccc9c --- /dev/null +++ b/test/files/neg/t5564.check @@ -0,0 +1,4 @@ +t5564.scala:8: error: inferred type arguments [A] do not conform to method bar's type parameter bounds [B >: A <: C] + def bar[B >: A <: C]: T = throw new Exception + ^ +one error found diff --git a/test/files/neg/t5564.scala b/test/files/neg/t5564.scala new file mode 100644 index 0000000000..663cf88726 --- /dev/null +++ b/test/files/neg/t5564.scala @@ -0,0 +1,9 @@ + + + +trait C + + +class Foo[@specialized(Int) T, A] { + def bar[B >: A <: C]: T = throw new Exception +} diff --git a/test/files/pos/overloaded_extractor_and_regular_def.scala b/test/files/pos/overloaded_extractor_and_regular_def.scala new file mode 100644 index 0000000000..c8e7da5cad --- /dev/null +++ b/test/files/pos/overloaded_extractor_and_regular_def.scala @@ -0,0 +1,32 @@ +trait TreesBase { + type Tree + + type Apply <: Tree + + val Apply: ApplyExtractor + + abstract class ApplyExtractor { + def apply(x: Int): Apply + def unapply(apply: Apply): Option[Int] + } +} + +trait TreesApi extends TreesBase { + def Apply(x: String) +} + +class Universe extends TreesApi { + abstract class Tree + case class Apply(x: Int) extends Tree + object Apply extends ApplyExtractor + def Apply(x: String) = Apply(x.toInt) +} + +object Test extends App { + def foo(tapi: TreesApi) { + import tapi._ + def bar(tree: Tree) { + val Apply(x) = tree + } + } +}
\ No newline at end of file diff --git a/test/files/pos/rangepos-patmat.flags b/test/files/pos/rangepos-patmat.flags new file mode 100644 index 0000000000..281f0a10cd --- /dev/null +++ b/test/files/pos/rangepos-patmat.flags @@ -0,0 +1 @@ +-Yrangepos diff --git a/test/files/pos/rangepos-patmat.scala b/test/files/pos/rangepos-patmat.scala new file mode 100644 index 0000000000..98c842aaf8 --- /dev/null +++ b/test/files/pos/rangepos-patmat.scala @@ -0,0 +1,4 @@ +class Foo { + def test: PartialFunction[Any, String] = { case _ => "ok" } + +} diff --git a/test/files/pos/t1133.scala b/test/files/pos/t1133.scala new file mode 100644 index 0000000000..4538de5f5f --- /dev/null +++ b/test/files/pos/t1133.scala @@ -0,0 +1,32 @@ +object Match +{ + def main(args: Array[String]) = { + args(0) match { + case Extractor1(Extractor2(Extractor3("dog", "dog", "dog"), x2, x3), b, c, Extractor3("b", "b", f), e) => println(e) + case Extractor3(Extractor2(Extractor1("a", "aa", "aaa", "aa", "a"), Extractor2("a", "aa", "aaa"), e), y, z) => println(e) + case Extractor2(Extractor3("a", "a", x), Extractor3("b", "b", y), Extractor3("c", "c", z)) => println(z) + case _ => println("fail") + } + } + + object Extractor1 { + def unapply(x: Any) = x match { + case x: String => Some(x, x+x, x+x+x, x+x, x) + case _ => None + } + } + + object Extractor2 { + def unapply(x: Any) = x match { + case x: String => Some(x, x+x, x+x+x) + case _ => None + } + } + + object Extractor3 { + def unapply(x: Any) = x match { + case x: String => Some(x, x, x) + case _ => None + } + } +} diff --git a/test/files/pos/t1987.scala b/test/files/pos/t1987a.scala index ccab133716..ccab133716 100644 --- a/test/files/pos/t1987.scala +++ b/test/files/pos/t1987a.scala diff --git a/test/files/pos/t2435.scala b/test/files/pos/t2435.scala new file mode 100644 index 0000000000..2db931b99f --- /dev/null +++ b/test/files/pos/t2435.scala @@ -0,0 +1,27 @@ +object Bug { + abstract class FChain { + type T + + def chain(constant:String) = + new FConstant[this.type](constant, this) //removing [this.type], everything compiles + } + + case class FConstant[E <: FChain](constant:String, tail:E) extends FChain { + type T = tail.T + } + + object FNil extends FChain { + type T = Unit + } + +} + +object Test { + import Bug._ + println("Compiles:") + val a1 = FNil.chain("a").chain("a") + val a2 = a1.chain("a") + + println("\nDoesn't compile:") + val a = FNil.chain("a").chain("a").chain("a") +} diff --git a/test/files/pos/t2764/Ann.java b/test/files/pos/t2764/Ann.java new file mode 100644 index 0000000000..184fc6e864 --- /dev/null +++ b/test/files/pos/t2764/Ann.java @@ -0,0 +1,5 @@ +package bippy; + +public @interface Ann { + Enum value(); +} diff --git a/test/files/pos/t2764/Enum.java b/test/files/pos/t2764/Enum.java new file mode 100644 index 0000000000..fe07559535 --- /dev/null +++ b/test/files/pos/t2764/Enum.java @@ -0,0 +1,5 @@ +package bippy; + +public enum Enum { + VALUE; +} diff --git a/test/files/pos/t2764/Use.scala b/test/files/pos/t2764/Use.scala new file mode 100644 index 0000000000..8cf8102709 --- /dev/null +++ b/test/files/pos/t2764/Use.scala @@ -0,0 +1,6 @@ +package bippy + +class Use { + @Ann(Enum.VALUE) + def foo {} +} diff --git a/test/files/pos/t4651.scala b/test/files/pos/t4651.scala new file mode 100644 index 0000000000..0612a8fcfb --- /dev/null +++ b/test/files/pos/t4651.scala @@ -0,0 +1,12 @@ +object Test { + def analyze(x: Any) = x match { + case s: String => println("It's a string: " + s) + case 1 => println("It's a one") + case (a: Int, b) => println("It's a pair of and int " + a + + " and something " + b) + case 1 :: 2 :: _ => println("It's a list starting with 1, 2") + case List(a, b, c) => println("It's a three-element list with " + + a + ", " + b + ", " + c) + case _ => println("It's something different") + } +} diff --git a/test/files/pos/t5029.flags b/test/files/pos/t5029.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t5029.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t5029.scala b/test/files/pos/t5029.scala new file mode 100644 index 0000000000..6f9a329b80 --- /dev/null +++ b/test/files/pos/t5029.scala @@ -0,0 +1,3 @@ +object Test { + (Vector(): Seq[_]) match { case List() => true; case Nil => false } +}
\ No newline at end of file diff --git a/test/files/pos/t5137.scala b/test/files/pos/t5137.scala new file mode 100644 index 0000000000..bb72cf378f --- /dev/null +++ b/test/files/pos/t5137.scala @@ -0,0 +1,17 @@ +object Test { + + // okay + (1 * (List[BigInt]().map(((x0) => x0 match { + case x => x + })).sum)) + + // okay + ((1: BigInt) * (List[BigInt]().map({ + case x => x + }).sum)) + + // fail + (1 * (List[BigInt]().map({ + case x => x + }).sum)) +}
\ No newline at end of file diff --git a/test/files/pos/t5165/TestAnnotation.java b/test/files/pos/t5165/TestAnnotation.java new file mode 100644 index 0000000000..90886b7537 --- /dev/null +++ b/test/files/pos/t5165/TestAnnotation.java @@ -0,0 +1,11 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +public @interface TestAnnotation { + public enum TestEnumOne { A, B } + public enum TestEnumTwo { C, D } + + public TestEnumOne one(); + public TestEnumTwo two(); + public String strVal(); +} diff --git a/test/files/pos/t5165/TestObject.scala b/test/files/pos/t5165/TestObject.scala new file mode 100644 index 0000000000..eaf244e9d0 --- /dev/null +++ b/test/files/pos/t5165/TestObject.scala @@ -0,0 +1,3 @@ + +object TestObject extends TestTrait + diff --git a/test/files/pos/t5165/TestTrait.scala b/test/files/pos/t5165/TestTrait.scala new file mode 100644 index 0000000000..b317e6c6a3 --- /dev/null +++ b/test/files/pos/t5165/TestTrait.scala @@ -0,0 +1,3 @@ + +@TestAnnotation(one=TestAnnotation.TestEnumOne.A, two=TestAnnotation.TestEnumTwo.C, strVal="something") +trait TestTrait diff --git a/test/files/pos/t5210.scala b/test/files/pos/t5210.scala new file mode 100644 index 0000000000..e85037a902 --- /dev/null +++ b/test/files/pos/t5210.scala @@ -0,0 +1,10 @@ +object WithOpTest { + trait WithOp extends Cloneable { + def f: this.type = this + def g1: this.type = f + def g2: this.type = { + val t = f + t + } + } +} diff --git a/test/files/pos/t5384.scala b/test/files/pos/t5384.scala new file mode 100644 index 0000000000..4e297d5935 --- /dev/null +++ b/test/files/pos/t5384.scala @@ -0,0 +1,7 @@ +class A(x: String, y: Int)(implicit o: String) +class B1(implicit o: String) extends A(y = 5, x = "a") +class B2(implicit o: String) extends A("a", 5) +class B3(implicit o: String) extends A(y = 5, x = "a")(o) + +class AM[E: Manifest](val x: Unit = (), y: Unit) +class BM[E: Manifest] extends AM[E](y = ()) diff --git a/test/files/pos/t5626.scala b/test/files/pos/t5626.scala new file mode 100644 index 0000000000..c501dfbe60 --- /dev/null +++ b/test/files/pos/t5626.scala @@ -0,0 +1,12 @@ +class C { + val blob = { + new { case class Foo() } + } + val blub = { + class Inner { case class Foo() } + new Inner + } + + val foo = blob.Foo() + val bar = blub.Foo() +} diff --git a/test/files/pos/t5654.scala b/test/files/pos/t5654.scala new file mode 100644 index 0000000000..1f8d05bfed --- /dev/null +++ b/test/files/pos/t5654.scala @@ -0,0 +1,13 @@ +class T(val a: Array[_]) + +class U { + val a = Array(Array(1, 2), Array("a","b")) +} + +class T1 { val a: Array[_] = Array(1) } + +case class Bomb(a: Array[_]) +case class Bomb2(a: Array[T] forSome { type T }) +class Okay1(a: Array[_]) +case class Okay2(s: Seq[_]) + diff --git a/test/files/pos/t5720-ownerous.scala b/test/files/pos/t5720-ownerous.scala index 3a12499612..ad4d4c171d 100644 --- a/test/files/pos/t5720-ownerous.scala +++ b/test/files/pos/t5720-ownerous.scala @@ -28,10 +28,10 @@ class C { //def model = Option(M("foo")()).getOrElse(M("bar")()).copy(currentUser = "")() // the bug - def model = Option(m).getOrElse(M("bar")()).copy("baz")() + def model = Option(m).getOrElse(M("bar")()).copy("baz")("empty") // style points for this version - def modish = ((null: Option[M]) getOrElse new M()()).copy()() + def modish = ((null: Option[M]) getOrElse new M()()).copy()("empty") // various simplifications are too simple case class N(currentUser: String = "anon") diff --git a/test/files/pos/t5777.scala b/test/files/pos/t5777.scala new file mode 100644 index 0000000000..24cea36163 --- /dev/null +++ b/test/files/pos/t5777.scala @@ -0,0 +1,45 @@ +// /scala/trac/5777/a.scala +// Wed May 9 08:44:57 PDT 2012 + +trait Ring { + trait E +} + +class Poly[C <: Ring](val ring: C) extends Ring +// This definition of Poly triggers the same failure on *both* versions +// class Poly(val ring: Ring) extends Ring + +object BigInt extends Ring + +object MyApp { + val r = new Poly(BigInt) + + implicitly[r.ring.E <:< BigInt.E] + + // fail on 2.10, works on 2.9.2 + (null.asInstanceOf[BigInt.E] : r.ring.E) + + // works on both versions + val r1 = new Poly[BigInt.type](BigInt) + (null.asInstanceOf[BigInt.E] : r1.ring.E) + + // Oddly, -Xprint:typer reports that r and r1 have the same inferred type. + // + // private[this] val r: Poly[BigInt.type] = new Poly[BigInt.type](BigInt); + // <stable> <accessor> def r: Poly[BigInt.type] = MyApp.this.r; + // (null.asInstanceOf[BigInt.E]: MyApp.r.ring.E); + // private[this] val r1: Poly[BigInt.type] = new Poly[BigInt.type](BigInt); + // <stable> <accessor> def r1: Poly[BigInt.type] = MyApp.this.r1; + // (null.asInstanceOf[BigInt.E]: MyApp.r1.ring.E) + + // diff typer-2.9.2.txt typer-2.10.txt + // ... + // --- + // > object MyApp extends scala.AnyRef { + // > def <init>(): MyApp.type = { + // > MyApp.super.<init>(); + // 30c30 + // < scala.this.Predef.implicitly[<:<[BigInt.E,MyApp.r.ring.E]](scala.this.Predef.conforms[BigInt.E]); + // --- + // > scala.this.Predef.implicitly[<:<[BigInt.E,MyApp.r.ring.E]](); +} diff --git a/test/files/pos/t5796.scala b/test/files/pos/t5796.scala new file mode 100644 index 0000000000..d05350c535 --- /dev/null +++ b/test/files/pos/t5796.scala @@ -0,0 +1,8 @@ +object Bug { + def foo() { + val v = { + lazy val s = 0 + s + } + } +} diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index 68ac904b18..3a08e2a2ea 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -58,12 +58,12 @@ retrieved 64 members [accessible: true] `type AnswercallccInterpreter.Answer` [accessible: true] `type EnvironmentcallccInterpreter.Environment` [accessible: true] `type NamecallccInterpreter.Name` +[accessible: true] `value __leftOfArrowcallccInterpreter.type` +[accessible: true] `value __resultOfEnsuringcallccInterpreter.type` +[accessible: true] `value selfAny` [accessible: true] `value term0callccInterpreter.App` [accessible: true] `value term1callccInterpreter.App` [accessible: true] `value term2callccInterpreter.Add` -[accessible: false] `value __leftOfArrowcallccInterpreter.type` -[accessible: false] `value __resultOfEnsuringcallccInterpreter.type` -[accessible: false] `value selfAny` ================================================================================ askType at CallccInterpreter.scala(14,21) diff --git a/test/files/presentation/patmat.check b/test/files/presentation/hyperlinks.check index 29fd8b8e68..85d295dd7d 100644 --- a/test/files/presentation/patmat.check +++ b/test/files/presentation/hyperlinks.check @@ -1,4 +1,14 @@ -reload: PatMatTests.scala +reload: NameDefaultTests.scala, PatMatTests.scala + +askHyperlinkPos for `someOtherInt` at (14,24) NameDefaultTests.scala +================================================================================ +[response] found askHyperlinkPos for `someOtherInt` at (12,9) NameDefaultTests.scala +================================================================================ + +askHyperlinkPos for `someString` at (14,45) NameDefaultTests.scala +================================================================================ +[response] found askHyperlinkPos for `someString` at (3,7) NameDefaultTests.scala +================================================================================ askHyperlinkPos for `CaseOne` at (12,18) PatMatTests.scala ================================================================================ diff --git a/test/files/presentation/patmat.flags b/test/files/presentation/hyperlinks.flags index dc13682c5e..dc13682c5e 100644 --- a/test/files/presentation/patmat.flags +++ b/test/files/presentation/hyperlinks.flags diff --git a/test/files/presentation/patmat/Runner.scala b/test/files/presentation/hyperlinks/Runner.scala index 3d19f2d948..3d19f2d948 100644 --- a/test/files/presentation/patmat/Runner.scala +++ b/test/files/presentation/hyperlinks/Runner.scala diff --git a/test/files/presentation/hyperlinks/src/NameDefaultTests.scala b/test/files/presentation/hyperlinks/src/NameDefaultTests.scala new file mode 100644 index 0000000000..b218040fe3 --- /dev/null +++ b/test/files/presentation/hyperlinks/src/NameDefaultTests.scala @@ -0,0 +1,16 @@ + +class NameDefaults { + val someString = "abc" + val someInt = 42 + + def foo(x: String, y: Int)(implicit logger: Int): Int = y + + implicit val l = 42 + + def bar { + println() + val someOtherInt = 10 + + foo(y = someOtherInt/*#*/, x = someString/*#*/) + } +} diff --git a/test/files/presentation/patmat/src/PatMatTests.scala b/test/files/presentation/hyperlinks/src/PatMatTests.scala index bbd0f2e7ed..bbd0f2e7ed 100644 --- a/test/files/presentation/patmat/src/PatMatTests.scala +++ b/test/files/presentation/hyperlinks/src/PatMatTests.scala diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check index d643f82a25..44a3207d75 100644 --- a/test/files/presentation/ide-bug-1000349.check +++ b/test/files/presentation/ide-bug-1000349.check @@ -34,7 +34,7 @@ retrieved 37 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Foo` [accessible: true] `method →[B](y: B)(Foo, B)` -[accessible: false] `value __leftOfArrowFoo` -[accessible: false] `value __resultOfEnsuringFoo` -[accessible: false] `value selfAny` +[accessible: true] `value __leftOfArrowFoo` +[accessible: true] `value __resultOfEnsuringFoo` +[accessible: true] `value selfAny` ================================================================================ diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check index 2410ebf71d..34c3b557d8 100644 --- a/test/files/presentation/ide-bug-1000475.check +++ b/test/files/presentation/ide-bug-1000475.check @@ -31,11 +31,11 @@ retrieved 36 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Object` [accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowObject` -[accessible: false] `value __resultOfEnsuringObject` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Foo.scala(6,10) @@ -69,11 +69,11 @@ retrieved 36 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Object` [accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowObject` -[accessible: false] `value __resultOfEnsuringObject` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Foo.scala(7,7) @@ -107,9 +107,9 @@ retrieved 36 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Object` [accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowObject` -[accessible: false] `value __resultOfEnsuringObject` -[accessible: false] `value selfAny` ================================================================================ diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index 2ae0158a13..dcbd440801 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -118,10 +118,10 @@ retrieved 124 members [accessible: true] `method zipWithIndex=> Iterator[(B, Int)]` [accessible: true] `method zip[B](that: Iterator[B])Iterator[(B, B)]` [accessible: true] `method →[B](y: B)(java.util.Iterator[B], B)` +[accessible: true] `value __leftOfArrowjava.util.Iterator[B]` +[accessible: true] `value __resultOfEnsuringjava.util.Iterator[B]` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method reversed=> List[B]` -[accessible: false] `value __leftOfArrowjava.util.Iterator[B]` -[accessible: false] `value __resultOfEnsuringjava.util.Iterator[B]` -[accessible: false] `value selfAny` ================================================================================ diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check index ce21293ae5..05d6f61699 100644 --- a/test/files/presentation/implicit-member.check +++ b/test/files/presentation/implicit-member.check @@ -35,8 +35,8 @@ retrieved 39 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Implicit.type` [accessible: true] `method →[B](y: B)(Implicit.type, B)` -[accessible: false] `value __leftOfArrowImplicit.type` -[accessible: false] `value __resultOfEnsuringImplicit.type` -[accessible: false] `value selfAny` -[accessible: false] `value xImplicit.type` +[accessible: true] `value __leftOfArrowImplicit.type` +[accessible: true] `value __resultOfEnsuringImplicit.type` +[accessible: true] `value selfAny` +[accessible: true] `value xImplicit.type` ================================================================================ diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check index 1f02274736..b666d51de5 100644 --- a/test/files/presentation/ping-pong.check +++ b/test/files/presentation/ping-pong.check @@ -32,13 +32,13 @@ retrieved 40 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Pong` [accessible: true] `method →[B](y: B)(Pong, B)` +[accessible: true] `value __leftOfArrowPong` +[accessible: true] `value __resultOfEnsuringPong` +[accessible: true] `value nameString` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowPong` -[accessible: false] `value __resultOfEnsuringPong` -[accessible: false] `value nameString` [accessible: false] `value pingPing` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at PingPong.scala(19,20) @@ -75,12 +75,12 @@ retrieved 40 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Ping` [accessible: true] `method →[B](y: B)(Ping, B)` +[accessible: true] `value __leftOfArrowPing` +[accessible: true] `value __resultOfEnsuringPing` +[accessible: true] `value pongPong` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowPing` -[accessible: false] `value __resultOfEnsuringPing` -[accessible: false] `value pongPong` -[accessible: false] `value selfAny` ================================================================================ askType at PingPong.scala(8,10) diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check new file mode 100644 index 0000000000..c6d4762635 --- /dev/null +++ b/test/files/presentation/t5708.check @@ -0,0 +1,47 @@ +reload: Completions.scala + +askTypeCompletion at Completions.scala(17,9) +================================================================================ +[response] aksTypeCompletion at (17,9) +retrieved 44 members +[accessible: true] `lazy value fooInt` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(test.Compat.type, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)test.Compat.type` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type` +[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type` +[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method pkgPrivateM=> String` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> test.Compat.type` +[accessible: true] `method →[B](y: B)(test.Compat.type, B)` +[accessible: true] `value CONST_STRINGString("constant")` +[accessible: true] `value __leftOfArrowtest.Compat.type` +[accessible: true] `value __resultOfEnsuringtest.Compat.type` +[accessible: true] `value pkgPrivateVString` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method privateM=> String` +[accessible: false] `method protectedValM=> String` +[accessible: false] `value privateVString` +[accessible: false] `value protectedVString` +================================================================================ diff --git a/test/pending/presentation/t5708/Test.scala b/test/files/presentation/t5708/Test.scala index 96e758d974..96e758d974 100644 --- a/test/pending/presentation/t5708/Test.scala +++ b/test/files/presentation/t5708/Test.scala diff --git a/test/files/presentation/t5708/src/Completions.scala b/test/files/presentation/t5708/src/Completions.scala new file mode 100644 index 0000000000..1e9e5d5eb1 --- /dev/null +++ b/test/files/presentation/t5708/src/Completions.scala @@ -0,0 +1,18 @@ +package test + +object Compat { + final val CONST_STRING = "constant" + lazy val foo = 4 + + private val privateV = "" + private[test] val pkgPrivateV = "" + protected val protectedV = "" + + private def privateM = "" + private[test] def pkgPrivateM = "" + protected def protectedValM = "" +} + +class Foo { + Compat./*!*/CONST_STRING // its 'accessible' flag is false +} diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check index 290a5ac381..3026e58f7e 100644 --- a/test/files/presentation/visibility.check +++ b/test/files/presentation/visibility.check @@ -38,10 +38,10 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.Foo` [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` [accessible: false] `method secretPrivateThis()Unit` -[accessible: false] `value __leftOfArrowaccessibility.Foo` -[accessible: false] `value __resultOfEnsuringaccessibility.Foo` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Completions.scala(16,11) @@ -83,9 +83,9 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.Foo` [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` -[accessible: false] `value __leftOfArrowaccessibility.Foo` -[accessible: false] `value __resultOfEnsuringaccessibility.Foo` -[accessible: false] `value selfAny` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` ================================================================================ askTypeCompletion at Completions.scala(22,11) @@ -126,10 +126,10 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.AccessibilityChecks` [accessible: true] `method →[B](y: B)(accessibility.AccessibilityChecks, B)` +[accessible: true] `value __leftOfArrowaccessibility.AccessibilityChecks` +[accessible: true] `value __resultOfEnsuringaccessibility.AccessibilityChecks` +[accessible: true] `value selfAny` [accessible: false] `method secretPrivate()Unit` -[accessible: false] `value __leftOfArrowaccessibility.AccessibilityChecks` -[accessible: false] `value __resultOfEnsuringaccessibility.AccessibilityChecks` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Completions.scala(28,10) @@ -166,14 +166,14 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.Foo` [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method secretPrivate()Unit` [accessible: false] `method secretPrivateThis()Unit` [accessible: false] `method secretProtected()Unit` -[accessible: false] `value __leftOfArrowaccessibility.Foo` -[accessible: false] `value __resultOfEnsuringaccessibility.Foo` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Completions.scala(37,8) @@ -209,13 +209,13 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.Foo` [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method secretPrivate()Unit` [accessible: false] `method secretPrivateThis()Unit` [accessible: false] `method secretProtected()Unit` [accessible: false] `method secretProtectedInPackage()Unit` -[accessible: false] `value __leftOfArrowaccessibility.Foo` -[accessible: false] `value __resultOfEnsuringaccessibility.Foo` -[accessible: false] `value selfAny` ================================================================================ diff --git a/test/files/run/backreferences.check b/test/files/run/backreferences.check new file mode 100644 index 0000000000..1d474d5255 --- /dev/null +++ b/test/files/run/backreferences.check @@ -0,0 +1,2 @@ +false +true diff --git a/test/files/run/backreferences.scala b/test/files/run/backreferences.scala new file mode 100644 index 0000000000..335cd6c7de --- /dev/null +++ b/test/files/run/backreferences.scala @@ -0,0 +1,13 @@ +case class Elem[T](x: T, y: T) + +object Test { + def unrolled[T](x: Any, y: Any, z: Any) = (x, y, z) match { + case (el: Elem[_], el.x, el.y) => true + case _ => false + } + + def main(args: Array[String]): Unit = { + println(unrolled(Elem("bippy", 5), "bippy", 6)) + println(unrolled(Elem("bippy", 5), "bippy", 5)) + } +} diff --git a/test/files/run/caseClassHash.check b/test/files/run/caseClassHash.check new file mode 100644 index 0000000000..b5a6f08e99 --- /dev/null +++ b/test/files/run/caseClassHash.check @@ -0,0 +1,9 @@ +Foo(true,-1,-1,d,-5,-10,500.0,500.0,List(),5.0) +Foo(true,-1,-1,d,-5,-10,500.0,500.0,List(),5) +1383698062 +1383698062 +true +## method 1: 1383698062 +## method 2: 1383698062 + Murmur 1: 1383698062 + Murmur 2: 1383698062 diff --git a/test/files/run/caseClassHash.scala b/test/files/run/caseClassHash.scala new file mode 100644 index 0000000000..7adfddedf8 --- /dev/null +++ b/test/files/run/caseClassHash.scala @@ -0,0 +1,37 @@ +case class Foo[T](a: Boolean, b: Byte, c: Short, d: Char, e: Int, f: Long, g: Double, h: Float, i: AnyRef, j: T) { } + +object Test { + def mkFoo[T](x: T) = Foo[T](true, -1, -1, 100, -5, -10, 500d, 500f, Nil, x) + + def main(args: Array[String]): Unit = { + val foo1 = mkFoo[Double](5.0d) + val foo2 = mkFoo[Long](5l) + + List(foo1, foo2, foo1.##, foo2.##, foo1 == foo2) foreach println + + println("## method 1: " + foo1.##) + println("## method 2: " + foo2.##) + println(" Murmur 1: " + scala.util.MurmurHash3.productHash(foo1)) + println(" Murmur 2: " + scala.util.MurmurHash3.productHash(foo2)) + } +} + +object Timing { + var hash = 0 + def mkFoo(i: Int) = Foo(i % 2 == 0, i.toByte, i.toShort, i.toChar, i, i, 1.1, 1.1f, this, this) + + def main(args: Array[String]): Unit = { + val reps = if (args.isEmpty) 100000000 else args(0).toInt + val start = System.nanoTime + + println("Warmup.") + 1 to 10000 foreach mkFoo + + hash = 0 + 1 to reps foreach (i => hash += mkFoo(i).##) + + val end = System.nanoTime + println("hash = " + hash) + println("Elapsed: " + ((end - start) / 1e6) + " ms.") + } +} diff --git a/test/files/run/hashhash.scala b/test/files/run/hashhash.scala index b9cec99a12..f9fc067398 100644 --- a/test/files/run/hashhash.scala +++ b/test/files/run/hashhash.scala @@ -6,5 +6,18 @@ object Test { /** Just a little sanity check, not to be confused with a unit test. */ List(5, 5.5f, "abc", new AnyRef, ()) foreach confirmSame List(5.0f, 1.0d, -(5.0f), (-1.0d)) foreach confirmDifferent + + val x = (BigInt(1) << 64).toDouble + val y: Any = x + val f: Float = x.toFloat + val jn: java.lang.Number = x + val jf: java.lang.Float = x.toFloat + val jd: java.lang.Double = x + + assert(x.## == y.##, ((x, y))) + assert(x.## == f.##, ((x, f))) + assert(x.## == jn.##, ((x, jn))) + assert(x.## == jf.##, ((x, jf))) + assert(x.## == jd.##, ((x, jd))) } } diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check index 5656d1a276..f253de71d6 100644 --- a/test/files/run/names-defaults.check +++ b/test/files/run/names-defaults.check @@ -92,7 +92,7 @@ test5 test5 5 10: 2 -slkdfj1 +slkdfj2 1 lskfdjlk 11 diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index e1bc7cbf59..220414f02a 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -176,7 +176,7 @@ object Test extends App { println(Fact2()("jyp")) println(Fact2(x = 1)()) - println(Fact2(10)().copy(y = "blabla")()) + println(Fact2(10)().copy(y = "blabla")(3)) // assignment to var <-> named argument @@ -195,7 +195,7 @@ object Test extends App { // dependent types and copy method val a11 = new A2 val b11 = a11.B2(new a11.C2)(1) - println(b11.copy()()) + println(b11.copy()(2)) diff --git a/test/files/run/patmat_unapp_abstype-new.check b/test/files/run/patmat_unapp_abstype-new.check index 72239d16cd..42c54631d2 100644 --- a/test/files/run/patmat_unapp_abstype-new.check +++ b/test/files/run/patmat_unapp_abstype-new.check @@ -1,4 +1,4 @@ TypeRef -none of the above +MethodType Bar Foo diff --git a/test/files/run/patmat_unapp_abstype-new.flags b/test/files/run/patmat_unapp_abstype-new.flags deleted file mode 100644 index ba80cad69b..0000000000 --- a/test/files/run/patmat_unapp_abstype-new.flags +++ /dev/null @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/t1247.check b/test/files/run/t1247.check new file mode 100644 index 0000000000..ce123032fd --- /dev/null +++ b/test/files/run/t1247.check @@ -0,0 +1 @@ +Is same closure class: true is same closure: true diff --git a/test/files/run/t1247.scala b/test/files/run/t1247.scala new file mode 100644 index 0000000000..c709b73bc8 --- /dev/null +++ b/test/files/run/t1247.scala @@ -0,0 +1,11 @@ +object Test extends App { + val f = () => 5 + def test(g: => Int) { + val gFunc = g _ + val isSameClosureClass = gFunc.getClass == f.getClass + val isSame = gFunc eq f + println("Is same closure class: "+isSameClosureClass+" is same closure: "+isSame) + } + + test(f()) +} diff --git a/test/files/run/t2296c.check b/test/files/run/t2296c.check new file mode 100644 index 0000000000..076e9180a8 --- /dev/null +++ b/test/files/run/t2296c.check @@ -0,0 +1 @@ +RUNNING ACTION diff --git a/test/files/run/t2296c/Action.java b/test/files/run/t2296c/Action.java new file mode 100644 index 0000000000..50ba9a4de1 --- /dev/null +++ b/test/files/run/t2296c/Action.java @@ -0,0 +1,21 @@ +package bug.action; + +import bug.Global; + +public abstract class Action { + protected Global m_glob; + + public Action(Global glob0) { + m_glob = glob0; + } + + public Action() { + this(null); + } + + public abstract void run(int v); + + public void setGlobal(Global g) { + m_glob = g; + } +} diff --git a/test/files/run/t2296c/Display.java b/test/files/run/t2296c/Display.java new file mode 100644 index 0000000000..7f7e6a73d0 --- /dev/null +++ b/test/files/run/t2296c/Display.java @@ -0,0 +1,9 @@ +package bug; + +public class Display { + protected Global m_glob; + + public void start() { + m_glob.runActions(); + } +} diff --git a/test/files/run/t2296c/Global.java b/test/files/run/t2296c/Global.java new file mode 100644 index 0000000000..7e5a762de2 --- /dev/null +++ b/test/files/run/t2296c/Global.java @@ -0,0 +1,29 @@ +package bug; + +import bug.action.Action; +import java.util.List; +import java.util.LinkedList; + +public class Global { + public int items() { + return 0; + } + + public int items(int i) { + return i + ls.size(); + } + + private List<Action> ls = new LinkedList<Action>(); + + public void putAction(Action a) { + a.setGlobal(this); + ls.add(a); + } + + public void runActions() { + for (Action action: ls) { + System.out.println("RUNNING ACTION"); + action.run(0); + } + } +} diff --git a/test/files/run/t2296c/ScalaActivity.scala b/test/files/run/t2296c/ScalaActivity.scala new file mode 100644 index 0000000000..aa7648a944 --- /dev/null +++ b/test/files/run/t2296c/ScalaActivity.scala @@ -0,0 +1,18 @@ +package test + +import bug.Display +import bug.action.Action + +abstract class Outer extends Display { + + def init() { + m_glob.putAction(ScalaActivity) + } + + object ScalaActivity extends Action { + def run(v: Int) { + val testSet = List(1,2,3) + testSet.map(p => m_glob.items(p)) // crash with illegal access + } + } +} diff --git a/test/files/run/t2296c/Test.scala b/test/files/run/t2296c/Test.scala new file mode 100644 index 0000000000..1132bebebb --- /dev/null +++ b/test/files/run/t2296c/Test.scala @@ -0,0 +1,15 @@ +package test + +import bug.Global + +object Test { + def main(args: Array[String]) { + val m = new Main() + m.init() + m.start() + } +} + +class Main extends Outer { + m_glob = new Global() +} diff --git a/test/files/run/t2296c/a.scala b/test/files/run/t2296c/a.scala new file mode 100644 index 0000000000..fae32f4ec4 --- /dev/null +++ b/test/files/run/t2296c/a.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + test.Test main args + } +} diff --git a/test/files/run/t3702.check b/test/files/run/t3702.check new file mode 100644 index 0000000000..31c2ac4ed1 --- /dev/null +++ b/test/files/run/t3702.check @@ -0,0 +1,2 @@ +() +6 diff --git a/test/files/run/t3702.scala b/test/files/run/t3702.scala new file mode 100644 index 0000000000..021abcb625 --- /dev/null +++ b/test/files/run/t3702.scala @@ -0,0 +1,11 @@ +object Test { + def foo(h: Any, t: List[Any]) = h match { + case 5 :: _ => () + case List(from) => from + } + + def main(args: Array[String]): Unit = { + println(foo(5 :: Nil, List(1,2,3))) + println(foo(6 :: Nil, List(1,2,3))) + } +} diff --git a/test/files/run/t4025.check b/test/files/run/t4025.check new file mode 100644 index 0000000000..6715003cb6 --- /dev/null +++ b/test/files/run/t4025.check @@ -0,0 +1,19 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> class Color(val red: Int) +defined class Color + +scala> + +scala> case class Red(r:Int) extends Color(r) +defined class Red + +scala> + +scala> def f(c: Any) = c match { case Red(_) => () } +f: (c: Any)Unit + +scala> diff --git a/test/files/run/t4025.scala b/test/files/run/t4025.scala new file mode 100644 index 0000000000..5db0093970 --- /dev/null +++ b/test/files/run/t4025.scala @@ -0,0 +1,12 @@ +import scala.tools.nsc.Settings +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +class Color(val red: Int) + +case class Red(r:Int) extends Color(r) + +def f(c: Any) = c match { case Red(_) => () } +""" +} diff --git a/test/files/run/t4124.check b/test/files/run/t4124.check new file mode 100644 index 0000000000..66a0092d93 --- /dev/null +++ b/test/files/run/t4124.check @@ -0,0 +1,4 @@ +hi +hi +bye +bye diff --git a/test/files/run/t4124.scala b/test/files/run/t4124.scala new file mode 100644 index 0000000000..9f35b57ce3 --- /dev/null +++ b/test/files/run/t4124.scala @@ -0,0 +1,24 @@ +import xml.Node + +object Test extends App { + val body: Node = <elem>hi</elem> + println ((body: AnyRef, "foo") match { + case (node: Node, "bar") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body, "foo") match { + case (node: Node, "bar") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body: AnyRef, "foo") match { + case (node: Node, "foo") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body: AnyRef, "foo") match { + case (node: Node, "foo") => "bye" + case (ser: Serializable, "foo") => "hi" + }) +} diff --git a/test/files/run/t4190.check b/test/files/run/t4190.check new file mode 100644 index 0000000000..b8aae0c7a1 --- /dev/null +++ b/test/files/run/t4190.check @@ -0,0 +1,3 @@ +a0 +b0 +c0 diff --git a/test/files/run/t4190.scala b/test/files/run/t4190.scala new file mode 100644 index 0000000000..aa88b8708d --- /dev/null +++ b/test/files/run/t4190.scala @@ -0,0 +1,6 @@ +import collection.mutable._ + +object Test extends App { + val x: ArrayBuffer[String] = ArrayBuffer("a", "b", "c") + x.view map (_ + "0") foreach println +} diff --git a/test/files/run/t4482.check b/test/files/run/t4482.check new file mode 100644 index 0000000000..0cfbf08886 --- /dev/null +++ b/test/files/run/t4482.check @@ -0,0 +1 @@ +2 diff --git a/test/files/run/t4482.scala b/test/files/run/t4482.scala new file mode 100644 index 0000000000..392861c22e --- /dev/null +++ b/test/files/run/t4482.scala @@ -0,0 +1,15 @@ +trait Foo { def i: Int } +trait Bar + +case class Spam(i: Int) extends Foo with Bar + +object Test { + def matchParent(p:Any) = p match { + case f:Foo if f.i == 1 => 1 + case _:Bar => 2 + case _:Foo => 3 + } + def main(args: Array[String]): Unit = { + println(matchParent(Spam(3))) + } +} diff --git a/test/files/run/t5009.check b/test/files/run/t5009.check new file mode 100644 index 0000000000..cc9df54b34 --- /dev/null +++ b/test/files/run/t5009.check @@ -0,0 +1,4 @@ +C(1,true) +10 +C(7283,20) +100 diff --git a/test/files/run/t5009.scala b/test/files/run/t5009.scala new file mode 100644 index 0000000000..b4fe1bc894 --- /dev/null +++ b/test/files/run/t5009.scala @@ -0,0 +1,17 @@ +object Test extends App { + + case class C[T, U <: String, O >: Object](x: Int, y: T)(z: U, b: Boolean)(s: O, val l: Int) + + val c = C(1, true)("dlkfj", true)("dlkfjlk", 10) + println(c) + println(c.l) + + val f1a = c.copy(y = 20, x = 7283) + + val f1b = c.copy[Int, String, Object](y = 20, x = 7283) + val f2b = f1b("lkdjen", false) + val res = f2b(new Object, 100) + println(res) + println(res.l) + +} diff --git a/test/files/run/t5037.check b/test/files/run/t5037.check new file mode 100644 index 0000000000..da29283aaa --- /dev/null +++ b/test/files/run/t5037.check @@ -0,0 +1,2 @@ +true +false diff --git a/test/files/run/t5037.scala b/test/files/run/t5037.scala new file mode 100644 index 0000000000..7b1fce7a82 --- /dev/null +++ b/test/files/run/t5037.scala @@ -0,0 +1,18 @@ +object Test { + def main(args: Array[String]) { + val t = new Test + t.inner.foo() + } +} + +class Test { + class Inner { + def foo() { + println(bar) + bar = false + println(bar) + } + } + val inner = new Inner + private[this] final var bar = true +} diff --git a/test/files/run/t5201.check b/test/files/run/t5201.check new file mode 100644 index 0000000000..27ba77ddaf --- /dev/null +++ b/test/files/run/t5201.check @@ -0,0 +1 @@ +true diff --git a/test/files/run/t5201.scala b/test/files/run/t5201.scala new file mode 100644 index 0000000000..48aa7ba54c --- /dev/null +++ b/test/files/run/t5201.scala @@ -0,0 +1,8 @@ +object Test extends App { + // First make sure specific types are preserved + val tmp: Vector[Int] = Vector(Vector(1,2), Vector(3,4)).view.flatten.force + + // Now make sure we really get a view + val seq = Seq(Seq(1, 2), Seq(3, 4)).view.flatten + Console.println(seq.isInstanceOf[collection.SeqView[_,_]]) +} diff --git a/test/files/run/t5328.check b/test/files/run/t5328.check new file mode 100644 index 0000000000..77a43968c5 --- /dev/null +++ b/test/files/run/t5328.check @@ -0,0 +1,3 @@ +2 +1,2,8 +1,8,3 diff --git a/test/files/run/t5328.scala b/test/files/run/t5328.scala new file mode 100644 index 0000000000..12adf45b84 --- /dev/null +++ b/test/files/run/t5328.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(Vector(1).view.updated(0,2).toList mkString ",") + println(Seq(1,2,3).view.updated(2,8).toList mkString ",") + println(List(1,2,3).view.updated(1,8).toList mkString ",") +} diff --git a/test/files/run/t5394.scala b/test/files/run/t5394.scala new file mode 100644 index 0000000000..1b39da3ac4 --- /dev/null +++ b/test/files/run/t5394.scala @@ -0,0 +1,4 @@ +object Test extends App { + def f[T](l: List[T]): Int = l match { case x :: xs => f(xs) case Nil => 0 } + f(List.fill(10000)(0)) +}
\ No newline at end of file diff --git a/test/files/run/t5407.check b/test/files/run/t5407.check new file mode 100644 index 0000000000..51993f072d --- /dev/null +++ b/test/files/run/t5407.check @@ -0,0 +1,2 @@ +2 +2 diff --git a/test/files/run/t5407.scala b/test/files/run/t5407.scala new file mode 100644 index 0000000000..35a8ec6a45 --- /dev/null +++ b/test/files/run/t5407.scala @@ -0,0 +1,17 @@ +case class Foo(private val x: Int, y: Option[Int], z: Boolean) + +object Test extends App { + def foo(x: Foo) = x match { + case Foo(x, Some(y), z) => y + case Foo(x, y, z) => 0 + } + val x = Foo(1, Some(2), false) + println(foo(x)) + + + def bar(x: Foo) = x match { + case Foo(x, Some(y), z) => y + case Foo(x, None, z) => 0 + } + println(bar(x)) +}
\ No newline at end of file diff --git a/test/files/run/t5527.check b/test/files/run/t5527.check index bb13928fd8..1518168c51 100644 --- a/test/files/run/t5527.check +++ b/test/files/run/t5527.check @@ -1,4 +1,4 @@ -[[syntax trees at end of parser]]// Scala source: newSource1 +[[syntax trees at end of parser]] // newSource1 package <empty> { object UselessComments extends scala.AnyRef { def <init>() = { diff --git a/test/files/run/t5552.check b/test/files/run/t5552.check new file mode 100644 index 0000000000..a19a60840e --- /dev/null +++ b/test/files/run/t5552.check @@ -0,0 +1,2 @@ +(3,3) +(3.0,3.0) diff --git a/test/files/run/t5552.scala b/test/files/run/t5552.scala new file mode 100644 index 0000000000..afb8a1f0be --- /dev/null +++ b/test/files/run/t5552.scala @@ -0,0 +1,10 @@ +class C[@specialized(Int) A](a:A) { + lazy val b = (a, a) + def c = b +} +object Test { + def main(args:Array[String]) { + println(new C(3).c) + println(new C(3.0).c) + } +} diff --git a/test/files/specialized/SI-5005.check b/test/files/specialized/SI-5005.check index 9fc63a2b1d..81e8342dad 100644 --- a/test/files/specialized/SI-5005.check +++ b/test/files/specialized/SI-5005.check @@ -1,4 +1,4 @@ -[[syntax trees at end of specialize]]// Scala source: newSource1 +[[syntax trees at end of specialize]] // newSource1 package <empty> { class C2[@specialized(scala.Boolean) U >: Nothing <: Any] extends Object { def <init>(): C2[U] = { diff --git a/test/pending/neg/t796.scala b/test/pending/neg/t796.scala deleted file mode 100644 index c013f49686..0000000000 --- a/test/pending/neg/t796.scala +++ /dev/null @@ -1,20 +0,0 @@ -case class CaseClass( value: Int ); - -object PatternMatchBug { - def matcher( a: AnyRef, b: Any ) { - (a, b) match { - case ( instance: CaseClass, instance.value ) => - System.out.println( "Match succeeded!" ); - case _ => - System.out.println( "Match failed!" ); - } - } - - def main( args : Array[String] ) { - val caseClassInstance = CaseClass( 42 ) - - matcher( caseClassInstance, 13 ) - matcher( caseClassInstance, 42 ) - } -} - diff --git a/test/pending/pos/t1832.scala b/test/pending/pos/t1832.scala new file mode 100644 index 0000000000..bca863f4bd --- /dev/null +++ b/test/pending/pos/t1832.scala @@ -0,0 +1,10 @@ +// Edit by paulp: reduced. +trait Cloning { + trait Foo + def fn(g: Int => Unit): Foo + + implicit def mkStar(i: Int) = new { def *(a: Foo): Foo = null } + + val pool1 = 4 * fn { case i => i * 2 } + val pool2 = 4 * fn { case i: Int => i * 2 } +} diff --git a/test/pending/pos/t3439.scala b/test/pending/pos/t3439.scala new file mode 100644 index 0000000000..425f1aeeb5 --- /dev/null +++ b/test/pending/pos/t3439.scala @@ -0,0 +1,2 @@ +abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg } +case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg) diff --git a/test/pending/pos/t4717.scala b/test/pending/pos/t4717.scala index 43cf412bc6..7eaa3dd487 100644 --- a/test/pending/pos/t4717.scala +++ b/test/pending/pos/t4717.scala @@ -1,7 +1,7 @@ -trait Bug1[@specialized +A] extends TraversableOnce[A] { - def ++[B >: A](that: TraversableOnce[B]): Iterator[B] = new Iterator[B] { - lazy val it = that.toIterator - def hasNext = it.hasNext - def next = it.next +trait Bounds[@specialized A] { + // okay without `>: A` + def x[B >: A]: Unit = new Bounds[B] { + lazy val it = ??? // def or val okay + it } }
\ No newline at end of file diff --git a/test/pending/pos/t5091.scala b/test/pending/pos/t5091.scala new file mode 100644 index 0000000000..217e83f66d --- /dev/null +++ b/test/pending/pos/t5091.scala @@ -0,0 +1,11 @@ +object RecursiveValueNeedsType { + + def foo(param: String) = 42 + def bar(n: Int) = 42 + + { + val xxx = foo(param = null) + val param = bar(xxx) + } + +} diff --git a/test/pending/pos/t5231.scala b/test/pending/pos/t5231.scala new file mode 100644 index 0000000000..77e6631ebb --- /dev/null +++ b/test/pending/pos/t5231.scala @@ -0,0 +1,18 @@ +object Client { + sealed trait ConfigLike { + def clientID: Int + } + + object Config { + def apply() : ConfigBuilder = new ConfigBuilder() + implicit def build( cb: ConfigBuilder ) : Config = cb.build + } + + final class Config private[Client]( val clientID: Int ) + extends ConfigLike + + final class ConfigBuilder private () extends ConfigLike { + var clientID: Int = 0 + def build : Config = new Config( clientID ) + } +} diff --git a/test/pending/pos/t5265.scala b/test/pending/pos/t5265.scala new file mode 100644 index 0000000000..3be7d2187e --- /dev/null +++ b/test/pending/pos/t5265.scala @@ -0,0 +1,21 @@ +import java.util.Date + +trait TDate + +trait TT[A1,T1] + +trait TTFactory[F,G] { + def create(f: F) : TT[F,G] + def sample: F +} + +object Impls { + + // If the c1 is declared before c2, it compiles fine + implicit def c2(s: Date) = c1.create(s) + + implicit val c1 = new TTFactory[Date,TDate] { + def create(v: Date): TT[Date,TDate] = sys.error("") + def sample = new Date + } +}
\ No newline at end of file diff --git a/test/pending/pos/unapplyGeneric.scala b/test/pending/pos/unapplyGeneric.scala deleted file mode 100644 index bf88816885..0000000000 --- a/test/pending/pos/unapplyGeneric.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Bar { - def unapply[A,B](bar:Bar[A,B]) = Some(bar) -} - -class Bar[A,B](val _1:A, val _2:B) extends Product2[A,B] - -object Test { - new Bar(2, 'a') match { - case Bar(x,y) => - } -} diff --git a/test/pending/pos/z1720.scala b/test/pending/pos/z1720.scala new file mode 100644 index 0000000000..6050f3ff88 --- /dev/null +++ b/test/pending/pos/z1720.scala @@ -0,0 +1,16 @@ +package test + +class Thing { + def info: Info[this.type] = InfoRepository.getInfo(this) + def info2: Info[this.type] = { + def self: this.type = this + InfoRepository.getInfo(self) + } +} + +trait Info[T] +case class InfoImpl[T](thing: T) extends Info[T] + +object InfoRepository { + def getInfo(t: Thing): Info[t.type] = InfoImpl(t) +}
\ No newline at end of file diff --git a/test/pending/presentation/t5708.check b/test/pending/presentation/t5708.check deleted file mode 100644 index 9d944d6cfc..0000000000 --- a/test/pending/presentation/t5708.check +++ /dev/null @@ -1,81 +0,0 @@ -reload: Completions.scala - -askTypeCompletion at Completions.scala(9,9) -================================================================================ -[response] aksTypeCompletion at (9,9) -retrieved 38 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(test.Compat.type, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> test.Compat.type` -[accessible: true] `method →[B](y: B)(test.Compat.type, B)` -[accessible: true] `lazy value fooInt` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: true] `value CONST_STRINGString("constant")` -[accessible: false] `value __leftOfArrowtest.Compat.type` -[accessible: false] `value __resultOfEnsuringtest.Compat.type` -[accessible: false] `value selfAny` -================================================================================ - -askTypeCompletion at Completions.scala(10,9) -================================================================================ -[response] aksTypeCompletion at (10,9) -retrieved 38 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(test.Compat.type, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> test.Compat.type` -[accessible: true] `method →[B](y: B)(test.Compat.type, B)` -[accessible: true] `lazy value fooInt` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: true] `value CONST_STRINGString("constant")` -[accessible: false] `value __leftOfArrowtest.Compat.type` -[accessible: false] `value __resultOfEnsuringtest.Compat.type` -[accessible: false] `value selfAny` -================================================================================ diff --git a/test/pending/presentation/t5708/src/Completions.scala b/test/pending/presentation/t5708/src/Completions.scala deleted file mode 100644 index cc41492df7..0000000000 --- a/test/pending/presentation/t5708/src/Completions.scala +++ /dev/null @@ -1,11 +0,0 @@ -package test - -object Compat { - final val CONST_STRING = "constant" - lazy val foo = 4 -} - -class Foo { - Compat./*!*/CONST_STRING // its 'accessible' flag is false - Compat./*!*/foo // its 'accessible' flag is false -} diff --git a/test/pending/run/t3702.scala b/test/pending/run/t3702.scala deleted file mode 100644 index e08fc12e76..0000000000 --- a/test/pending/run/t3702.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test { - def main(args: Array[String]) { - foo(Nil, Nil) - } - - def foo(h: Any, t: List[Any]) = h match { - case 5 :: _ => () - case List(from) => List(from, from, from) - } -} diff --git a/test/pending/run/t5629.scala b/test/pending/run/t5629.scala deleted file mode 100644 index 28e74a1c94..0000000000 --- a/test/pending/run/t5629.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.{specialized => spec} - -trait GrandParent[@spec(Int) -A] { - def foo(a:A): Unit - def bar[B <: A](b:B): Unit = println("grandparent got: %s" format b) -} - -trait Parent[@spec(Int) -A] extends GrandParent[A] { - def foo(a:A) = bar(a) -} - -class IntChild extends Parent[Int] { - override def bar[B <: Int](b:B): Unit = println("int child got: %s" format b) -} - -class AnyChild extends Parent[Any] { - override def bar[B <: Any](b:B): Unit = println("any child got: %s" format b) -} - -object Test { - def main(args:Array[String]) { - new IntChild().foo(33) - new AnyChild().foo(33) - } -} |