diff options
Diffstat (limited to 'test/files')
40 files changed, 319 insertions, 18 deletions
diff --git a/test/files/neg/bug1275.check b/test/files/neg/bug1275.check index 9f806c0689..6ee8365796 100644 --- a/test/files/neg/bug1275.check +++ b/test/files/neg/bug1275.check @@ -1,4 +1,6 @@ -bug1275.scala:13: error: The kind of type MyType does not conform to the expected kind of type MyType[+t] <: TestCovariance.Seq[t] in trait Seq. - def span[a, s <: Seq[a] { type MyType <: s } ](xs: s): s = xs f - ^ +bug1275.scala:11: error: type mismatch; + found : xs.MyType[a] + required: s + = xs f + ^ one error found diff --git a/test/files/neg/bug1275.scala b/test/files/neg/bug1275.scala index e9be13c763..1175b30763 100644 --- a/test/files/neg/bug1275.scala +++ b/test/files/neg/bug1275.scala @@ -1,14 +1,15 @@ -// tested using Scala compiler version 2.6.0-RC1 -- (c) 2002-2010 LAMP/EPFL - -// prompted by "Covariant return types" mailing list question -object TestCovariance { - - // see Type constructor polymorphism in http://www.scala-lang.org/docu/changelog.html - trait Seq[+t] { - type MyType[+t] <: Seq[t] - - def f: MyType[t] - } - - def span[a, s <: Seq[a] { type MyType <: s } ](xs: s): s = xs f -} +object Test { + trait Seq[+t] { + type MyType[+t] <: Seq[t] + + def f: MyType[t] + } + + // illegal abstract type member refinement: changes the arity of MyType + // the error is pretty strange, since the compiler forms the illegal type xs.MyType[a] anyway + def span[a, s <: Seq[a] { type MyType/*look ma, no type parameters!*/ <: s } ](xs: s): s + = xs f +// ^ +// found : xs.MyType[a] +// required: s +}
\ No newline at end of file diff --git a/test/files/neg/bug882.check b/test/files/neg/bug882.check index 8f47fefd9b..4e3e6d0860 100644 --- a/test/files/neg/bug882.check +++ b/test/files/neg/bug882.check @@ -1,4 +1,4 @@ -bug882.scala:2: error: traits cannot have type parameters with context bounds `: ...' +bug882.scala:2: error: traits cannot have type parameters with context bounds `: ...' nor view bounds `<% ...' trait SortedSet[A <% Ordered[A]] { ^ one error found diff --git a/test/files/neg/t2416.check b/test/files/neg/t2416.check new file mode 100644 index 0000000000..0899ad09d5 --- /dev/null +++ b/test/files/neg/t2416.check @@ -0,0 +1,10 @@ +t2416.scala:3: error: type arguments [Int] do not conform to trait A's type parameter bounds [X <: Double] + def x : A[Int]#B = 10 // no you won't + ^ +t2416.scala:8: error: type arguments [Boolean] do not conform to type B's type parameter bounds [Y <: Double] + def x : A#B[Boolean] = 10 // seriously? + ^ +t2416.scala:13: error: type arguments [String] do not conform to type B's type parameter bounds [Z <: Double] + type C[Z <: A] = Z#B[String] // nuh-uh! + ^ +three errors found diff --git a/test/files/neg/t2416.scala b/test/files/neg/t2416.scala new file mode 100644 index 0000000000..6bb57a984b --- /dev/null +++ b/test/files/neg/t2416.scala @@ -0,0 +1,14 @@ +object t2416a { + trait A[X <: Double] { type B = X } + def x : A[Int]#B = 10 // no you won't +} + +object t2416b { + trait A{type B[Y <: Double] = Int} + def x : A#B[Boolean] = 10 // seriously? +} + +object t2416c { + trait A{type B[Z <: Double] = Int} + type C[Z <: A] = Z#B[String] // nuh-uh! +}
\ No newline at end of file diff --git a/test/files/neg/t2462a.check b/test/files/neg/t2462a.check new file mode 100644 index 0000000000..040a01f3a1 --- /dev/null +++ b/test/files/neg/t2462a.check @@ -0,0 +1,4 @@ +t2462a.scala:2: error: Cannot construct a collection of type List[String] with elements of type Int based on a collection of type List[String]. + List(1,2,3).map[Int, List[String]](x => 1) + ^ +one error found diff --git a/test/files/neg/t2462a.scala b/test/files/neg/t2462a.scala new file mode 100644 index 0000000000..2d523b4dd8 --- /dev/null +++ b/test/files/neg/t2462a.scala @@ -0,0 +1,3 @@ +object Test { + List(1,2,3).map[Int, List[String]](x => 1) +}
\ No newline at end of file diff --git a/test/files/neg/t2462b.check b/test/files/neg/t2462b.check new file mode 100644 index 0000000000..bc0d9aa469 --- /dev/null +++ b/test/files/neg/t2462b.check @@ -0,0 +1,14 @@ +t2462b.scala:6: warning: Invalid implicitNotFound message for trait Meh in package test: +The type parameters Too, Elem referenced in the message of the @implicitNotFound annotation are not defined by trait Meh. +trait Meh[-From, +To] + ^ +t2462b.scala:9: warning: Invalid implicitNotFound message for trait Meh2 in package test: +The type parameter Elem referenced in the message of the @implicitNotFound annotation is not defined by trait Meh2. +trait Meh2[-From, +To] + ^ +t2462b.scala:12: error: overriding method x in class thankyoupartest of type => Int; + method x needs `override' modifier +class testmustfail extends thankyoupartest { def x = 43 } + ^ +two warnings found +one error found diff --git a/test/files/neg/t2462b.scala b/test/files/neg/t2462b.scala new file mode 100644 index 0000000000..7a1389cc8e --- /dev/null +++ b/test/files/neg/t2462b.scala @@ -0,0 +1,12 @@ +package test + +import scala.annotation.implicitNotFound + +@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") +trait Meh[-From, +To] + +@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") +trait Meh2[-From, +To] + +class thankyoupartest { def x = 42 } +class testmustfail extends thankyoupartest { def x = 43 } diff --git a/test/files/neg/t3399.check b/test/files/neg/t3399.check new file mode 100644 index 0000000000..eb6c679704 --- /dev/null +++ b/test/files/neg/t3399.check @@ -0,0 +1,4 @@ +t3399.scala:23: error: could not find implicit value for parameter e: =:=[Nats.Add[Nats._1,Nats._1],Nats._1] + implicitly[ Add[_1, _1] =:= _1] + ^ +one error found diff --git a/test/files/neg/t3399.scala b/test/files/neg/t3399.scala new file mode 100644 index 0000000000..3edaa0724f --- /dev/null +++ b/test/files/neg/t3399.scala @@ -0,0 +1,24 @@ +object Nats { + sealed trait Nat { + // fold right on N, N-1, ..., 1 + type FoldR[Init <: Type, Type, F <: Fold[Nat, Type]] <: Type + } + sealed trait _0 extends Nat { + type FoldR[Init <: Type, Type, F <: Fold[Nat, Type]] = Init + } + sealed trait Succ[N <: Nat] extends Nat { + type FoldR[Init <: Type, Type, F <: Fold[Nat, Type]] = + F#Apply[Succ[N], N#FoldR[Init, Type, F]] + } + + type Add[A <: Nat, B <: Nat] = A#FoldR[B, Nat, Inc] + trait Fold[-Elem, Value] { + type Apply[N <: Elem, Acc <: Value] <: Value + } + type Inc = Fold[Any, Nat] { + type Apply[N <: Any, Acc <: Nat] = Succ[Acc] + } + + type _1 = Succ[_0] + implicitly[ Add[_1, _1] =:= _1] +}
\ No newline at end of file diff --git a/test/files/neg/t3507.check b/test/files/neg/t3507.check new file mode 100644 index 0000000000..1246a20d09 --- /dev/null +++ b/test/files/neg/t3507.check @@ -0,0 +1,4 @@ +t3507.scala:13: error: could not find implicit value for evidence parameter of type Manifest[object _1.b.c] + mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier + ^ +one error found diff --git a/test/files/neg/t3507.scala b/test/files/neg/t3507.scala new file mode 100644 index 0000000000..9a8c7c5462 --- /dev/null +++ b/test/files/neg/t3507.scala @@ -0,0 +1,15 @@ +class A { + object b { + object c + } + def m = b.c +} + +object Test { + var a: A = new A // mutable + val c /*: object _1.b.c forSome { val _1: A } */ = a.m // widening using existential + + def mani[T: Manifest](x: T) = () + mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier + // --> _1 is not in scope here +}
\ No newline at end of file diff --git a/test/files/neg/t3653.check b/test/files/neg/t3653.check new file mode 100644 index 0000000000..ac6e2ca9dc --- /dev/null +++ b/test/files/neg/t3653.check @@ -0,0 +1,7 @@ +t3653.scala:3: error: double definition: +method x:(implicit x: Int)Int and +method x:(i: Int)Int at line 2 +have same type after erasure: (x: Int)Int + def x(implicit x: Int) = 5 + ^ +one error found diff --git a/test/files/neg/t3653.scala b/test/files/neg/t3653.scala new file mode 100644 index 0000000000..96cf96008a --- /dev/null +++ b/test/files/neg/t3653.scala @@ -0,0 +1,4 @@ +class B { + def x(i: Int) = 3 + def x(implicit x: Int) = 5 +}
\ No newline at end of file diff --git a/test/files/neg/t3663.check b/test/files/neg/t3663.check new file mode 100644 index 0000000000..09ea25ad91 --- /dev/null +++ b/test/files/neg/t3663.check @@ -0,0 +1,4 @@ +main.scala:11: error: variable foo cannot be accessed in test.Test + println(t.foo) + ^ +one error found diff --git a/test/files/neg/t3663/PackageProtected.java b/test/files/neg/t3663/PackageProtected.java new file mode 100644 index 0000000000..f4535a55b4 --- /dev/null +++ b/test/files/neg/t3663/PackageProtected.java @@ -0,0 +1,5 @@ +package test; + +class PackageProtected { + int foo; +} diff --git a/test/files/neg/t3663/main.scala b/test/files/neg/t3663/main.scala new file mode 100644 index 0000000000..29619550cc --- /dev/null +++ b/test/files/neg/t3663/main.scala @@ -0,0 +1,14 @@ +package test + +final class Test extends PackageProtected { + def bar = foo +} + +package another { + object Main { + def bug(t: Test) { + // Can always be replicated. + println(t.foo) + } + } +}
\ No newline at end of file diff --git a/test/files/neg/t3691.check b/test/files/neg/t3691.check new file mode 100644 index 0000000000..1b548cc84d --- /dev/null +++ b/test/files/neg/t3691.check @@ -0,0 +1,16 @@ +t3691.scala:4: error: type mismatch; + found : java.lang.Object with Test.A[String] + required: AnyRef{type A[x]} + val b = (new A[String]{}): { type A[x] } // not ok + ^ +t3691.scala:5: error: type mismatch; + found : java.lang.Object with Test.A[String] + required: AnyRef{type A} + val c = (new A[String]{}): { type A } // not ok + ^ +t3691.scala:7: error: type mismatch; + found : java.lang.Object{type A = String} + required: AnyRef{type A[X]} + val x = (new { type A = String }): { type A[X] } // not ok + ^ +three errors found diff --git a/test/files/neg/t3691.scala b/test/files/neg/t3691.scala new file mode 100644 index 0000000000..69e8bef630 --- /dev/null +++ b/test/files/neg/t3691.scala @@ -0,0 +1,11 @@ +object Test { + trait A[X] { type A[x <: X] = x } + val a = (new A[String]{}): { type A[x <: String] } // ok + val b = (new A[String]{}): { type A[x] } // not ok + val c = (new A[String]{}): { type A } // not ok + + val x = (new { type A = String }): { type A[X] } // not ok +//a: AnyRef{type A[X]} + + identity[x.A[Any]] _ +}
\ No newline at end of file diff --git a/test/files/neg/t742.check b/test/files/neg/t742.check new file mode 100644 index 0000000000..f587948ef1 --- /dev/null +++ b/test/files/neg/t742.check @@ -0,0 +1,5 @@ +t742.scala:5: error: kinds of the type arguments (Crash._1,Crash._2,Any) do not conform to the expected kinds of the type parameters (type m,type n,type z). +Crash._1's type parameters do not match type m's expected parameters: type s1 has one type parameter, but type n has two + type p = mul[_1, _2, Any] // mul[_1, _1, Any] needs -Yrecursion + ^ +one error found diff --git a/test/files/neg/t742.scala b/test/files/neg/t742.scala new file mode 100644 index 0000000000..bb1c2f85ea --- /dev/null +++ b/test/files/neg/t742.scala @@ -0,0 +1,8 @@ +object Crash { + type mul[m[n[s[_], z], z], n[s[_], z], z] = m[n, z] + type _1[s1[_], z1] = s1[z1] + type _2[s1[_], z1] = s1[z1] + type p = mul[_1, _2, Any] // mul[_1, _1, Any] needs -Yrecursion + // _1[_2, Zero] + // _2[Zero] +}
\ No newline at end of file diff --git a/test/files/pos/nothing_manifest_disambig.scala b/test/files/pos/nothing_manifest_disambig.scala new file mode 100644 index 0000000000..9a3db0c6d4 --- /dev/null +++ b/test/files/pos/nothing_manifest_disambig.scala @@ -0,0 +1,10 @@ +object Test { + def mani[T: Manifest](xs: T) = xs + mani(List()) + + def listElMani[T: Manifest](xs: List[T]) = xs + listElMani(List()) + + def foo[A, C](m : C)(implicit ev: C <:< Traversable[A], mani: Manifest[A]): (C, A, Manifest[A]) = (m, m.head, mani) + foo(List(1,2,3)) +}
\ No newline at end of file diff --git a/test/files/pos/t2331.scala b/test/files/pos/t2331.scala new file mode 100644 index 0000000000..9a15b5c2a9 --- /dev/null +++ b/test/files/pos/t2331.scala @@ -0,0 +1,11 @@ +trait C { + def m[T]: T +} + +object Test { + val o /*: C --> no crash*/ = new C { + def m[T]: Nothing /*: T --> no crash*/ = error("omitted") + } + + o.m[Nothing] +}
\ No newline at end of file diff --git a/test/files/pos/t3249/Test.java b/test/files/pos/t3249/Test.java new file mode 100644 index 0000000000..4cc7cb2ab5 --- /dev/null +++ b/test/files/pos/t3249/Test.java @@ -0,0 +1,5 @@ +public class Test { + public static void meh() { + new A<Integer>().f(); + } +}
\ No newline at end of file diff --git a/test/files/pos/t3249/a.scala b/test/files/pos/t3249/a.scala new file mode 100644 index 0000000000..0394464549 --- /dev/null +++ b/test/files/pos/t3249/a.scala @@ -0,0 +1,11 @@ +class A[U] { def f[T] = { class X extends A[T] } } + + +/* +$ scalac a.scala +$ javac -cp .:$SCALA_HOME/lib/scala-library.jar -Xprint 'A$X$1' + + public class X$1 extends A<java.lang.Object> implements scala.ScalaObject { + public X$1(A<U> null); + } +*/
\ No newline at end of file diff --git a/test/files/pos/t3374.scala b/test/files/pos/t3374.scala new file mode 100644 index 0000000000..4c0293181d --- /dev/null +++ b/test/files/pos/t3374.scala @@ -0,0 +1,6 @@ +trait Parent { + type Test[A, H[B <: A]] +} +trait Sub extends Parent { + type Test[AS, HS[B <: AS]] = AS +}
\ No newline at end of file diff --git a/test/files/pos/t3419/B_1.scala b/test/files/pos/t3419/B_1.scala new file mode 100644 index 0000000000..a8ec7edba4 --- /dev/null +++ b/test/files/pos/t3419/B_1.scala @@ -0,0 +1,3 @@ +trait T[A,B] { + type X[a <: A, b <: B] <: B +}
\ No newline at end of file diff --git a/test/files/pos/t3419/C_2.scala b/test/files/pos/t3419/C_2.scala new file mode 100644 index 0000000000..da721d2c31 --- /dev/null +++ b/test/files/pos/t3419/C_2.scala @@ -0,0 +1,3 @@ +object F { + type S = T[Any,Int] {type X[N <: Int, Acc <: Int] = Acc} +}
\ No newline at end of file diff --git a/test/files/pos/t3477.scala b/test/files/pos/t3477.scala new file mode 100644 index 0000000000..660aa55736 --- /dev/null +++ b/test/files/pos/t3477.scala @@ -0,0 +1,7 @@ +class J3 { + def f[K, K1 >: K, V](x: Map[K1, V]): Map[K, V] = error("") +} + +object Test { + (new J3).f(Map[Int, Int]()) +}
\ No newline at end of file diff --git a/test/files/pos/t3486/JTest.java b/test/files/pos/t3486/JTest.java new file mode 100644 index 0000000000..0bf388b72d --- /dev/null +++ b/test/files/pos/t3486/JTest.java @@ -0,0 +1,3 @@ +public class JTest<A> extends T2<A> { + public A m( A a ) { return a; } +}
\ No newline at end of file diff --git a/test/files/pos/t3486/test.scala b/test/files/pos/t3486/test.scala new file mode 100644 index 0000000000..544232b0d1 --- /dev/null +++ b/test/files/pos/t3486/test.scala @@ -0,0 +1,6 @@ +trait Test[A] { + def m( a: A ): A + def specified(a:A):A = a +} + +abstract class T2[A] extends Test[A]
\ No newline at end of file diff --git a/test/files/pos/t3494.scala b/test/files/pos/t3494.scala new file mode 100644 index 0000000000..35a4bcde5d --- /dev/null +++ b/test/files/pos/t3494.scala @@ -0,0 +1,7 @@ +object Test { + def f[T](xs: T*) = () + + val x = "abc" + + f[x.type](x) +}
\ No newline at end of file diff --git a/test/files/pos/t3582.scala b/test/files/pos/t3582.scala new file mode 100644 index 0000000000..0ac112efbf --- /dev/null +++ b/test/files/pos/t3582.scala @@ -0,0 +1,12 @@ +trait C[A] +object Test { + def ImplicitParamCA[CC[A], A](implicit ev: C[A]) {implicitly[C[A]]} // must use this exact syntax... + // error: could not find implicit value for parameter e: C[A] +} +// [[syntax trees at end of typer]] +// abstract trait C#5[A#9116 >: Nothing#5832 <: Any#52] extends scala#33.AnyRef#2780; +// final object Test#15 extends java.lang.Object#2485 with ScalaObject#1913 { +// def ImplicitParamCA#9123[CC#9124[A#10858 >: Nothing#5832 <: Any#52] >: [A#10858]Nothing#5832 <: [A#10858]Any#52, +// A#9125 >: Nothing#5832 <: Any#52](implicit ev#10856: C#5[A#9127]): Unit#3818 +// = scala#34.this.Predef#1683.implicitly#8816[C#5[A#10858]]() +// } diff --git a/test/files/pos/t3582b.scala b/test/files/pos/t3582b.scala new file mode 100644 index 0000000000..8f0bfb9b2a --- /dev/null +++ b/test/files/pos/t3582b.scala @@ -0,0 +1,5 @@ +object ParamScoping { + // scoping worked fine in the result type, but was wrong in body + // reason: typedTypeDef needs new context, which was set up by typed1 but not by typedDefDef and typedClassDef + def noOverlapFOwithHO[T, G[T]]: G[T] = null.asInstanceOf[G[T]] +}
\ No newline at end of file diff --git a/test/files/pos/t3622/test/AsyncTask.java b/test/files/pos/t3622/test/AsyncTask.java new file mode 100644 index 0000000000..cfcea3fe1a --- /dev/null +++ b/test/files/pos/t3622/test/AsyncTask.java @@ -0,0 +1,5 @@ +package test; + +public abstract class AsyncTask<Params, Progress, Result> { + protected abstract Result doInBackground(Params... args); +}
\ No newline at end of file diff --git a/test/files/pos/t3622/test/MyAsyncTask.java b/test/files/pos/t3622/test/MyAsyncTask.java new file mode 100644 index 0000000000..9ef4947052 --- /dev/null +++ b/test/files/pos/t3622/test/MyAsyncTask.java @@ -0,0 +1,9 @@ +package test; + +public abstract class MyAsyncTask extends AsyncTask<String, String, String> { + protected abstract String doInBackground1(String[] args); + @Override + protected String doInBackground(String... args) { + return doInBackground1(new String[]{"dummy"}); + } +}
\ No newline at end of file diff --git a/test/files/pos/t3622/test/Test.scala b/test/files/pos/t3622/test/Test.scala new file mode 100644 index 0000000000..fb82c581f9 --- /dev/null +++ b/test/files/pos/t3622/test/Test.scala @@ -0,0 +1,5 @@ +package test + +class Test extends MyAsyncTask { + protected[test] def doInBackground1(args: Array[String]): String = "" +}
\ No newline at end of file diff --git a/test/files/pos/t3676.scala b/test/files/pos/t3676.scala new file mode 100644 index 0000000000..60c0ceaec8 --- /dev/null +++ b/test/files/pos/t3676.scala @@ -0,0 +1,5 @@ +trait SeqLike[+Repr] +trait Seq extends SeqLike[Seq] + +trait MySeq extends Seq with SeqLike[MySub] +trait MySub extends MySeq diff --git a/test/files/pos/t3777.scala b/test/files/pos/t3777.scala new file mode 100644 index 0000000000..165eeebfdb --- /dev/null +++ b/test/files/pos/t3777.scala @@ -0,0 +1,7 @@ +object Test { + type Point = Map[Symbol, String] + type Points = IndexedSeq[Point] + + def makePoints2: Points = IndexedSeq[Point]() + val spoints2 = util.Random.shuffle(makePoints2) +} |