diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-16 22:30:24 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-16 22:34:16 -0700 |
commit | 0c3ca2248d55eeeee2db6693e5fc46b9ba049eda (patch) | |
tree | 71686d0b99fc1d4a245ddb24efe50398b0c00c78 /test/files | |
parent | c663ecf8677eda3fe8c91170b614eb7166b18711 (diff) | |
parent | 13b4628aabb8e7a293a382dcab6db5848f672f94 (diff) | |
download | scala-0c3ca2248d55eeeee2db6693e5fc46b9ba049eda.tar.gz scala-0c3ca2248d55eeeee2db6693e5fc46b9ba049eda.tar.bz2 scala-0c3ca2248d55eeeee2db6693e5fc46b9ba049eda.zip |
Merge branch 'master' into HEAD
* master:
SI-7469 Remove @deprecated scala.util.logging
SI-3943 Test case for already-fixed Java interop bug
Fix formatting for couple of docs in the compiler
SI-7476 Add documentation to GenericTraversableTemplate
SI-7469 Remove @deprecated scala.util.parsing.ast
SI-7469 Remove @deprecated MurmurHash elements
SI-7469 Remove deprecated elements in s.u.parsing.combinator
SI-7469 Make @deprecated elems in scala.concurrent private[scala]
removes duplication in inferImplicitValue
SI-7047 fixes silent for c.inferImplicitXXX
SI-7167 implicit macros decide what is divergence
macroExpandAll is now triggered in all invocations of typed
SI-5923 instantiates targs in deferred macro applications
SI-6406 Restore deprecated API
SI-6039 Harden against irrelevant filesystem details
Limit unnecessary calls to Type#toString.
fix typo in comment
SI-7432 add testcases
SI-7432 Range.min should throw NoSuchElementException on empty range
AbstractFile.getDirectory does not return null when outDir is "."
Conflicts:
src/compiler/scala/tools/nsc/typechecker/Typers.scala
Diffstat (limited to 'test/files')
27 files changed, 173 insertions, 16 deletions
diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala index 2fab650637..75777a5b94 100644 --- a/test/files/jvm/xml01.scala +++ b/test/files/jvm/xml01.scala @@ -1,7 +1,6 @@ import java.io.StringReader import org.xml.sax.InputSource -import scala.util.logging._ import scala.xml._ object Test extends App { diff --git a/test/files/neg/macro-divergence-controlled.check b/test/files/neg/macro-divergence-controlled.check new file mode 100644 index 0000000000..4876f7cf96 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: could not find implicit value for parameter e: Complex[Foo] + println(implicitly[Complex[Foo]]) + ^ +one error found diff --git a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala new file mode 100644 index 0000000000..59acaede65 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Complex[T] + +class Foo(val foo: Foo) + +object Complex { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { + import c.universe._ + val tpe = weakTypeOf[T] + for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { + val trecur = appliedType(typeOf[Complex[_]], List(f.typeSignature)) + if (c.openImplicits.tail.exists(ic => ic.pt =:= trecur)) c.abort(c.enclosingPosition, "diverging implicit expansion. reported by a macro!") + val recur = c.inferImplicitValue(trecur, silent = true) + if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") + } + c.literalNull + } + + implicit object ComplexString extends Complex[String] + implicit def genComplex[T]: Complex[T] = macro impl[T] +} diff --git a/test/files/neg/macro-divergence-controlled/Test_2.scala b/test/files/neg/macro-divergence-controlled/Test_2.scala new file mode 100644 index 0000000000..dcc4593335 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(implicitly[Complex[Foo]]) +}
\ No newline at end of file diff --git a/test/files/neg/t6406-regextract.check b/test/files/neg/t6406-regextract.check index 4fea66f760..19425a68b0 100644 --- a/test/files/neg/t6406-regextract.check +++ b/test/files/neg/t6406-regextract.check @@ -1,7 +1,6 @@ -t6406-regextract.scala:4: error: cannot resolve overloaded unapply +t6406-regextract.scala:4: warning: method unapplySeq in class Regex is deprecated: Extracting a match result from anything but a CharSequence or Match is deprecated List(1) collect { case r(i) => i } ^ -t6406-regextract.scala:4: error: not found: value i - List(1) collect { case r(i) => i } - ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/tailrec-2.check b/test/files/neg/tailrec-2.check index d3432a7e76..1daad6922e 100644 --- a/test/files/neg/tailrec-2.check +++ b/test/files/neg/tailrec-2.check @@ -1,4 +1,4 @@ -tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targeting supertype Super[A] +tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targeting a supertype @annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Super[A]).f(mem) ^ tailrec-2.scala:9: error: @tailrec annotated method contains no recursive calls diff --git a/test/files/pos/t1648.scala b/test/files/pos/t1648.scala deleted file mode 100644 index 6d53ce11ee..0000000000 --- a/test/files/pos/t1648.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - class MyClass extends scala.util.logging.Logged { } - val x = new MyClass with scala.util.logging.ConsoleLogger -} diff --git a/test/files/pos/t3943/Client_2.scala b/test/files/pos/t3943/Client_2.scala new file mode 100644 index 0000000000..650ac9b7a9 --- /dev/null +++ b/test/files/pos/t3943/Client_2.scala @@ -0,0 +1,7 @@ +object Test { + val x: Child = new Child + x.getInner.foo("meh") +// error: type mismatch; +// found : java.lang.String("meh") +// required: E +} diff --git a/test/files/pos/t3943/Outer_1.java b/test/files/pos/t3943/Outer_1.java new file mode 100644 index 0000000000..1d38c5e76b --- /dev/null +++ b/test/files/pos/t3943/Outer_1.java @@ -0,0 +1,14 @@ +class Outer<E> { + abstract class Inner { + abstract public void foo(E e); + } +} + +class Child extends Outer<String> { + // the implicit prefix for Inner is Outer<E> instead of Outer<String> + public Inner getInner() { + return new Inner() { + public void foo(String e) { System.out.println("meh "+e); } + }; + } +} diff --git a/test/files/pos/t5692c.check b/test/files/pos/t5692c.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/t5692c.check diff --git a/test/files/pos/t5692c.scala b/test/files/pos/t5692c.scala new file mode 100644 index 0000000000..fa5f0b2dcd --- /dev/null +++ b/test/files/pos/t5692c.scala @@ -0,0 +1,4 @@ +class C { + def foo[T: scala.reflect.ClassTag](xs: T*): Array[T] = ??? + foo() +}
\ No newline at end of file diff --git a/test/files/run/macro-divergence-spurious.check b/test/files/run/macro-divergence-spurious.check new file mode 100644 index 0000000000..19765bd501 --- /dev/null +++ b/test/files/run/macro-divergence-spurious.check @@ -0,0 +1 @@ +null diff --git a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala new file mode 100644 index 0000000000..bc4a9fded7 --- /dev/null +++ b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Complex[T] + +class Foo(val bar: Bar) +class Bar(val s: String) + +object Complex { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { + import c.universe._ + val tpe = weakTypeOf[T] + for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { + val trecur = appliedType(typeOf[Complex[_]], List(f.typeSignature)) + val recur = c.inferImplicitValue(trecur, silent = true) + if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") + } + c.literalNull + } + + implicit object ComplexString extends Complex[String] + implicit def genComplex[T]: Complex[T] = macro impl[T] +} diff --git a/test/files/run/macro-divergence-spurious/Test_2.scala b/test/files/run/macro-divergence-spurious/Test_2.scala new file mode 100644 index 0000000000..dcc4593335 --- /dev/null +++ b/test/files/run/macro-divergence-spurious/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(implicitly[Complex[Foo]]) +}
\ No newline at end of file diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala index 5f3f61ca3f..8d7d3b5d3d 100644 --- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala @@ -7,7 +7,7 @@ object Macros { val inscope = c.inferImplicitValue(c.mirror.staticClass("SourceLocation").toType) val outer = c.Expr[SourceLocation](if (!inscope.isEmpty) inscope else Literal(Constant(null))) - val Apply(fun, args) = c.enclosingImplicits(0)._2 + val Apply(fun, args) = c.enclosingImplicits(0).tree val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala index 535ec2ccf0..4c165ed1b8 100644 --- a/test/files/run/macro-sip19/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.Context object Macros { def impl(c: Context) = { import c.universe._ - val Apply(fun, args) = c.enclosingImplicits(0)._2 + val Apply(fun, args) = c.enclosingImplicits(0).tree val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point diff --git a/test/files/run/range.scala b/test/files/run/range.scala index f08b2105d3..b81e67921a 100644 --- a/test/files/run/range.scala +++ b/test/files/run/range.scala @@ -16,6 +16,17 @@ object Test { catch { case _: IllegalArgumentException => true } ) assert(caught) + // #7432 + val noElemAtMin = ( + try { (10 until 10).min ; false } + catch { case _: NoSuchElementException => true } + ) + assert(noElemAtMin) + val noElemAtMax = ( + try { (10 until 10).max ; false } + catch { case _: NoSuchElementException => true } + ) + assert(noElemAtMax) } case class GR[T](val x: T)(implicit val num: Integral[T]) { diff --git a/test/files/run/t5923a.check b/test/files/run/t5923a.check new file mode 100644 index 0000000000..7165b734ac --- /dev/null +++ b/test/files/run/t5923a.check @@ -0,0 +1,3 @@ +C(Int) +C(String) +C(Nothing) diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala new file mode 100644 index 0000000000..6d21362c4d --- /dev/null +++ b/test/files/run/t5923a/Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +case class C[T](t: String) +object C { + implicit def foo[T]: C[T] = macro Macros.impl[T] +} + +object Macros { + def impl[T: c.WeakTypeTag](c: Context) = { + import c.universe._ + reify(C[T](c.literal(weakTypeOf[T].toString).splice)) + } +}
\ No newline at end of file diff --git a/test/files/run/t5923a/Test_2.scala b/test/files/run/t5923a/Test_2.scala new file mode 100644 index 0000000000..001ff9aea8 --- /dev/null +++ b/test/files/run/t5923a/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(implicitly[C[Int]]) + println(implicitly[C[String]]) + println(implicitly[C[Nothing]]) +}
\ No newline at end of file diff --git a/test/files/run/t5923b.check b/test/files/run/t5923b.check new file mode 100644 index 0000000000..d56076f84e --- /dev/null +++ b/test/files/run/t5923b.check @@ -0,0 +1,3 @@ +class [Ljava.lang.Object; +class [Ljava.lang.Object; +class [Ljava.lang.Object; diff --git a/test/files/run/t5923b/Test.scala b/test/files/run/t5923b/Test.scala new file mode 100644 index 0000000000..7c2627462a --- /dev/null +++ b/test/files/run/t5923b/Test.scala @@ -0,0 +1,7 @@ +object Test extends App { + import scala.collection.generic.CanBuildFrom + val cbf = implicitly[CanBuildFrom[Nothing, Nothing, Array[Nothing]]] + println(cbf().result.getClass) + println(new Array[Nothing](0).getClass) + println(Array[Nothing]().getClass) +}
\ No newline at end of file diff --git a/test/files/run/t6039.scala b/test/files/run/t6039.scala new file mode 100644 index 0000000000..9d811b0634 --- /dev/null +++ b/test/files/run/t6039.scala @@ -0,0 +1,18 @@ +import scala.tools.partest._ + +object Test extends StoreReporterDirectTest { + private def compileCode(): Boolean = { + new java.io.File("util") mkdirs + val classpath = List(sys.props("partest.lib"), ".") mkString sys.props("path.separator") + log(s"classpath = $classpath") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(packageCode) + } + def code = ??? + def packageCode = """ +package scala.bippy +class A { new util.Random() } +""" + def show(): Unit = { + assert(compileCode(), filteredInfos take 1 mkString "") + } +} diff --git a/test/files/run/t7047.check b/test/files/run/t7047.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t7047.check diff --git a/test/files/run/t7047/Impls_Macros_1.scala b/test/files/run/t7047/Impls_Macros_1.scala new file mode 100644 index 0000000000..2992e3efe4 --- /dev/null +++ b/test/files/run/t7047/Impls_Macros_1.scala @@ -0,0 +1,19 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +class Foo + +object Macros { + def impl(c: Context) = { + import c.universe._ + try { + c.inferImplicitValue(typeOf[Foo], silent = false) + c.abort(c.enclosingPosition, "silent=false is not working") + } catch { + case _: Exception => + } + c.literalNull + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/t7047/Test_2.scala b/test/files/run/t7047/Test_2.scala new file mode 100644 index 0000000000..acfddae942 --- /dev/null +++ b/test/files/run/t7047/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo +}
\ No newline at end of file diff --git a/test/files/scalacheck/avl.scala b/test/files/scalacheck/avl.scala index af79ad49e3..02003bd271 100644 --- a/test/files/scalacheck/avl.scala +++ b/test/files/scalacheck/avl.scala @@ -2,14 +2,12 @@ import org.scalacheck.Gen import org.scalacheck.Prop.forAll import org.scalacheck.Properties -import util.logging.ConsoleLogger - package scala.collection.mutable { /** * Property of an AVL Tree : Any node of the tree has a balance value beetween in [-1; 1] */ - abstract class AVLTreeTest(name: String) extends Properties(name) with ConsoleLogger { + abstract class AVLTreeTest(name: String) extends Properties(name) { def `2^`(n: Int) = (1 to n).fold(1)((a, b) => b*2) |