summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/class-symbol-contravariant.check36
-rw-r--r--test/files/run/class-symbol-contravariant.scala15
-rw-r--r--test/files/run/constrained-types.check8
-rw-r--r--test/files/run/parserJavaIdent.check26
-rw-r--r--test/files/run/parserJavaIdent.scala26
-rw-r--r--test/files/run/reflection-magicsymbols-repl.check2
-rw-r--r--test/files/run/t4172.check2
-rw-r--r--test/files/run/t4710.check2
-rw-r--r--test/files/run/t6028.check2
-rw-r--r--test/files/run/t6259.scala56
-rw-r--r--test/files/run/t6329_repl.check2
-rw-r--r--test/files/run/t6506.scala8
-rw-r--r--test/files/run/t6666a.scala16
-rw-r--r--test/files/run/t6957.scala8
-rw-r--r--test/files/run/t7096.check2
-rw-r--r--test/files/run/t7096.scala36
16 files changed, 238 insertions, 9 deletions
diff --git a/test/files/run/class-symbol-contravariant.check b/test/files/run/class-symbol-contravariant.check
new file mode 100644
index 0000000000..987f215bca
--- /dev/null
+++ b/test/files/run/class-symbol-contravariant.check
@@ -0,0 +1,36 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> :power
+** Power User mode enabled - BEEP WHIR GYVE **
+** :phase has been set to 'typer'. **
+** scala.tools.nsc._ has been imported **
+** global._, definitions._ also imported **
+** Try :help, :vals, power.<tab> **
+
+scala> val u = rootMirror.universe
+u: $r.intp.global.type = <global>
+
+scala> import u._, scala.reflect.internal.Flags
+import u._
+import scala.reflect.internal.Flags
+
+scala> class C
+defined class C
+
+scala> val sym = u.typeOf[C].typeSymbol
+sym: u.Symbol = class C
+
+scala> sym.isContravariant
+res0: Boolean = false
+
+scala> sym setFlag Flags.INCONSTRUCTOR
+res1: sym.type = class C
+
+scala> sym.isClassLocalToConstructor
+res2: Boolean = true
+
+scala> sym.isContravariant // was true
+res3: Boolean = false
+
+scala>
diff --git a/test/files/run/class-symbol-contravariant.scala b/test/files/run/class-symbol-contravariant.scala
new file mode 100644
index 0000000000..6a84944e3b
--- /dev/null
+++ b/test/files/run/class-symbol-contravariant.scala
@@ -0,0 +1,15 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ override def code = """
+ |:power
+ |val u = rootMirror.universe
+ |import u._, scala.reflect.internal.Flags
+ |class C
+ |val sym = u.typeOf[C].typeSymbol
+ |sym.isContravariant
+ |sym setFlag Flags.INCONSTRUCTOR
+ |sym.isClassLocalToConstructor
+ |sym.isContravariant // was true
+ |""".stripMargin.trim
+} \ No newline at end of file
diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check
index da97a378e6..85c4f41872 100644
--- a/test/files/run/constrained-types.check
+++ b/test/files/run/constrained-types.check
@@ -75,11 +75,11 @@ scala> var four = "four"
four: String = four
scala> val four2 = m(four) // should have an existential bound
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
four2: String @Annot(x) forSome { val x: String } = four
scala> val four3 = four2 // should have the same type as four2
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
four3: String @Annot(x) forSome { val x: String } = four
scala> val stuff = m("stuff") // should not crash
@@ -102,7 +102,7 @@ scala> def m = {
val y : String @Annot(x) = x
y
} // x should not escape the local scope with a narrow type
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
m: String @Annot(x) forSome { val x: String }
scala>
@@ -116,7 +116,7 @@ scala> def n(y: String) = {
}
m("stuff".stripMargin)
} // x should be existentially bound
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
n: (y: String)String @Annot(x) forSome { val x: String }
scala>
diff --git a/test/files/run/parserJavaIdent.check b/test/files/run/parserJavaIdent.check
new file mode 100644
index 0000000000..597ddbee47
--- /dev/null
+++ b/test/files/run/parserJavaIdent.check
@@ -0,0 +1,26 @@
+[1.7] parsed: simple
+[1.8] parsed: with123
+[1.6] parsed: with$
+[1.10] parsed: withøßöèæ
+[1.6] parsed: with_
+[1.6] parsed: _with
+[1.1] failure: java identifier expected
+
+3start
+^
+[1.1] failure: java identifier expected
+
+-start
+^
+[1.5] failure: java identifier expected
+
+with-s
+ ^
+[1.3] failure: java identifier expected
+
+we♥scala
+ ^
+[1.6] failure: java identifier expected
+
+with space
+ ^
diff --git a/test/files/run/parserJavaIdent.scala b/test/files/run/parserJavaIdent.scala
new file mode 100644
index 0000000000..c068075e4e
--- /dev/null
+++ b/test/files/run/parserJavaIdent.scala
@@ -0,0 +1,26 @@
+object Test extends scala.util.parsing.combinator.JavaTokenParsers {
+
+ def test[A](s: String) {
+ val res = parseAll(ident, s) match {
+ case Failure(_, in) => Failure("java identifier expected", in)
+ case o => o
+ }
+ println(res)
+ }
+
+ def main(args: Array[String]) {
+ // Happy tests
+ test("simple")
+ test("with123")
+ test("with$")
+ test("withøßöèæ")
+ test("with_")
+ test("_with")
+ // Sad tests
+ test("3start")
+ test("-start")
+ test("with-s")
+ test("we♥scala")
+ test("with space")
+ }
+}
diff --git a/test/files/run/reflection-magicsymbols-repl.check b/test/files/run/reflection-magicsymbols-repl.check
index d3cd26f25f..2535e3f43d 100644
--- a/test/files/run/reflection-magicsymbols-repl.check
+++ b/test/files/run/reflection-magicsymbols-repl.check
@@ -23,7 +23,7 @@ scala> def test(n: Int): Unit = {
val x = sig.asInstanceOf[MethodType].params.head
println(x.typeSignature)
}
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
test: (n: Int)Unit
scala> for (i <- 1 to 8) test(i)
diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check
index 94cdff4870..b48c9ca056 100644
--- a/test/files/run/t4172.check
+++ b/test/files/run/t4172.check
@@ -4,7 +4,7 @@ Type :help for more information.
scala>
scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) }
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
c: (C, C{def f: Int}) forSome { type C <: AnyRef } = (C,C)
scala>
diff --git a/test/files/run/t4710.check b/test/files/run/t4710.check
index 7c2b10b098..f2335d1bdd 100644
--- a/test/files/run/t4710.check
+++ b/test/files/run/t4710.check
@@ -2,7 +2,7 @@ Type in expressions to have them evaluated.
Type :help for more information.
scala> def method : String = { implicit def f(s: Symbol) = "" ; 'symbol }
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
method: String
scala>
diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check
index 79deaacf3a..94013efd36 100644
--- a/test/files/run/t6028.check
+++ b/test/files/run/t6028.check
@@ -81,4 +81,4 @@ package <empty> {
}
}
-warning: there were 1 feature warnings; re-run with -feature for details
+warning: there were 1 feature warning(s); re-run with -feature for details
diff --git a/test/files/run/t6259.scala b/test/files/run/t6259.scala
new file mode 100644
index 0000000000..294c95e96b
--- /dev/null
+++ b/test/files/run/t6259.scala
@@ -0,0 +1,56 @@
+import scala.reflect.runtime.universe._
+
+class A[X](implicit val tt: TypeTag[X]) {}
+object B extends A[String]
+
+object C {
+ object D extends A[String]
+}
+
+trait E {
+ object F extends A[String]
+}
+
+class G {
+ object H extends A[String]
+}
+
+object HasX {
+ val x = {
+ object InVal extends A[String]
+ InVal
+ 5
+ }
+
+}
+
+trait NeedsEarly {
+ val x: AnyRef
+}
+
+object Early extends {
+ // Drops to this.getClass and is not ok...
+ val x = { object EarlyOk extends A[String]; EarlyOk }
+} with NeedsEarly
+
+
+class DoubleTrouble[X](x: AnyRef)(implicit override val tt: TypeTag[X]) extends A[X]
+
+object DoubleOk extends DoubleTrouble[String]({
+ // Drops to this.getClass and is an issue
+ object InnerTrouble extends A[String];
+ InnerTrouble
+})
+
+object Test extends App {
+ B
+ C.D
+ val e = new E {}; e.F
+ val g = new G; g.H
+
+ locally(HasX.x)
+ // locally(Early.x) TODO sort out VerifyError in Early$.<init>
+ // DoubleOk TODO sort out VerifyError in DoubleOk$.<init>
+}
+
+
diff --git a/test/files/run/t6329_repl.check b/test/files/run/t6329_repl.check
index 8663184bde..693263a5c2 100644
--- a/test/files/run/t6329_repl.check
+++ b/test/files/run/t6329_repl.check
@@ -4,7 +4,7 @@ Type :help for more information.
scala>
scala> classManifest[List[_]]
-warning: there were 1 deprecation warnings; re-run with -deprecation for details
+warning: there were 1 deprecation warning(s); re-run with -deprecation for details
res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[Any]
scala> scala.reflect.classTag[List[_]]
diff --git a/test/files/run/t6506.scala b/test/files/run/t6506.scala
new file mode 100644
index 0000000000..04d77c3c16
--- /dev/null
+++ b/test/files/run/t6506.scala
@@ -0,0 +1,8 @@
+object Test {
+ def main(args: Array[String]) {
+ new WL(new {} #:: S) with T
+ }
+ object S { def #::(a: Any): Any = () }
+ trait T
+ class WL(a: Any)
+}
diff --git a/test/files/run/t6666a.scala b/test/files/run/t6666a.scala
new file mode 100644
index 0000000000..1d208a32e7
--- /dev/null
+++ b/test/files/run/t6666a.scala
@@ -0,0 +1,16 @@
+class A(a: Any)
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ }
+
+ val x: Unit = {
+ object InVal extends A({
+ new {} // okay
+ val o = {new {}} // nesting triggers a VerifyError.
+ null
+ });
+ InVal;
+ ()
+ };
+}
diff --git a/test/files/run/t6957.scala b/test/files/run/t6957.scala
new file mode 100644
index 0000000000..d0bf8e7b5e
--- /dev/null
+++ b/test/files/run/t6957.scala
@@ -0,0 +1,8 @@
+object Test {
+ def main(args: Array[String]) {
+ class Foo
+ class Parent(f:Foo)
+ class Child extends Parent({val x=new Foo{}; x})
+ new Child
+ }
+}
diff --git a/test/files/run/t7096.check b/test/files/run/t7096.check
new file mode 100644
index 0000000000..6f1cef6c43
--- /dev/null
+++ b/test/files/run/t7096.check
@@ -0,0 +1,2 @@
+testing symbol List(method foo, class Base, package ano, package <root>), param value x, xRefs List(x)
+testing symbol List(method foo, class Sub, package ano, package <root>), param value x, xRefs List(x)
diff --git a/test/files/run/t7096.scala b/test/files/run/t7096.scala
new file mode 100644
index 0000000000..e9c0323c2e
--- /dev/null
+++ b/test/files/run/t7096.scala
@@ -0,0 +1,36 @@
+import scala.tools.partest._
+import scala.tools.nsc._
+
+object Test extends CompilerTest {
+ import global._
+ import definitions._
+
+ override def code = """
+package ano
+
+class ann(x: Any) extends annotation.TypeConstraint
+
+abstract class Base {
+ def foo(x: String): String @ann(x.trim())
+}
+
+class Sub extends Base {
+ def foo(x: String): String @ann(x.trim()) = x
+}
+ """
+
+ object syms extends SymsInPackage("ano")
+ import syms._
+
+ def check(source: String, unit: global.CompilationUnit) {
+ afterTyper {
+ terms.filter(_.name.toString == "foo").foreach(sym => {
+ val xParam = sym.tpe.paramss.flatten.head
+ val annot = sym.tpe.finalResultType.annotations.head
+ val xRefs = annot.args.head.filter(t => t.symbol == xParam)
+ println(s"testing symbol ${sym.ownerChain}, param $xParam, xRefs $xRefs")
+ assert(xRefs.length == 1, xRefs)
+ })
+ }
+ }
+}