aboutsummaryrefslogtreecommitdiff
path: root/tests/pos
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pos')
-rw-r--r--tests/pos/i1975.scala5
-rw-r--r--tests/pos/i1976.scala4
-rw-r--r--tests/pos/i1990.scala12
-rw-r--r--tests/pos/i1990a.scala20
-rw-r--r--tests/pos/i2009.scala9
-rw-r--r--tests/pos/inferOverloaded.scala41
-rw-r--r--tests/pos/t5604/ReplConfig.scala53
-rw-r--r--tests/pos/t5604/ReplReporter.scala30
-rw-r--r--tests/pos/t5899.scala19
-rw-r--r--tests/pos/t7591.scala86
-rw-r--r--tests/pos/trait-force-info.scala18
11 files changed, 91 insertions, 206 deletions
diff --git a/tests/pos/i1975.scala b/tests/pos/i1975.scala
new file mode 100644
index 000000000..4657a6735
--- /dev/null
+++ b/tests/pos/i1975.scala
@@ -0,0 +1,5 @@
+object Test {
+ val X = Seq(1, 2)
+
+ for (X <- Seq(3, 4)) yield println(X)
+}
diff --git a/tests/pos/i1976.scala b/tests/pos/i1976.scala
new file mode 100644
index 000000000..32967977d
--- /dev/null
+++ b/tests/pos/i1976.scala
@@ -0,0 +1,4 @@
+object Test {
+ import scala.xml._
+ val node = <node>{ "whatever " }</node>
+}
diff --git a/tests/pos/i1990.scala b/tests/pos/i1990.scala
new file mode 100644
index 000000000..77cea0af7
--- /dev/null
+++ b/tests/pos/i1990.scala
@@ -0,0 +1,12 @@
+class A {
+ class Foo {
+ inline def inlineMeth: Unit = {
+ new Bar
+ }
+ }
+ class Bar
+}
+
+class B extends A {
+ (new Foo).inlineMeth
+}
diff --git a/tests/pos/i1990a.scala b/tests/pos/i1990a.scala
new file mode 100644
index 000000000..f6f95ee36
--- /dev/null
+++ b/tests/pos/i1990a.scala
@@ -0,0 +1,20 @@
+class A { self =>
+ class Foo {
+ inline def inlineMeth: Unit = {
+ println(self)
+ }
+ }
+}
+
+class C extends A {
+ class B extends A
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val c = new C
+ val b = new c.B
+
+ (new b.Foo).inlineMeth
+ }
+}
diff --git a/tests/pos/i2009.scala b/tests/pos/i2009.scala
new file mode 100644
index 000000000..e2cf47203
--- /dev/null
+++ b/tests/pos/i2009.scala
@@ -0,0 +1,9 @@
+object Test {
+
+ trait Gen[T] {
+ def map[U](f: T => U): Gen[U] = ???
+ }
+
+ def f[T](implicit g: Gen[T]): Gen[() => T] =
+ g map ( () => _ )
+}
diff --git a/tests/pos/inferOverloaded.scala b/tests/pos/inferOverloaded.scala
new file mode 100644
index 000000000..e7179a04a
--- /dev/null
+++ b/tests/pos/inferOverloaded.scala
@@ -0,0 +1,41 @@
+class MySeq[T] {
+ def map1[U](f: T => U): MySeq[U] = new MySeq[U]
+ def map2[U](f: T => U): MySeq[U] = new MySeq[U]
+}
+
+class MyMap[A, B] extends MySeq[(A, B)] {
+ def map1[C](f: (A, B) => C): MySeq[C] = new MySeq[C]
+ def map1[C, D](f: (A, B) => (C, D)): MyMap[C, D] = new MyMap[C, D]
+ def map1[C, D](f: ((A, B)) => (C, D)): MyMap[C, D] = new MyMap[C, D]
+
+ def foo(f: Function2[Int, Int, Int]): Unit = ()
+ def foo[R](pf: PartialFunction[(A, B), R]): MySeq[R] = new MySeq[R]
+}
+
+object Test {
+ val m = new MyMap[Int, String]
+
+ // This one already worked because it is not overloaded:
+ m.map2 { case (k, v) => k - 1 }
+
+ // These already worked because preSelectOverloaded eliminated the non-applicable overload:
+ m.map1(t => t._1)
+ m.map1((kInFunction, vInFunction) => kInFunction - 1)
+ val r1 = m.map1(t => (t._1, 42.0))
+ val r1t: MyMap[Int, Double] = r1
+
+ // These worked because the argument types are known for overload resolution:
+ m.map1({ case (k, v) => k - 1 }: PartialFunction[(Int, String), Int])
+ m.map2({ case (k, v) => k - 1 }: PartialFunction[(Int, String), Int])
+
+ // These ones did not work before:
+ m.map1 { case (k, v) => k }
+ val r = m.map1 { case (k, v) => (k, k*10) }
+ val rt: MyMap[Int, Int] = r
+ m.foo { case (k, v) => k - 1 }
+
+ // Used to be ambiguous but overload resolution now favors PartialFunction
+ def h[R](pf: Function2[Int, String, R]): Unit = ()
+ def h[R](pf: PartialFunction[(Double, Double), R]): Unit = ()
+ h { case (a: Double, b: Double) => 42: Int }
+}
diff --git a/tests/pos/t5604/ReplConfig.scala b/tests/pos/t5604/ReplConfig.scala
deleted file mode 100644
index 8c589eba6..000000000
--- a/tests/pos/t5604/ReplConfig.scala
+++ /dev/null
@@ -1,53 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2011 LAMP/EPFL
- * @author Paul Phillips
- */
-
-package scala.tools.nsc
-package interpreter
-
-import util.Exceptional.unwrap
-import util.stackTraceString
-
-trait ReplConfig {
- lazy val replProps = new ReplProps
-
- class TapMaker[T](x: T) {
- def tapInfo(msg: => String): T = tap(x => replinfo(parens(x)))
- def tapDebug(msg: => String): T = tap(x => repldbg(parens(x)))
- def tapTrace(msg: => String): T = tap(x => repltrace(parens(x)))
- def tap[U](f: T => U): T = {
- f(x)
- x
- }
- }
-
- private def parens(x: Any) = "(" + x + ")"
- private def echo(msg: => String) =
- try Console println msg
- catch { case x: AssertionError => Console.println("Assertion error printing debugging output: " + x) }
-
- private[nsc] def repldbg(msg: => String) = if (isReplDebug) echo(msg)
- private[nsc] def repltrace(msg: => String) = if (isReplTrace) echo(msg)
- private[nsc] def replinfo(msg: => String) = if (isReplInfo) echo(msg)
-
- private[nsc] def logAndDiscard[T](label: String, alt: => T): PartialFunction[Throwable, T] = {
- case t =>
- repldbg(label + ": " + unwrap(t))
- repltrace(stackTraceString(unwrap(t)))
- alt
- }
- private[nsc] def substituteAndLog[T](alt: => T)(body: => T): T =
- substituteAndLog("" + alt, alt)(body)
- private[nsc] def substituteAndLog[T](label: String, alt: => T)(body: => T): T = {
- try body
- catch logAndDiscard(label, alt)
- }
- private[nsc] def squashAndLog(label: String)(body: => Unit): Unit =
- substituteAndLog(label, ())(body)
-
- def isReplTrace: Boolean = replProps.trace
- def isReplDebug: Boolean = replProps.debug || isReplTrace
- def isReplInfo: Boolean = replProps.info || isReplDebug
- def isReplPower: Boolean = replProps.power
-}
diff --git a/tests/pos/t5604/ReplReporter.scala b/tests/pos/t5604/ReplReporter.scala
deleted file mode 100644
index 9423efd8a..000000000
--- a/tests/pos/t5604/ReplReporter.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2002-2011 LAMP/EPFL
- * @author Paul Phillips
- */
-
-package scala.tools.nsc
-package interpreter
-
-import reporters._
-import IMain._
-
-class ReplReporter(intp: IMain) extends ConsoleReporter(intp.settings, Console.in, new ReplStrippingWriter(intp)) {
- override def printMessage(msg: String): Unit = {
- // Avoiding deadlock if the compiler starts logging before
- // the lazy val is complete.
- if (intp.isInitializeComplete) {
- if (intp.totalSilence) {
- if (isReplTrace)
- super.printMessage("[silent] " + msg)
- }
- else super.printMessage(msg)
- }
- else Console.println("[init] " + msg)
- }
-
- override def displayPrompt(): Unit = {
- if (intp.totalSilence) ()
- else super.displayPrompt()
- }
-}
diff --git a/tests/pos/t5899.scala b/tests/pos/t5899.scala
deleted file mode 100644
index 852b4e3e7..000000000
--- a/tests/pos/t5899.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-import scala.tools.nsc._
-
-trait Foo {
- val global: Global
- import global.{Name, Symbol, nme}
-
- case class Bippy(name: Name)
-
- def f(x: Bippy, sym: Symbol): Int = {
- // no warning (!) for
- // val Stable = sym.name.toTermName
-
- val Stable = sym.name
- Bippy(Stable) match {
- case Bippy(nme.WILDCARD) => 1
- case Bippy(Stable) => 2 // should not be considered unreachable
- }
- }
-}
diff --git a/tests/pos/t7591.scala b/tests/pos/t7591.scala
deleted file mode 100644
index dd127b881..000000000
--- a/tests/pos/t7591.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-/* NEST (New Scala Test)
- * Copyright 2007-2013 LAMP/EPFL
- * @author Paul Phillips
- */
-
-import scala.tools.cmd._
-
-/** A sample command specification for illustrative purposes.
- * First take advantage of the meta-options:
- *
- * // this command creates an executable runner script "demo"
- * % scala scala.tools.cmd.Demo --self-update demo
- *
- * // this one creates and sources a completion file - note backticks
- * % `./demo --bash`
- *
- * // and now you have a runner with working completion
- * % ./demo --<tab>
- * --action --defint --int
- * --bash --defstr --str
- * --defenv --self-update --unary
- *
- * The normal option configuration is plausibly self-explanatory.
- */
-trait DemoSpec extends Spec with Meta.StdOpts with Interpolation {
- lazy val referenceSpec = DemoSpec
- lazy val programInfo = Spec.Info("demo", "Usage: demo [<options>]", "scala.tools.cmd.Demo")
-
- help("""Usage: demo [<options>]""")
- heading("Unary options:")
-
- val optIsUnary = "unary" / "a unary option" --? ;
- ("action" / "a body which may be run") --> println("Hello, I am the --action body.")
-
- heading("Binary options:")
- val optopt = "str" / "an optional String" --|
- val optoptInt = ("int" / "an optional Int") . --^[Int]
- val optEnv = "defenv" / "an optional String" defaultToEnv "PATH"
- val optDefault = "defstr" / "an optional String" defaultTo "default"
- val optDefaultInt = "defint" / "an optional Int" defaultTo -1
- val optExpand = "alias" / "an option which expands" expandTo ("--int", "15")
-}
-
-object DemoSpec extends DemoSpec with Property {
- lazy val propMapper = new PropertyMapper(DemoSpec)
-
- type ThisCommandLine = SpecCommandLine
- def creator(args: List[String]) =
- new SpecCommandLine(args) {
- override def errorFn(msg: String) = { println("Error: " + msg) ; sys.exit(0) }
- }
-}
-
-class Demo(args: List[String]) extends DemoSpec with Instance {
-// TODO NEEDS MANUAL CHANGE (early initializers)
-// BEGIN copied early initializers
-val parsed = DemoSpec(args: _*)
-// END copied early initializers
-
- import java.lang.reflect._
-
- def helpMsg = DemoSpec.helpMsg
- def demoSpecMethods = this.getClass.getMethods.toList
- private def isDemo(m: Method) = (m.getName startsWith "opt") && !(m.getName contains "$") && (m.getParameterTypes.isEmpty)
-
- def demoString(ms: List[Method]) = {
- val longest = ms map (_.getName.length) max
- val formatStr = " %-" + longest + "s: %s"
- val xs = ms map (m => formatStr.format(m.getName, m.invoke(this)))
-
- xs mkString ("Demo(\n ", "\n ", "\n)\n")
- }
-
- override def toString = demoString(demoSpecMethods filter isDemo)
-}
-
-object Demo {
- def main(args: Array[String]): Unit = {
- val runner = new Demo(args.toList)
-
- if (args.isEmpty)
- println(runner.helpMsg)
-
- println(runner)
- }
-}
diff --git a/tests/pos/trait-force-info.scala b/tests/pos/trait-force-info.scala
deleted file mode 100644
index c2b33869c..000000000
--- a/tests/pos/trait-force-info.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-/** This does NOT crash unless it's in the interactive package.
- */
-
-package scala.tools.nsc
-package interactive
-
-trait MyContextTrees {
- val self: Global
- val NoContext = self.analyzer.NoContext
-}
-//
-// error: java.lang.AssertionError: assertion failed: trait Contexts.NoContext$ linkedModule: <none>List()
-// at scala.Predef$.assert(Predef.scala:160)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.innerSymbol$1(ClassfileParser.scala:1211)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.classSymbol(ClassfileParser.scala:1223)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser.classNameToSymbol(ClassfileParser.scala:489)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:757)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:789)