diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/bug1275.check | 8 | ||||
-rw-r--r-- | test/files/neg/bug1275.scala | 29 | ||||
-rw-r--r-- | test/files/neg/bug882.check | 2 | ||||
-rw-r--r-- | test/files/neg/t2416.check | 10 | ||||
-rw-r--r-- | test/files/neg/t2416.scala | 14 | ||||
-rw-r--r-- | test/files/neg/t2462a.check | 4 | ||||
-rw-r--r-- | test/files/neg/t2462a.scala | 3 | ||||
-rw-r--r-- | test/files/neg/t2462b.check | 14 | ||||
-rw-r--r-- | test/files/neg/t2462b.scala | 12 | ||||
-rw-r--r-- | test/files/neg/t3399.check | 4 | ||||
-rw-r--r-- | test/files/neg/t3399.scala | 24 | ||||
-rw-r--r-- | test/files/neg/t3507.check | 4 | ||||
-rw-r--r-- | test/files/neg/t3507.scala | 15 | ||||
-rw-r--r-- | test/files/neg/t3653.check | 7 | ||||
-rw-r--r-- | test/files/neg/t3653.scala | 4 | ||||
-rw-r--r-- | test/files/neg/t3663.check | 4 | ||||
-rw-r--r-- | test/files/neg/t3663/PackageProtected.java | 5 | ||||
-rw-r--r-- | test/files/neg/t3663/main.scala | 14 | ||||
-rw-r--r-- | test/files/neg/t3691.check | 16 | ||||
-rw-r--r-- | test/files/neg/t3691.scala | 11 | ||||
-rw-r--r-- | test/files/neg/t742.check | 5 | ||||
-rw-r--r-- | test/files/neg/t742.scala | 8 |
22 files changed, 199 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 |