summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-02-20 22:46:08 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-02-20 22:48:34 -0800
commit9712cd07ea5bd9acd34d4e7f5ba2180dbdee7fee (patch)
treef432c928c34d95ed3a434cf0673828282d93bd5a /test/files
parent70956e560a11996e1d801d59b312dfe9d56b7a74 (diff)
parent2952d0fa020c003e919dff0eea0bc63f7d52fba8 (diff)
downloadscala-9712cd07ea5bd9acd34d4e7f5ba2180dbdee7fee.tar.gz
scala-9712cd07ea5bd9acd34d4e7f5ba2180dbdee7fee.tar.bz2
scala-9712cd07ea5bd9acd34d4e7f5ba2180dbdee7fee.zip
Merge 2.10.x into master.
Conflicts: build.number src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala src/compiler/scala/tools/nsc/typechecker/Macros.scala test/files/presentation/doc/doc.scala
Diffstat (limited to 'test/files')
-rw-r--r--test/files/pos/annotated-original/C_2.scala7
-rw-r--r--test/files/pos/annotated-original/M_1.scala7
-rw-r--r--test/files/pos/t5744/Macros_1.scala22
-rw-r--r--test/files/pos/t5744/Test_2.scala6
-rw-r--r--test/files/pos/t7091.scala7
-rwxr-xr-xtest/files/presentation/doc/doc.scala22
-rw-r--r--test/files/presentation/ide-t1000567.check1
-rw-r--r--test/files/presentation/ide-t1000567/Runner.scala15
-rw-r--r--test/files/presentation/ide-t1000567/src/a/a.scala5
-rw-r--r--test/files/presentation/ide-t1000567/src/b/b.scala5
-rw-r--r--test/files/presentation/memory-leaks/MemoryLeaksTest.scala2
-rw-r--r--test/files/run/annotatedRetyping.check6
-rw-r--r--test/files/run/annotatedRetyping.scala62
13 files changed, 154 insertions, 13 deletions
diff --git a/test/files/pos/annotated-original/C_2.scala b/test/files/pos/annotated-original/C_2.scala
new file mode 100644
index 0000000000..36a09ffe0c
--- /dev/null
+++ b/test/files/pos/annotated-original/C_2.scala
@@ -0,0 +1,7 @@
+object Bug {
+ M.m {
+ def s = ""
+ M.m(s): @unchecked // error: macro has not been expanded.
+ ???
+ }
+}
diff --git a/test/files/pos/annotated-original/M_1.scala b/test/files/pos/annotated-original/M_1.scala
new file mode 100644
index 0000000000..01654e02cf
--- /dev/null
+++ b/test/files/pos/annotated-original/M_1.scala
@@ -0,0 +1,7 @@
+import language.experimental.macros
+import reflect.macros.Context
+
+object M {
+ def impl(c: Context)(a: c.Expr[Any]) = c.Expr[Any](c.resetLocalAttrs(a.tree))
+ def m(a: Any) = macro impl
+}
diff --git a/test/files/pos/t5744/Macros_1.scala b/test/files/pos/t5744/Macros_1.scala
new file mode 100644
index 0000000000..288a88653d
--- /dev/null
+++ b/test/files/pos/t5744/Macros_1.scala
@@ -0,0 +1,22 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.Context
+
+object Macros {
+ def foo[U: Numeric](x: U) = macro foo_impl[U]
+ def bar[U: Numeric : Equiv, Y <% String](x: U)(implicit s: String) = macro bar_impl[U, Y]
+
+ def foo_impl[U](c: Context)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]]) = {
+ import c.universe._
+ val plusOne = Apply(Select(numeric.tree, newTermName("plus")), List(x.tree, Literal(Constant(1))))
+ val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusOne))
+ c.Expr[Unit](body)
+ }
+
+ def bar_impl[U, Y](c: Context)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]], equiv: c.Expr[Equiv[U]], viewAsString: c.Expr[Y => String], s: c.Expr[String]) = {
+ import c.universe._
+ val plusOne = Apply(Select(numeric.tree, newTermName("plus")), List(x.tree, Literal(Constant(1))))
+ val plusLen = Apply(Select(numeric.tree, newTermName("plus")), List(plusOne, Select(s.tree, newTermName("length"))))
+ val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusLen))
+ c.Expr[Unit](body)
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t5744/Test_2.scala b/test/files/pos/t5744/Test_2.scala
new file mode 100644
index 0000000000..64b57e6032
--- /dev/null
+++ b/test/files/pos/t5744/Test_2.scala
@@ -0,0 +1,6 @@
+object Test extends App {
+ import Macros._
+ foo(42)
+ implicit val s = ""
+ bar(43)
+} \ No newline at end of file
diff --git a/test/files/pos/t7091.scala b/test/files/pos/t7091.scala
new file mode 100644
index 0000000000..72e81a2ea8
--- /dev/null
+++ b/test/files/pos/t7091.scala
@@ -0,0 +1,7 @@
+package p1.p2
+
+protected[p2] class C(var x: Int = 0)
+
+protected[p2] trait T {
+ new C()
+}
diff --git a/test/files/presentation/doc/doc.scala b/test/files/presentation/doc/doc.scala
index 21eabeb284..f9ebd09876 100755
--- a/test/files/presentation/doc/doc.scala
+++ b/test/files/presentation/doc/doc.scala
@@ -7,8 +7,6 @@ import scala.tools.nsc.util._
import scala.tools.nsc.io._
object Test extends InteractiveTest {
- override val settings: doc.Settings = docSettings
-
val tags = Seq(
"@example `\"abb\".permutations = Iterator(abb, bab, bba)`",
"@version 1.0, 09/07/2012",
@@ -29,23 +27,23 @@ object Test extends InteractiveTest {
|class User(c: %sCommented)""".stripMargin.format(comment, tags take nTags mkString "\n", caret)
override lazy val compiler = {
- new {
- override val settings = {
- prepareSettings(Test.this.settings)
- Test.this.settings
- }
- } with Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase {
+ prepareSettings(settings)
+ new Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase {
outer =>
-
val global: this.type = this
- def chooseLink(links: List[LinkTo]): LinkTo = links.head
- def internalLink(sym: Symbol, site: Symbol) = None
- def toString(link: LinkTo) = link.toString
override lazy val analyzer = new {
val global: outer.type = outer
} with doc.ScaladocAnalyzer
+ def chooseLink(links: List[LinkTo]): LinkTo = links.head
+ def internalLink(sym: Symbol, site: Symbol) = None
+ def toString(link: LinkTo) = link.toString
+ def warnNoLink = false
+ def findExternalLink(sym: Symbol, name: String) = None
+
+ override def forScaladoc = true
+
def getComment(sym: Symbol, source: SourceFile) = {
val docResponse = new Response[(String, String, Position)]
askDocComment(sym, sym.owner, source, docResponse)
diff --git a/test/files/presentation/ide-t1000567.check b/test/files/presentation/ide-t1000567.check
new file mode 100644
index 0000000000..6d62cb3e13
--- /dev/null
+++ b/test/files/presentation/ide-t1000567.check
@@ -0,0 +1 @@
+reload: a.scala, b.scala
diff --git a/test/files/presentation/ide-t1000567/Runner.scala b/test/files/presentation/ide-t1000567/Runner.scala
new file mode 100644
index 0000000000..77a618b60a
--- /dev/null
+++ b/test/files/presentation/ide-t1000567/Runner.scala
@@ -0,0 +1,15 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+// also known as SI-5013
+
+object Test extends InteractiveTest {
+
+ override def runDefaultTests(): Unit = {
+ val a = sourceFiles.find(_.file.name == "a.scala").head
+ val b = sourceFiles.find(_.file.name == "b.scala").head
+ askLoadedTyped(a).get
+ askLoadedTyped(b).get
+ super.runDefaultTests()
+ }
+
+}
diff --git a/test/files/presentation/ide-t1000567/src/a/a.scala b/test/files/presentation/ide-t1000567/src/a/a.scala
new file mode 100644
index 0000000000..ee21112a3e
--- /dev/null
+++ b/test/files/presentation/ide-t1000567/src/a/a.scala
@@ -0,0 +1,5 @@
+package a
+
+class Foo {
+ protected[Foo] var x = 0
+}
diff --git a/test/files/presentation/ide-t1000567/src/b/b.scala b/test/files/presentation/ide-t1000567/src/b/b.scala
new file mode 100644
index 0000000000..a0185b15cf
--- /dev/null
+++ b/test/files/presentation/ide-t1000567/src/b/b.scala
@@ -0,0 +1,5 @@
+package b
+
+class Bar extends a.Foo {
+ println(x)
+}
diff --git a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
index 159097cc10..950569c880 100644
--- a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
+++ b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
@@ -25,7 +25,7 @@ import scala.tools.nsc.doc
object Test extends InteractiveTest {
final val mega = 1024 * 1024
- override val settings: doc.Settings = docSettings
+ override val withDocComments = true
override def execute(): Unit = memoryConsumptionTest()
diff --git a/test/files/run/annotatedRetyping.check b/test/files/run/annotatedRetyping.check
new file mode 100644
index 0000000000..b296a80526
--- /dev/null
+++ b/test/files/run/annotatedRetyping.check
@@ -0,0 +1,6 @@
+typing List(1, 2).map(((x) => {
+ val another = scala.Tuple2(t.nt, t.tr): @testAnn match {
+ case scala.Tuple2(_, _) => 1
+ };
+ x
+}))
diff --git a/test/files/run/annotatedRetyping.scala b/test/files/run/annotatedRetyping.scala
new file mode 100644
index 0000000000..cf1b0f27b5
--- /dev/null
+++ b/test/files/run/annotatedRetyping.scala
@@ -0,0 +1,62 @@
+import scala.tools.partest._
+import scala.tools.nsc._
+
+object Test extends DirectTest {
+
+ override def extraSettings: String = "-usejavacp"
+
+ def code = """
+ class testAnn extends annotation.Annotation
+
+ object t {
+ def nt = 1
+ def tr = "a"
+ }
+
+ class Test {
+ List(1,2).map(x => {
+ val another = ((t.nt, t.tr): @testAnn) match { case (_, _) => 1 }
+ x
+ })
+ }
+ """.trim
+
+
+ // point of this test: type-check the "Annotated" tree twice. first time the analyzer plugin types it,
+ // second time the typer.
+
+ // bug was that typedAnnotated assigned a type to the Annotated tree. The second type check would consider
+ // the tree as alreadyTyped, which is not cool, the Annotated needs to be transformed into a Typed tree.
+
+ def show() {
+ val global = newCompiler()
+ import global._
+ import analyzer._
+ import collection.{mutable => m}
+
+ object analyzerPlugin extends AnalyzerPlugin {
+ val templates: m.Map[Symbol, (Template, Typer)] = m.Map()
+ override def pluginsTypeSig(tpe: Type, typer: Typer, defTree: Tree, pt: Type): Type = {
+ defTree match {
+ case impl: Template =>
+ templates += typer.context.owner -> (impl, typer)
+
+ case dd: DefDef if dd.symbol.isPrimaryConstructor && templates.contains(dd.symbol.owner) =>
+ val (impl, templTyper) = templates(dd.symbol.owner)
+ for (stat <- impl.body.filterNot(_.isDef)) {
+ println("typing "+ stat)
+ val statsOwner = impl.symbol orElse templTyper.context.owner.newLocalDummy(impl.pos)
+ val tpr = analyzer.newTyper(templTyper.context.make(stat, statsOwner))
+ tpr.typed(stat)
+ }
+
+ case _ =>
+ }
+ tpe
+ }
+ }
+
+ addAnalyzerPlugin(analyzerPlugin)
+ compileString(global)(code)
+ }
+}