diff options
author | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-12-16 16:38:09 +0100 |
---|---|---|
committer | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-12-16 16:38:09 +0100 |
commit | 42851ed2675015d42bb341b82a09bd0bef4a8ce4 (patch) | |
tree | 06806b4183cf74a43553e9a8a9acfeff84fdf712 /tests/pending | |
parent | 5be609fc4e04e3cca5e1435ee41b8cacac9b0513 (diff) | |
download | dotty-42851ed2675015d42bb341b82a09bd0bef4a8ce4.tar.gz dotty-42851ed2675015d42bb341b82a09bd0bef4a8ce4.tar.bz2 dotty-42851ed2675015d42bb341b82a09bd0bef4a8ce4.zip |
move failing tests from tests/untried/pos to tests/pending/pos
Diffstat (limited to 'tests/pending')
494 files changed, 9309 insertions, 0 deletions
diff --git a/tests/pending/pos/CustomGlobal.scala b/tests/pending/pos/CustomGlobal.scala new file mode 100644 index 000000000..a5668bd7c --- /dev/null +++ b/tests/pending/pos/CustomGlobal.scala @@ -0,0 +1,33 @@ +package custom + +import scala.tools.nsc._, reporters._, typechecker._ + +/** Demonstration of a custom Global with a custom Typer, + * decoupled from trunk. Demonstration: + * +{{{ +scalac -d . CustomGlobal.scala && scala -nc -Yglobal-class custom.CustomGlobal \ + -e 'class Bippy(x: Int) ; def f = new Bippy(5)' + +I'm typing a Bippy! It's a ClassDef. +I'm typing a Bippy! It's a Ident. +I'm typing a Bippy! It's a DefDef. +}}} + * + */ +class CustomGlobal(currentSettings: Settings, reporter: Reporter) extends Global(currentSettings, reporter) { + override lazy val analyzer = new { + val global: CustomGlobal.this.type = CustomGlobal.this + } with Analyzer { + override def newTyper(context: Context): Typer = new CustomTyper(context) + + class CustomTyper(context : Context) extends Typer(context) { + override def typed(tree: Tree, mode: Mode, pt: Type): Tree = { + if (tree.summaryString contains "Bippy") + println("I'm typing a Bippy! It's a " + tree.shortClass + ".") + + super.typed(tree, mode, pt) + } + } + } +} diff --git a/tests/pending/pos/List1.scala b/tests/pending/pos/List1.scala new file mode 100644 index 000000000..30ebf5e1e --- /dev/null +++ b/tests/pending/pos/List1.scala @@ -0,0 +1,45 @@ +object lists { + + abstract class List[a] { + def isEmpty: Boolean; + def head: a; + def tail: List[a]; + def prepend(x: a) = Cons[a](x, this); + } + + def Nil[b] = new List[b] { + def isEmpty: Boolean = true; + def head = sys.error("head of Nil"); + def tail = sys.error("tail of Nil"); + } + + def Cons[c](x: c, xs: List[c]): List[c] = new List[c] { + def isEmpty = false; + def head = x; + def tail = xs; + } + + def foo = { + val intnil = Nil[Int]; + val intlist = intnil.prepend(1).prepend(1+1); + val x: Int = intlist.head; + val strnil = Nil[String]; + val strlist = strnil.prepend("A").prepend("AA"); + val y: String = strlist.head; + () + } + + class IntList() extends List[Int] { + def isEmpty: Boolean = false; + def head: Int = 1; + def foo: List[Int] { def isEmpty: Boolean; def head: Int; def tail: List[Int] } = Nil[Int]; + def tail0: List[Int] = foo.prepend(1).prepend(1+1); + def tail: List[Int] = Nil[Int].prepend(1).prepend(1+1); + } + + def foo2 = { + val il1 = new IntList(); + val il2 = il1.prepend(1).prepend(2); + () + } +} diff --git a/tests/pending/pos/MailBox.scala b/tests/pending/pos/MailBox.scala new file mode 100644 index 000000000..8e27bd362 --- /dev/null +++ b/tests/pending/pos/MailBox.scala @@ -0,0 +1,84 @@ +package test; + +import scala.actors.TIMEOUT; + +class MailBox { + + private class LinkedList[a] { + var elem: a = _; + var next: LinkedList[a] = null; + } + + private def insert[a](l: LinkedList[a], x: a): LinkedList[a] = { + l.next = new LinkedList[a]; + l.next.elem = x; + l.next.next = l.next; + l + } + + private abstract class Receiver { + def isDefined(msg: Any): Boolean; + var msg: Any = null; + } + + private val sent = new LinkedList[Any]; + private var lastSent = sent; + private val receivers = new LinkedList[Receiver]; + private var lastReceiver = receivers; + + def send(msg: Any): Unit = synchronized { + var r = receivers; + var r1 = r.next; + while (r1 != null && !r1.elem.isDefined(msg)) { + r = r1; r1 = r1.next; + } + if (r1 != null) { + r.next = r1.next; r1.elem.msg = msg; r1.elem.notify(); + } else { + lastSent = insert(lastSent, msg); + } + } + + def receive[a](f: PartialFunction[Any, a]): a = { + val msg: Any = synchronized { + var s = sent; + var s1 = s.next; + while (s1 != null && !f.isDefinedAt(s1.elem)) { + s = s1; s1 = s1.next + } + if (s1 != null) { + s.next = s1.next; s1.elem + } else { + val r = insert(lastReceiver, new Receiver { + def isDefined(msg: Any) = f.isDefinedAt(msg); + }); + lastReceiver = r; + r.elem.wait(); + r.elem.msg + } + } + f(msg) + } + + def receiveWithin[a](msec: Long)(f: PartialFunction[Any, a]): a = { + val msg: Any = synchronized { + var s = sent; + var s1 = s.next; + while (s1 != null && !f.isDefinedAt(s1.elem)) { + s = s1; s1 = s1.next ; + } + if (s1 != null) { + s.next = s1.next; s1.elem + } else { + val r = insert(lastReceiver, new Receiver { + def isDefined(msg: Any) = f.isDefinedAt(msg); + }); + lastReceiver = r; + r.elem.wait(msec); + if (r.elem.msg == null) r.elem.msg = TIMEOUT; + r.elem.msg + } + } + f(msg) + } +} diff --git a/tests/pending/pos/NoCyclicReference.scala b/tests/pending/pos/NoCyclicReference.scala new file mode 100644 index 000000000..e42896661 --- /dev/null +++ b/tests/pending/pos/NoCyclicReference.scala @@ -0,0 +1,7 @@ +package test + +trait Iterable[+A] { self => + + type CC[B] <: Iterable[B] { type CC[C] = self.CC[C] } + +} diff --git a/tests/pending/pos/S5.scala b/tests/pending/pos/S5.scala new file mode 100644 index 000000000..f0b66a6e6 --- /dev/null +++ b/tests/pending/pos/S5.scala @@ -0,0 +1,30 @@ +/* Here's a fragment of a Scala encoding for the Keris module system; +** the compiler claims: +** +** S5.scala:28: value n in class N of type N.this._N.n +** cannot override value n in class M of type M.this._N.n +** val system = new M() with N() {} +** ^ +** To me it seems like the code is perfectly fine... +*/ +abstract class M() { + val _N: N; + val n: _N.n; + val _M: M = this; + val m: _M.m = new _M.m(); + class m() { + // module body of M + } +} +trait N { + val _N: N = this; + val n: _N.n = new _N.n(); + val _M: M; + val m: _M.m; + class n() { + // module body of N + } +} +object O { + val system = new M() with N {} +} diff --git a/tests/pending/pos/SI-5788.scala b/tests/pending/pos/SI-5788.scala new file mode 100644 index 000000000..f29246180 --- /dev/null +++ b/tests/pending/pos/SI-5788.scala @@ -0,0 +1,3 @@ +trait Foo[@specialized(Int) A] { + final def bar(a:A):A = bar(a) +} diff --git a/tests/pending/pos/SI-7638.scala b/tests/pending/pos/SI-7638.scala new file mode 100644 index 000000000..ed581efe9 --- /dev/null +++ b/tests/pending/pos/SI-7638.scala @@ -0,0 +1,51 @@ +package miniboxing.tests.compile + +trait Ordering[@specialized(Int) A] { + def eqv(x: Array[A], y: Array[A]): Boolean = false +} + +trait ArrayVectorOrder[@specialized(Int) A] extends Ordering[A] { + override def eqv(x: Array[A], y: Array[A]): Boolean = super.eqv(x, y) +} + +object vectorOrder { + implicit def arrayOrder[@specialized(Int) A](): miniboxing.tests.compile.ArrayVectorOrder[A] = + /* + * Before applying patch: + * + * while compiling: SI-7638.scala + * during phase: mixin + * library version: version 2.10.3-20130625-164027-d22e8d282c + * compiler version: version 2.10.3-20130627-153946-54cb6af7db + * reconstructed args: + * + * last tree to typer: TypeTree(class Array) + * symbol: class Array in package scala (flags: final) + * symbol definition: final class Array[T >: ? <: ?] extends Object + * tpe: Array[Int] + * symbol owners: class Array -> package scala + * context owners: anonymous class anon$1 -> package compile + * + * == Expanded type of tree == + * + * TypeRef( + * TypeSymbol(final class Array[T >: ? <: ?] extends Object) + * args = List(TypeRef(TypeSymbol(final abstract class Int extends ))) + * ) + * + * unhandled exception while transforming SI-7638.scala + * error: uncaught exception during compilation: java.lang.UnsupportedOperationException + * error: java.lang.UnsupportedOperationException: tail of empty list + * at scala.collection.immutable.Nil$.tail(List.scala:339) + * at scala.collection.immutable.Nil$.tail(List.scala:334) + * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$rebindSuper$1.apply(Mixin.scala:123) + * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$rebindSuper$1.apply(Mixin.scala:122) + * at scala.reflect.internal.SymbolTable.atPhase(SymbolTable.scala:207) + * at scala.reflect.internal.SymbolTable.afterPhase(SymbolTable.scala:216) + * at scala.tools.nsc.Global.afterPickler(Global.scala:1104) + * at scala.tools.nsc.transform.Mixin.scala$tools$nsc$transform$Mixin$$rebindSuper(Mixin.scala:122) + * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$mixinTraitMembers$1$1.apply(Mixin.scala:339) + * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$mixinTraitMembers$1$1.apply(Mixin.scala:292) + */ + new ArrayVectorOrder[A] { } +} diff --git a/tests/pending/pos/annotDepMethType.scala b/tests/pending/pos/annotDepMethType.scala new file mode 100644 index 000000000..079ca6224 --- /dev/null +++ b/tests/pending/pos/annotDepMethType.scala @@ -0,0 +1,7 @@ +case class pc(calls: Any*) extends annotation.TypeConstraint + +object Main { + class C0 { def baz: String = "" } + class C1 { def bar(c0: C0): String @pc(c0.baz) = c0.baz } + def trans(c1: C1): String @pc(c1.bar(throw new Error())) = c1.bar(new C0) +} diff --git a/tests/pending/pos/annotated-original/C_2.scala b/tests/pending/pos/annotated-original/C_2.scala new file mode 100644 index 000000000..36a09ffe0 --- /dev/null +++ b/tests/pending/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/tests/pending/pos/annotated-original/M_1.scala b/tests/pending/pos/annotated-original/M_1.scala new file mode 100644 index 000000000..84a01bcce --- /dev/null +++ b/tests/pending/pos/annotated-original/M_1.scala @@ -0,0 +1,7 @@ +import language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object M { + def impl(c: Context)(a: c.Expr[Any]) = c.Expr[Any](c.untypecheck(a.tree)) + def m(a: Any) = macro impl +} diff --git a/tests/pending/pos/annotated-treecopy/Impls_Macros_1.scala b/tests/pending/pos/annotated-treecopy/Impls_Macros_1.scala new file mode 100644 index 000000000..986287dfa --- /dev/null +++ b/tests/pending/pos/annotated-treecopy/Impls_Macros_1.scala @@ -0,0 +1,54 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context +import collection.mutable.ListBuffer +import collection.mutable.Stack + +object Macros { + trait TypedFunction { + def tree: scala.reflect.runtime.universe.Tree + val typeIn: String + val typeOut: String + } + + def tree[T,U](f:Function1[T,U]): Function1[T,U] = macro tree_impl[T,U] + + def tree_impl[T:c.WeakTypeTag,U:c.WeakTypeTag](c: Context) + (f:c.Expr[Function1[T,U]]): c.Expr[Function1[T,U]] = { + import c.universe._ + import internal._ + val ttag = c.weakTypeTag[U] + f match { + case Expr(Function(List(ValDef(_,n,tp,_)),b)) => + // normalize argument name + var b1 = new Transformer { + override def transform(tree: Tree): Tree = tree match { + case Ident(x) if (x==n) => Ident(TermName("_arg")) + case tt: TypeTree if tt.original != null => setOriginal(TypeTree(tt.tpe), transform(tt.original)) + // without the fix to LazyTreeCopier.Annotated, we would need to uncomment the line below to make the macro work + // that's because the pattern match in the input expression gets expanded into Typed(<x>, TypeTree(<Int @unchecked>)) + // with the original of the TypeTree being Annotated(<@unchecked>, Ident(<x>)) + // then the macro tries to replace all Ident(<x>) trees with Ident(<_arg>), recurs into the original of the TypeTree, changes it, + // but leaves the <@unchecked> part untouched. this signals the misguided LazyTreeCopier that the Annotated tree hasn't been modified, + // so the original tree should be copied over and returned => crash when later <x: @unchecked> re-emerges from TypeTree.original + // case Annotated(annot, arg) => treeCopy.Annotated(tree, transform(annot).duplicate, transform(arg)) + case _ => super.transform(tree) + } + }.transform(b) + + val reifiedTree = c.reifyTree(gen.mkRuntimeUniverseRef, EmptyTree, b1) + val reifiedExpr = c.Expr[scala.reflect.runtime.universe.Expr[T => U]](reifiedTree) + val template = + c.universe.reify(new (T => U) with TypedFunction { + override def toString = c.Expr[String](q"""${tp+" => "+ttag.tpe+" { "+b1.toString+" } "}""").splice // DEBUG + def tree = reifiedExpr.splice.tree + val typeIn = c.Expr[String](q"${tp.toString}").splice + val typeOut = c.Expr[String](q"${ttag.tpe.toString}").splice + def apply(_arg: T): U = c.Expr[U](b1)(ttag.asInstanceOf[c.WeakTypeTag[U]]).splice + }) + val untyped = c.untypecheck(template.tree) + + c.Expr[T => U](untyped) + case _ => sys.error("Bad function type") + } + } +} diff --git a/tests/pending/pos/annotated-treecopy/Test_2.scala b/tests/pending/pos/annotated-treecopy/Test_2.scala new file mode 100644 index 000000000..1c6b862ef --- /dev/null +++ b/tests/pending/pos/annotated-treecopy/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + import Macros._ + // tree { (x:((Int,Int,Int),(Int,Int,Int))) => { val y=x; val ((r1,m1,c1),(r2,m2,c2))=y; (r1, m1 + m2 + r1 * c1 * c2, c2) } } + tree { (x:((Int,Int,Int),(Int,Int,Int))) => { val ((r1,m1,c1),(r2,m2,c2))=x; (r1, m1 + m2 + r1 * c1 * c2, c2) } } +} diff --git a/tests/pending/pos/annotations.scala b/tests/pending/pos/annotations.scala new file mode 100644 index 000000000..9235a1ee6 --- /dev/null +++ b/tests/pending/pos/annotations.scala @@ -0,0 +1,110 @@ +class ann(i: Int) extends scala.annotation.Annotation +class cfann(x: String) extends annotation.ClassfileAnnotation + +// annotations on abstract types +abstract class C1[@annotation.elidable(0) +T, U, V[_]] +abstract class C2[@deprecated + @ann(1) T <: Number, + V] +abstract class C3 { + @ann(2) type X <: Number +} + +object Test { + + // bug #1028 + val x = 1 + @ann(x) val a = () + @ann({val yy = 2; yy}) val b = () + val bb: Int @ann({val yy = 2; yy}) = 10 + + def c: Int @ann(x) = 1 + def d: String @ann({val z = 0; z - 1}) = "2" + def e[@deprecated T, U](x: T) = x + + //bug #1214 + val y = new (Integer @ann(0))(2) + + import scala.beans.BeanProperty + + // bug #637 + trait S { def getField(): Int } + class O extends S { @BeanProperty val field = 0 } + + // bug #1070 + trait T { @BeanProperty var field = 1 } + + // annotation on annotation constructor + @(ann @ann(100))(200) def foo() = 300 + + // #2984 + private final val NAMESPACE = "/info" + @cfann(x = NAMESPACE + "/index") def index = "success" +} + +// test forward references to getters / setters +class BeanPropertyTests { + @scala.beans.BeanProperty lazy val lv1 = 0 + + def foo(): Unit = { + val bp1 = new BeanPropertyTests1 + + println(lv1) + println(getLv1()) + println(bp1.getLv2()) + + println(getV1()) + setV1(10) + bp1.setV2(100) + } + + @scala.beans.BeanProperty var v1 = 0 + +} + +class BeanPropertyTests1 { + @scala.beans.BeanProperty lazy val lv2 = "0" + @scala.beans.BeanProperty var v2 = 0 +} + +// test mixin of getters / setters, and implementing abstract +// methods using @BeanProperty +class C extends T with BeanF { + def foo(): Unit = { + setF("doch!") + setG(true) + this.getF() + } +} + +trait T { + @scala.beans.BeanProperty var f = "nei" + @scala.beans.BooleanBeanProperty var g = false +} + +trait BeanF { + def getF(): String + def setF(n: String): Unit + + def isG(): Boolean + def setG(nb: Boolean): Unit +} + + +class Ann3(arr: Array[String]) extends annotation.ClassfileAnnotation +class Ann4(i: Int) extends annotation.ClassfileAnnotation +class Ann5(value: Class[_]) extends annotation.ClassfileAnnotation + +object Test3 { + final val i = 1083 + final val cls = classOf[String] +} + +class Test4 { + @Ann3(arr = Array("dlkfj", "DSF")) + @Ann4(i = 2908) + @Ann4(i = Test3.i) + @Ann5(value = classOf[Int]) + @Ann5(Test3.cls) + def foo: Unit = {} +} diff --git a/tests/pending/pos/arrays2.scala b/tests/pending/pos/arrays2.scala new file mode 100644 index 000000000..795c486e3 --- /dev/null +++ b/tests/pending/pos/arrays2.scala @@ -0,0 +1,23 @@ +case class C(); + +object arrays2 { + + def main(args: Array[String]): Unit = { + val a: Array[Array[C]] = new Array[Array[C]](2); + a(0) = new Array[C](2); + a(0)(0) = new C(); + } +} + +// #2422 +object arrays4 { + val args = Array[String]("World") + "Hello %1$s".format(args: _*) +} + +// #2461 +object arrays3 { + import scala.collection.JavaConversions._ + def apply[X](xs : X*) : java.util.List[X] = java.util.Arrays.asList(xs: _*) +} + diff --git a/tests/pending/pos/attachments-typed-another-ident/Impls_1.scala b/tests/pending/pos/attachments-typed-another-ident/Impls_1.scala new file mode 100644 index 000000000..98062a9c7 --- /dev/null +++ b/tests/pending/pos/attachments-typed-another-ident/Impls_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.macros.blackbox.Context +import language.experimental.macros + +object MyAttachment + +object Macros { + def impl(c: Context) = { + import c.universe._ + import internal._ + val ident = updateAttachment(Ident(TermName("bar")), MyAttachment) + assert(attachments(ident).get[MyAttachment.type].isDefined, attachments(ident)) + val typed = c.typecheck(ident) + assert(attachments(typed).get[MyAttachment.type].isDefined, attachments(typed)) + c.Expr[Int](typed) + } + + def foo = macro impl +} diff --git a/tests/pending/pos/attachments-typed-another-ident/Macros_Test_2.scala b/tests/pending/pos/attachments-typed-another-ident/Macros_Test_2.scala new file mode 100644 index 000000000..022639bfe --- /dev/null +++ b/tests/pending/pos/attachments-typed-another-ident/Macros_Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + def bar = 2 + Macros.foo +} + diff --git a/tests/pending/pos/attachments-typed-ident/Impls_1.scala b/tests/pending/pos/attachments-typed-ident/Impls_1.scala new file mode 100644 index 000000000..98062a9c7 --- /dev/null +++ b/tests/pending/pos/attachments-typed-ident/Impls_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.macros.blackbox.Context +import language.experimental.macros + +object MyAttachment + +object Macros { + def impl(c: Context) = { + import c.universe._ + import internal._ + val ident = updateAttachment(Ident(TermName("bar")), MyAttachment) + assert(attachments(ident).get[MyAttachment.type].isDefined, attachments(ident)) + val typed = c.typecheck(ident) + assert(attachments(typed).get[MyAttachment.type].isDefined, attachments(typed)) + c.Expr[Int](typed) + } + + def foo = macro impl +} diff --git a/tests/pending/pos/attachments-typed-ident/Macros_Test_2.scala b/tests/pending/pos/attachments-typed-ident/Macros_Test_2.scala new file mode 100644 index 000000000..45a0609de --- /dev/null +++ b/tests/pending/pos/attachments-typed-ident/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def bar = 2 + Macros.foo +} diff --git a/tests/pending/pos/bounds.scala b/tests/pending/pos/bounds.scala new file mode 100644 index 000000000..26bc84a1b --- /dev/null +++ b/tests/pending/pos/bounds.scala @@ -0,0 +1,11 @@ +trait Map[A, +C] { + def ++ [B1 >: C] (kvs: Iterable[Tuple2[A, B1]]): Map[A, B1] = this + def ++ [B1 >: C] (kvs: Iterator[Tuple2[A, B1]]): Map[A, B1] = this +} + +class ListMap[A, +B] extends Map[A, B] {} + +object ListMap { + def empty[X, Y] = new ListMap[X, Y] + def apply[A1, B2](elems: Tuple2[A1, B2]*): Map[A1, B2] = empty[A1,B2].++(elems.iterator) +} diff --git a/tests/pending/pos/caseClassInMethod.scala b/tests/pending/pos/caseClassInMethod.scala new file mode 100644 index 000000000..958e5dd47 --- /dev/null +++ b/tests/pending/pos/caseClassInMethod.scala @@ -0,0 +1,5 @@ +object t { + def f = { object C; case class C(); 1 } + // pending: def g = { case class D(x: Int); object D; 2 } + def h = { case class E(y: Int = 10); 3 } +} diff --git a/tests/pending/pos/channels.scala b/tests/pending/pos/channels.scala new file mode 100644 index 000000000..b2f0cdc32 --- /dev/null +++ b/tests/pending/pos/channels.scala @@ -0,0 +1,29 @@ +class Channel[a] + +import collection.mutable.Set + +case class ![a](chan: Channel[a], data: a) + +/* +object Bang { + def unapply[a](x: ![a]): Option[{Channel[a], a}] = + Some(x.chan, x.data) +} + +*/ +object Test extends App { + object IC extends Channel[Int] + def f[b](x: ![b]): Int = x match { + case send: ![c] => + send.chan match { + case IC => send.data + } + } +} + +object Test2 extends App { + object IC extends Channel[Set[Int]] + def f[b](s: ![b]): Set[Int] = s match { + case IC ! x => x + } +} diff --git a/tests/pending/pos/compound.scala b/tests/pending/pos/compound.scala new file mode 100644 index 000000000..60890f910 --- /dev/null +++ b/tests/pending/pos/compound.scala @@ -0,0 +1,9 @@ +abstract class A { type T } + +abstract class B { val xz: Any } + +abstract class Test { + var yy: A with B { type T; val xz: T } = null; + var xx: A with B { type T; val xz: T } = null; + xx = yy; +} diff --git a/tests/pending/pos/constfold.scala b/tests/pending/pos/constfold.scala new file mode 100644 index 000000000..8d431efba --- /dev/null +++ b/tests/pending/pos/constfold.scala @@ -0,0 +1,14 @@ +object A { + val x = 2; + val y = x.asInstanceOf[Byte]; + val z = 1.0 / 2; + val s = "z is " + z; +} + +object Test extends App { + + Console.println(A.x); + Console.println(A.y); + Console.println(A.z); + Console.println(A.s); +} diff --git a/tests/pending/pos/context.scala b/tests/pending/pos/context.scala new file mode 100644 index 000000000..4e11d07eb --- /dev/null +++ b/tests/pending/pos/context.scala @@ -0,0 +1,38 @@ +class Context { + object symwrap extends SymbolWrapper { + val context: Context.this.type = Context.this + } + object typewrap extends TypeWrapper { + val context: Context.this.type = Context.this + } + object symbols extends symwrap.Symbols; + object types extends typewrap.Types; +} + +abstract class SymbolWrapper { + val context: Context; + import context._; + + class Symbols { + self: context.symbols.type => + + abstract class Symbol { + def typ: types.Type; + def sym: Symbol = typ.sym; + } + } +} + +abstract class TypeWrapper { + val context: Context; + import context._; + + class Types { + self: context.types.type => + + abstract class Type { + def sym: symbols.Symbol; + def typ: Type = sym.typ; + } + } +} diff --git a/tests/pending/pos/contextbounds-implicits-new.scala b/tests/pending/pos/contextbounds-implicits-new.scala new file mode 100644 index 000000000..8389d1332 --- /dev/null +++ b/tests/pending/pos/contextbounds-implicits-new.scala @@ -0,0 +1,10 @@ +import scala.reflect.runtime.universe._ + +/* Tests implicit parameters in the presence of context bounds. + * See Section 7.4 of the Scala Language Specification. + */ +class C { + + def f[T: TypeTag, S: TypeTag](x: T, y: S)(implicit p: C): Unit = { } + +} diff --git a/tests/pending/pos/contrib701.scala b/tests/pending/pos/contrib701.scala new file mode 100644 index 000000000..6f0e53a36 --- /dev/null +++ b/tests/pending/pos/contrib701.scala @@ -0,0 +1,3 @@ +trait B { + type A[T] >: A[A[T]] +} diff --git a/tests/pending/pos/cycle-jsoup.flags b/tests/pending/pos/cycle-jsoup.flags new file mode 100644 index 000000000..ca20f5517 --- /dev/null +++ b/tests/pending/pos/cycle-jsoup.flags @@ -0,0 +1 @@ +-Ybreak-cycles diff --git a/tests/pending/pos/cycle-jsoup.scala b/tests/pending/pos/cycle-jsoup.scala new file mode 100644 index 000000000..d547ecd93 --- /dev/null +++ b/tests/pending/pos/cycle-jsoup.scala @@ -0,0 +1,5 @@ +object Test { + def main(args : Array[String]): Unit = { + org.jsoup.Jsoup.parse(null: java.net.URL, 3000) + } +} diff --git a/tests/pending/pos/delambdafy-lambdalift.scala b/tests/pending/pos/delambdafy-lambdalift.scala new file mode 100644 index 000000000..e9da24ef3 --- /dev/null +++ b/tests/pending/pos/delambdafy-lambdalift.scala @@ -0,0 +1,8 @@ +class LambdaLift { + + def enclosingMethod(capturedArg: Int): Unit = { + def innerMethod(x: Int): Int = x + capturedArg + val f = (y: Int) => innerMethod(y) + } + +} diff --git a/tests/pending/pos/depexists.scala b/tests/pending/pos/depexists.scala new file mode 100644 index 000000000..dff1917a4 --- /dev/null +++ b/tests/pending/pos/depexists.scala @@ -0,0 +1,5 @@ +object depexists { + + val c: Option[(a, b)] forSome { type a <: Number; type b <: (a, a) } = null + val d = c +} diff --git a/tests/pending/pos/depmet_implicit_chaining_zw.scala b/tests/pending/pos/depmet_implicit_chaining_zw.scala new file mode 100644 index 000000000..a9da1e976 --- /dev/null +++ b/tests/pending/pos/depmet_implicit_chaining_zw.scala @@ -0,0 +1,28 @@ +trait Zero +trait Succ[N] + +trait ZipWith[N, S] { + type T + val x: T = sys.error("") +} + +object ZipWith { + implicit def ZeroZipWith[S]: ZipWith[Zero,S]{type T = Stream[S]} = new ZipWith[Zero, S] { + type T = Stream[S] + } + + implicit def SuccZipWith[N, S, R](implicit zWith : ZipWith[N, R]): ZipWith[Succ[N],S => R]{type T = Stream[S] => zWith.T} = new ZipWith[Succ[N], S => R] { + type T = Stream[S] => zWith.T // dependent types replace the associated types functionality + } + + // can't use implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]], + // since that will chop of the {type T = ... } refinement in adapt (pt = ZipWith[Succ[Succ[Zero]], Int => String => Boolean]) + // this works + // def zipWith(implicit zw: ZipWith[Succ[Succ[Zero]], Int => String => Boolean]): zw.T = zw.x + // thus, I present ?: implicitly on steroids! + def ?[T <: AnyRef](implicit w: T): w.type = w + + type _2 = Succ[Succ[Zero]] + val zw = ?[ZipWith[_2, Int => String => Boolean]].x // : Stream[Int] => Stream[String] => Stream[Boolean] + // val zw = implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]{type T = Stream[Int] => Stream[String] => Stream[Boolean]}].x +} diff --git a/tests/pending/pos/depmet_implicit_norm_ret.scala b/tests/pending/pos/depmet_implicit_norm_ret.scala new file mode 100644 index 000000000..85be750b4 --- /dev/null +++ b/tests/pending/pos/depmet_implicit_norm_ret.scala @@ -0,0 +1,29 @@ +object Test{ + def ?[S <: AnyRef](implicit w : S) : w.type = w + + // fallback, lower priority (overloading rules apply: pick alternative in subclass lowest in subtyping lattice) + class ZipWithDefault { + implicit def ZeroZipWith[S]: Test.ZipWith[S]{type T = Stream[S]} = new ZipWith[S] { + type T = Stream[S] + } + } + + object ZipWith extends ZipWithDefault { + // def apply[S: ZipWith](s : S) = ?[ZipWith[S]].zipWith(s) // TODO: bug return type should be inferred + def apply[S](s : S)(implicit zw: ZipWith[S]): zw.T = zw.zipWith(s) + + implicit def SuccZipWith[S,R](implicit zWith : ZipWith[R]): Test.ZipWith[S => R]{type T = Stream[S] => zWith.T} = new ZipWith[S => R] { + type T = Stream[S] => zWith.T // dependent types replace the associated types functionality + } + } + + trait ZipWith[S] { + type T + def zipWith : S => T = sys.error("") + } + + // bug: inferred return type = (Stream[A]) => java.lang.Object with Test.ZipWith[B]{type T = Stream[B]}#T + // this seems incompatible with vvvvvvvvvvvvvvvvvvvvvv -- #3731 + def map[A,B](f : A => B) /* : Stream[A] => Stream[B]*/ = ZipWith(f) + val tst: Stream[Int] = map{x: String => x.length}(Stream("a")) +} diff --git a/tests/pending/pos/depmet_implicit_oopsla_session.scala b/tests/pending/pos/depmet_implicit_oopsla_session.scala new file mode 100644 index 000000000..aa8478056 --- /dev/null +++ b/tests/pending/pos/depmet_implicit_oopsla_session.scala @@ -0,0 +1,63 @@ +object Sessions { + trait Session[This] { + type Dual + type HasDual[D] = Session[This]{type Dual=D} + def run(p: This, dp: Dual): Unit + } + + implicit object StopSession extends Session[Stop] { + type Dual = Stop + + def run(p: Stop, dp: Stop): Unit = {} + } + + implicit def InDual[A, B](implicit sessionDIn: Session[B]): Sessions.Session[Sessions.In[A,B]]{type Dual = Sessions.Out[A,sessionDIn.Dual]} = + new Session[In[A, B]] { + type Dual = Out[A, sessionDIn.Dual] + + def run(p: In[A, B], dp: Dual): Unit = + sessionDIn.run(p.func(dp.x), dp.y) + } + + implicit def OutDual[A, B](implicit sessionDOut: Session[B]): Sessions.Session[Sessions.Out[A,B]]{type Dual = Sessions.In[A,sessionDOut.Dual]} = + new Session[Out[A, B]] { + type Dual = In[A, sessionDOut.Dual] + + def run(p: Out[A, B], dp: Dual): Unit = + sessionDOut.run(p.y, dp.func(p.x)) + } + + sealed case class Stop() + sealed case class In[-A, +B](func: A => B) + sealed case class Out[+A, +B](x: A, y: B) + + def addServer = + In{x: Int => + In{y: Int => System.out.println("Thinking") + Out(x+y, + Stop())}} + + def addClient = + Out(3, + Out(4, { System.out.println("Waiting") + In{z: Int => System.out.println(z) + Stop()}})) + + def runSession[S, D: Session[S]#HasDual](p: S, dp: D) = + implicitly[Session[S]#HasDual[D]].run(p, dp) + + // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]#HasDual[D]) = + // s.run(p, dp) + // + // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]{type Dual=D}) = + // s.run(p, dp) + + // TODO: can we relax the ordering restrictions on dependencies so that we can use + // def runSession[S](p: S, dp: s.Dual)(implicit s: Session[S]) = + // s.run(p, dp) + // to emphasise similarity of type parameters and implicit arguments: + // def runSession[S][val s: Session[S]](p: S, dp: s.Dual) = + // s.run(p, dp) + + def myRun = runSession(addServer, addClient) +} diff --git a/tests/pending/pos/depmet_implicit_oopsla_session_2.scala b/tests/pending/pos/depmet_implicit_oopsla_session_2.scala new file mode 100644 index 000000000..4951c10a1 --- /dev/null +++ b/tests/pending/pos/depmet_implicit_oopsla_session_2.scala @@ -0,0 +1,87 @@ +object Sessions { + def ?[T <: AnyRef](implicit w: T): w.type = w + + // session states + sealed case class Stop() + sealed case class In[-Data, +Cont](recv: Data => Cont) + sealed case class Out[+Data, +Cont](data: Data, cont: Cont) + + // the type theory of communicating sessions: + + // an instance of type Session[S]{type Dual=D} is evidence that S and D are duals + // such a value witnesses this fact by describing how to compose an instance of S with an instance of D (through the run method) + trait Session[S] { type Self = S + type Dual + type HasDual[D] = Session[Self]{type Dual=D} + def run(self: Self, dual: Dual): Unit + } + + // friendly interface to the theory + def runSession[S, D: Session[S]#HasDual](session: S, dual: D) = + ?[Session[S]#HasDual[D]].run(session, dual) + + // facts in the theory: + + // ------------------------[StopDual] + // Stop is the dual of Stop + implicit object StopDual extends Session[Stop] { + type Dual = Stop + + def run(self: Self, dual: Dual): Unit = {} + } + + // CD is the dual of Cont + // -------------------------------------------[InDual] + // Out[Data, CD] is the dual of In[Data, Cont] + implicit def InDual[Data, Cont](implicit cont: Session[Cont]): Sessions.Session[Sessions.In[Data,Cont]]{type Dual = Sessions.Out[Data,cont.Dual]} = new Session[In[Data, Cont]] { + type Dual = Out[Data, cont.Dual] + + def run(self: Self, dual: Dual): Unit = + cont.run(self.recv(dual.data), dual.cont) + } + + // CD is the dual of Cont + // -------------------------------------------[OutDual] + // In[Data, CD] is the dual of Out[Data, Cont] + implicit def OutDual[Data, Cont](implicit cont: Session[Cont]): Sessions.Session[Sessions.Out[Data,Cont]]{type Dual = Sessions.In[Data,cont.Dual]} = new Session[Out[Data, Cont]] { + type Dual = In[Data, cont.Dual] + + def run(self: Self, dual: Dual): Unit = + cont.run(self.cont, dual.recv(self.data)) + } + + // a concrete session + def addServer = + In{x: Int => + In{y: Int => System.out.println("Thinking") + Out(x+y, + Stop())}} + + def addClient = + Out(3, + Out(4, { System.out.println("Waiting") + In{z: Int => System.out.println(z) + Stop()}})) + + def myRun = runSession(addServer, addClient) +} + +/* future improvements: + + + // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]#HasDual[D]) = + // s.run(p, dp) + // + // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]{type Dual=D}) = + // s.run(p, dp) + + // TODO: can we relax the ordering restrictions on dependencies so that we can write + // one possibility: graph of dependencies between arguments must be acyclic + // def runSession[S](p: S, dp: s.Dual)(implicit s: Session[S]) = + // s.run(p, dp) + // to emphasise similarity of type parameters and implicit arguments: + // def runSession[S][val s: Session[S]](p: S, dp: s.Dual) = + // s.run(p, dp) + + +*/ diff --git a/tests/pending/pos/depmet_implicit_oopsla_session_simpler.scala b/tests/pending/pos/depmet_implicit_oopsla_session_simpler.scala new file mode 100644 index 000000000..04b8f94e6 --- /dev/null +++ b/tests/pending/pos/depmet_implicit_oopsla_session_simpler.scala @@ -0,0 +1,44 @@ +object Sessions { + trait Session { + type Dual <: Session + + def run(dp: Dual): Unit + } + + sealed case class Stop() extends Session { + type Dual = Stop + + def run(dp: Dual): Unit = {} + } + + // can't write B <: Session{type Dual = BDual} due to limitations in type inference algorithm + // (type variables cannot occur on both sides of <:) + // using B#Dual instead of BDual is too imprecise, since it is disconnected from the actual argument that is passed for B + // would be nice if we could introduce a universal quantification over BDual that is not part of the + // type parameter list + sealed case class In[A, B <: Session, BDual <: Session](recv: A => B)(implicit dual: B <:< Session{type Dual=BDual}) extends Session { + type Dual = Out[A, BDual] + + def run(dp: Dual): Unit = recv(dp.data) run dp.cont + } + + sealed case class Out[A, B <: Session](data: A, cont: B) extends Session { + type Dual = In[A, cont.Dual, cont.Dual#Dual] + + def run(dp: Dual): Unit = cont run dp.recv(data) + } + + def addServer = + In{x: Int => + In{y: Int => System.out.println("Thinking") + Out(x+y, + Stop())}} + + def addClient = + Out(3, + Out(4, { System.out.println("Waiting") + In{z: Int => System.out.println(z) + Stop()}})) + + def myRun = addServer run addClient +} diff --git a/tests/pending/pos/depmet_implicit_oopsla_zipwith.scala b/tests/pending/pos/depmet_implicit_oopsla_zipwith.scala new file mode 100644 index 000000000..83171f865 --- /dev/null +++ b/tests/pending/pos/depmet_implicit_oopsla_zipwith.scala @@ -0,0 +1,44 @@ +case class Zero() +case class Succ[N](x: N) +import Stream.{cons, continually} + +trait ZipWith[N, S] { + type T + + def manyApp: N => Stream[S] => T + def zipWith: N => S => T = n => f => manyApp(n)(continually(f)) +} +object ZipWith { + implicit def ZeroZipWith[S]: ZipWith[Zero,S]{type T = Stream[S]} = new ZipWith[Zero, S] { + type T = Stream[S] + + def manyApp = n => xs => xs + } + + implicit def SuccZipWith[N, S, R](implicit zw: ZipWith[N, R]): ZipWith[Succ[N],S => R]{type T = Stream[S] => zw.T; def zapp[A, B](xs: Stream[A => B],ys: Stream[A]): Stream[B]} = + new ZipWith[Succ[N],S => R] { + type T = Stream[S] => zw.T + + def zapp[A, B](xs: Stream[A => B], ys: Stream[A]): Stream[B] = (xs, ys) match { + case (cons(f, fs), cons(s, ss)) => cons(f(s),zapp(fs, ss)) + case (_, _) => Stream.empty + } + + def manyApp = n => xs => ss => n match { + case Succ(i) => zw.manyApp(i)(zapp(xs, ss)) + } + } +} + +object Test { + def zWith[N, S](n: N, s: S)(implicit zw: ZipWith[N, S]): zw.T = zw.zipWith(n)(s) + + def zipWith0: Stream[Int] = zWith(Zero(),0) + +// (Stream[A]) => java.lang.Object with ZipWith[Zero,B]{type T = Stream[B]}#T +// should normalise to: Stream[A] => Stream[B] + def map[A, B](f: A => B) = zWith(Succ(Zero()),f) + + def zipWith3[A, B, C, D](f: A => B => C => D) = //: Stream[A] => Stream[B] => Stream[C] => Stream[D] = // BUG why do we need a return type? + zWith(Succ(Succ(Succ(Zero()))),f) +} diff --git a/tests/pending/pos/dotless-targs.scala b/tests/pending/pos/dotless-targs.scala new file mode 100644 index 000000000..8c0e244e4 --- /dev/null +++ b/tests/pending/pos/dotless-targs.scala @@ -0,0 +1,9 @@ +class A { + def fn1 = List apply 1 + def fn2 = List apply[Int] 2 + + def g1: Char = "g1" toList 0 + def g2: Char = "g2" apply 1 + + def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x) +} diff --git a/tests/pending/pos/exbound.scala b/tests/pending/pos/exbound.scala new file mode 100644 index 000000000..be78abc26 --- /dev/null +++ b/tests/pending/pos/exbound.scala @@ -0,0 +1,7 @@ +class A[T <: A[T]] { + +} + +object Test { + val x: A[_] = null +} diff --git a/tests/pending/pos/exhaust_alternatives.flags b/tests/pending/pos/exhaust_alternatives.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/pending/pos/exhaust_alternatives.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/exhaust_alternatives.scala b/tests/pending/pos/exhaust_alternatives.scala new file mode 100644 index 000000000..7fdecffa7 --- /dev/null +++ b/tests/pending/pos/exhaust_alternatives.scala @@ -0,0 +1,10 @@ +sealed abstract class X +sealed case class A(x: Boolean) extends X +case object B extends X + +object Test { + def test(x: X) = x match { + case A(true) => + case A(false) | B => + } +} diff --git a/tests/pending/pos/exhaustive_heuristics.scala b/tests/pending/pos/exhaustive_heuristics.scala new file mode 100644 index 000000000..5fb709c52 --- /dev/null +++ b/tests/pending/pos/exhaustive_heuristics.scala @@ -0,0 +1,26 @@ +// tests exhaustivity doesn't give warnings (due to its heuristic rewrites kicking in or it backing off) +object Test { + // List() => Nil + List(1) match { + case List() => + case x :: xs => + } + + // we don't look into guards + val turnOffChecks = true + List(1) match { + case _ if turnOffChecks => + } + + // we back off when there are any user-defined extractors + // in fact this is exhaustive, but we pretend we don't know since List's unapplySeq is not special to the compiler + // to compensate our ignorance, we back off + // well, in truth, we do rewrite List() to Nil, but otherwise we do nothing + // the full rewrite List(a, b) to a :: b :: Nil, for example is planned (but not sure it's a good idea) + List(true, false) match { + case List(_, _, _*) => + case List(node, _*) => + case Nil => + } + +} diff --git a/tests/pending/pos/existentials-harmful.scala b/tests/pending/pos/existentials-harmful.scala new file mode 100644 index 000000000..8722852e8 --- /dev/null +++ b/tests/pending/pos/existentials-harmful.scala @@ -0,0 +1,54 @@ +// a.scala +// Mon Jul 11 14:18:26 PDT 2011 + +object ExistentialsConsideredHarmful { + class Animal(val name: String) + object Dog extends Animal("Dog") + object Sheep extends Animal("Sheep") + + trait Tools[A] { + def shave(a: A): A + } + def tools[A](a: A): Tools[A] = null // dummy + + case class TransportBox[A <: Animal](animal: A, tools: Tools[A]) { + def label: String = animal.name + } + + // 1. + def carry[A <: Animal](box: TransportBox[A]): Unit = { + println(box.animal.name+" got carried away") + } + + val aBox = + if (math.random < 0.5) + TransportBox(Dog, tools(Dog)) + else + TransportBox(Sheep, tools(Sheep)) + + // 2. + //aBox.tools.shave(aBox.animal) + + // Use pattern match to avoid opening the existential twice + aBox match { + case TransportBox(animal, tools) => tools.shave(animal) + } + + abstract class BoxCarrier[R <: Animal](box: TransportBox[R]) { + def speed: Int + + def talkToAnimal: Unit = println("The carrier says hello to"+box.animal.name) + } + + // 3. + //val bc = new BoxCarrier(aBox) { + + // Use pattern match to avoid opening the existential twice + // Type annotation on bc is required ... possible compiler bug? + // val bc : BoxCarrier[_ <: Animal] = aBox match { + val bc = aBox match { + case tb : TransportBox[a] => new BoxCarrier(tb) { + def speed: Int = 12 + } + } +} diff --git a/tests/pending/pos/exponential-spec.scala b/tests/pending/pos/exponential-spec.scala new file mode 100644 index 000000000..54515c1d2 --- /dev/null +++ b/tests/pending/pos/exponential-spec.scala @@ -0,0 +1,47 @@ +// a.scala +// Sat Jun 30 19:51:17 PDT 2012 + +trait Exp[T] + +object Test { + def f[T](exp: Exp[T]): Exp[T] = ( + f[T] _ + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] // 4s + compose f[T] // 5s + compose f[T] // 5s + compose f[T] // 6s + compose f[T] // 7s + compose f[T] // 8s + compose f[T] // 11s + compose f[T] // 17s + compose f[T] // 29s + compose f[T] // 54s + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + compose f[T] + )(exp) +} diff --git a/tests/pending/pos/extractor-types.scala b/tests/pending/pos/extractor-types.scala new file mode 100644 index 000000000..200279be6 --- /dev/null +++ b/tests/pending/pos/extractor-types.scala @@ -0,0 +1,30 @@ +package p1 { + object Ex { def unapply(p: Any): Option[_ <: Int] = null } + object Foo { val Ex(_) = null } +} +// a.scala:2: error: error during expansion of this match (this is a scalac bug). +// The underlying error was: type mismatch; +// found : Some[_$1(in value x$1)] where type _$1(in value x$1) +// required: Some[_$1(in method unapply)] +// object Foo { val Ex(_) = null } +// ^ +// one error found + +package p2 { + trait Other { + class Quux + object Baz { def unapply(x: Any): Option[Quux] = None } + } + trait Reifiers { + def f(): Unit = { + val u2: Other = null + (null: Any) match { case u2.Baz(x) => println(x) } //: u2.Quux) } + // The underlying error was: type mismatch; + // found : Other#Quux + // required: u2.Quux + // x match { case u2.Baz(x) => println(x: u2.Quux) } + // ^ + // one error found + } + } +} diff --git a/tests/pending/pos/five-dot-f.flags b/tests/pending/pos/five-dot-f.flags new file mode 100644 index 000000000..112fc720a --- /dev/null +++ b/tests/pending/pos/five-dot-f.flags @@ -0,0 +1 @@ +-Xfuture
\ No newline at end of file diff --git a/tests/pending/pos/five-dot-f.scala b/tests/pending/pos/five-dot-f.scala new file mode 100644 index 000000000..8a7f86e21 --- /dev/null +++ b/tests/pending/pos/five-dot-f.scala @@ -0,0 +1,5 @@ +class C { + implicit def ffer(x: Int) = new { def f : Long = 123L } + + val x1: Long = 5.f +} diff --git a/tests/pending/pos/functions.scala b/tests/pending/pos/functions.scala new file mode 100644 index 000000000..0207523dd --- /dev/null +++ b/tests/pending/pos/functions.scala @@ -0,0 +1,12 @@ +import scala.actors.Actor + +object Test { + + def foo() = { + val x = 1; + Actor.receive { + case "abc" if x == 2 => + Console.println("hi!") + } + } +} diff --git a/tests/pending/pos/gadt-gilles.scala b/tests/pending/pos/gadt-gilles.scala new file mode 100644 index 000000000..662be9017 --- /dev/null +++ b/tests/pending/pos/gadt-gilles.scala @@ -0,0 +1,37 @@ +object Test { + trait A[T] + trait B[U, V] extends A[U with V] // indirect constraint + trait C + trait D + + val x: A[C with D] = new B[C, D] {} + val y: A[C with D] = x match { case b: B[u, v] => (new B[u, v] {}): A[u with v] } // OK + + + def f[T, U](p: A[T with U]): A[T with U] = p match { case b: B[u, v] => new A[u with v] {} } // Not OK +} + +object Test1 { + + trait T[U, V <: U] + + def f(r: Any) = r match { + + case t: T[u, v] => new T[u, v]{} + + } + +} +object Test2 { + + trait T[U, V <: U] + + val x: T[Int, Int] = new T[Int, Int]{} + + x match { + + case t: T[u, v] => new T[u, v]{} + + } + +} diff --git a/tests/pending/pos/gadts2.scala b/tests/pending/pos/gadts2.scala new file mode 100644 index 000000000..b67bafb32 --- /dev/null +++ b/tests/pending/pos/gadts2.scala @@ -0,0 +1,25 @@ +object Test { + + abstract class Number + case class MyInt(n: Int) extends Number + case class MyDouble(d: Double) extends Number + + trait Term[a] + case class Cell[a](var x: a) extends Term[a] + final case class NumTerm(val n: Number) extends Term[Number] + + def f[a](t: Term[a], c: Cell[a]): Unit = { + t match { + case NumTerm(n) => c.x = MyDouble(1.0) + } + } + + val x: Term[Number] = NumTerm(MyInt(5)) + + def main(args: Array[String]): Unit = { + val cell = Cell[Number](MyInt(6)) + Console.println(cell) + f[Number](new NumTerm(MyInt(5)), cell) + Console.println(cell) + } +} diff --git a/tests/pending/pos/generic-sigs.flags b/tests/pending/pos/generic-sigs.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/pending/pos/generic-sigs.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/generic-sigs.scala b/tests/pending/pos/generic-sigs.scala new file mode 100644 index 000000000..b751e215e --- /dev/null +++ b/tests/pending/pos/generic-sigs.scala @@ -0,0 +1,20 @@ +import language.existentials + +object A { + def f1 = List(classOf[Int], classOf[String]) + def f2 = List(classOf[String], classOf[Int]) + def f3(x: Class[_ <: Int]) = x + def f4(x: Class[_ <: String with Int]) = x + def f5(x: Class[_ <: Int with String]) = x + + class Bippy[T] + def f6(x: Int) = new Bippy[t forSome { type t <: Int }] + def f7(x: T forSome { type T <: Float }) = x + def f8(x: T forSome { type T <: Unit }) = x + def f9(x: T forSome { type T <: scala.runtime.BoxedUnit }) = x + def f10(x: Int) = new Bippy[t forSome { type t <: Unit }] + def f11(x: Int) = new Bippy[t forSome { type t >: Null }] + + class Boppy[+T1,-T2] + def g1 = new Boppy[t forSome { type t <: Int }, u forSome { type u <: String }] +} diff --git a/tests/pending/pos/getClassType.scala b/tests/pending/pos/getClassType.scala new file mode 100644 index 000000000..7482788a4 --- /dev/null +++ b/tests/pending/pos/getClassType.scala @@ -0,0 +1,16 @@ +trait IdlBase + +class IdlConcrete extends IdlBase + +class A { + // In general, this method should not need an instance to reflect on it, so + // take a Class[] + def reflect(clazz : Class[_ <: IdlBase]) = { + // Get a list of all its methods and build a hash keyed by method name + // for statistics recording. + } + + // But I also really have an IdlConcrete generated by Spring here... + val idl = new IdlConcrete + reflect(idl.getClass) +} diff --git a/tests/pending/pos/hk-infer.scala b/tests/pending/pos/hk-infer.scala new file mode 100644 index 000000000..c23a9d151 --- /dev/null +++ b/tests/pending/pos/hk-infer.scala @@ -0,0 +1,37 @@ +object Basis { + final case class X[T](t: T) + val x = Seq(X(32)) + val y = Seq(X(true)) + val x1 = Seq(X("asdf")) + val x2 = Seq(X('d')) +} +import Basis._ + +object DoesWork { + // Doesn'tWork + // def f1 = x ++ y ++ x1 ++ x2 + + def f2 = List(x, y, x1, x2).flatten +} + +// Testing the not giving of explicit Booper[M] arguments. +object ShouldWorkHK { + class Booper[M[_]](xs: Seq[M[_]]) extends collection.generic.SeqForwarder[M[_]] { + def underlying = xs + def BOOP(ys: Seq[M[_]]) = new Booper(xs ++ ys) + } + implicit def mkBoop[M[_]](xs: Seq[M[_]]): ShouldWorkHK.Booper[M] = new Booper(xs) + + def f1 = x BOOP y BOOP x1 BOOP x2 +} + +object DoesWorkHK { + class Booper[M[_]](xs: Seq[M[_]]) extends collection.generic.SeqForwarder[M[_]] { + def underlying = xs + def BOOP(ys: Seq[M[_]]) = new Booper[M](xs ++ ys) + } + implicit def mkBoop[M[_]](xs: Seq[M[_]]): DoesWorkHK.Booper[M] = new Booper[M](xs) + + def f1 = x BOOP y BOOP x1 BOOP x2 +} + diff --git a/tests/pending/pos/hklub0.scala b/tests/pending/pos/hklub0.scala new file mode 100644 index 000000000..36cd46332 --- /dev/null +++ b/tests/pending/pos/hklub0.scala @@ -0,0 +1,5 @@ +object Test { + val a : scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq] = null + val b : scala.collection.generic.GenericCompanion[scala.collection.mutable.Seq] = null + List(a, b) // immutable.this.List.apply[scala.collection.generic.GenericCompanion[Seq]](Test.this.a, Test.this.b) +} diff --git a/tests/pending/pos/hkrange.scala b/tests/pending/pos/hkrange.scala new file mode 100644 index 000000000..a6803230e --- /dev/null +++ b/tests/pending/pos/hkrange.scala @@ -0,0 +1,5 @@ +class A { + def f[CC[X] <: Traversable[X]](x: CC[Int]) = () + + f(1 to 5) +} diff --git a/tests/pending/pos/implicits-new.scala b/tests/pending/pos/implicits-new.scala new file mode 100644 index 000000000..f6b69c707 --- /dev/null +++ b/tests/pending/pos/implicits-new.scala @@ -0,0 +1,92 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.{ClassTag, classTag} + +// #1435 +object t1435 { + implicit def a(s:String):String = sys.error("") + implicit def a(i:Int):String = sys.error("") + implicit def b(i:Int):String = sys.error("") +} + +class C1435 { + val v:String = { + import t1435.a + 2 + } +} + +// #1492 +class C1492 { + + class X + + def foo(x: X => X): Unit = {} + + foo ( implicit x => implicitly[X] ) + foo { implicit x => implicitly[X] } +} + +// #1579 +object Test1579 { + class Column + class Query[E](val value: E) + class Invoker(q: Any) { val foo = null } + + implicit def unwrap[C](q: Query[C]): C = q.value + implicit def invoker(q: Query[Column]): Test1579.Invoker = new Invoker(q) + + val q = new Query(new Column) + q.foo +} +// #1625 +object Test1625 { + + class Wrapped(x:Any) { + def unwrap() = x + } + + implicit def byName[A](x: =>A): Test1625.Wrapped = new Wrapped(x) + + implicit def byVal[A](x: A): A = x + + def main(args: Array[String]) = { + +// val res:Wrapped = 7 // works + + val res = 7.unwrap() // doesn't work + + println("=> result: " + res) + } +} + +object Test2188 { + implicit def toJavaList[A: ClassTag](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) + + val x: java.util.List[String] = List("foo") +} + +object TestNumericWidening { + val y = 1 + val x: java.lang.Long = y +} + +// #2709 +package foo2709 { + class A + class B + + package object bar { + implicit def a2b(a: A): B = new B + } + + package bar { + object test { + new A: B + } + } +} + +// Problem with specs +object specsProblem { + println(implicitly[TypeTag[Class[_]]]) +} diff --git a/tests/pending/pos/implicits-old.scala b/tests/pending/pos/implicits-old.scala new file mode 100644 index 000000000..96edd01f3 --- /dev/null +++ b/tests/pending/pos/implicits-old.scala @@ -0,0 +1,89 @@ +// #1435 +object t1435 { + implicit def a(s:String):String = sys.error("") + implicit def a(i:Int):String = sys.error("") + implicit def b(i:Int):String = sys.error("") +} + +class C1435 { + val v:String = { + import t1435.a + 2 + } +} + +// #1492 +class C1492 { + + class X + + def foo(x: X => X): Unit = {} + + foo ( implicit x => implicitly[X] ) + foo { implicit x => implicitly[X] } +} + +// #1579 +object Test1579 { + class Column + class Query[E](val value: E) + class Invoker(q: Any) { val foo = null } + + implicit def unwrap[C](q: Query[C]): C = q.value + implicit def invoker(q: Query[Column]): Test1579.Invoker = new Invoker(q) + + val q = new Query(new Column) + q.foo +} +// #1625 +object Test1625 { + + class Wrapped(x:Any) { + def unwrap() = x + } + + implicit def byName[A](x: =>A): Test1625.Wrapped = new Wrapped(x) + + implicit def byVal[A](x: A): A = x + + def main(args: Array[String]) = { + +// val res:Wrapped = 7 // works + + val res = 7.unwrap() // doesn't work + + println("=> result: " + res) + } +} + +object Test2188 { + implicit def toJavaList[A: ClassManifest](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) + + val x: java.util.List[String] = List("foo") +} + +object TestNumericWidening { + val y = 1 + val x: java.lang.Long = y +} + +// #2709 +package foo2709 { + class A + class B + + package object bar { + implicit def a2b(a: A): B = new B + } + + package bar { + object test { + new A: B + } + } +} + +// Problem with specs +object specsProblem { + println(implicitly[Manifest[Class[_]]]) +} diff --git a/tests/pending/pos/imports-pos.scala b/tests/pending/pos/imports-pos.scala new file mode 100644 index 000000000..f6a55e5e0 --- /dev/null +++ b/tests/pending/pos/imports-pos.scala @@ -0,0 +1,16 @@ +package test; + +import java.lang.{System => S} + +object test { + import S.out.{print => p, println => print} + + val foo = 1; + + p("hello"); print("world"); S.out.println("!"); + S.out.flush(); +} +object test1 { + import test._; + foo +} diff --git a/tests/pending/pos/infer2-pos.scala b/tests/pending/pos/infer2-pos.scala new file mode 100644 index 000000000..2ce88be54 --- /dev/null +++ b/tests/pending/pos/infer2-pos.scala @@ -0,0 +1,7 @@ +package test +class Lst[T] +case class cons[T](x: T, xs: Lst[T]) extends Lst[T] +case class nil[T]() extends Lst[T] +object test { + Console.println(cons(1, nil())) +} diff --git a/tests/pending/pos/infersingle.flags b/tests/pending/pos/infersingle.flags new file mode 100644 index 000000000..e1b37447c --- /dev/null +++ b/tests/pending/pos/infersingle.flags @@ -0,0 +1 @@ +-Xexperimental
\ No newline at end of file diff --git a/tests/pending/pos/infersingle.scala b/tests/pending/pos/infersingle.scala new file mode 100644 index 000000000..60f4ff07e --- /dev/null +++ b/tests/pending/pos/infersingle.scala @@ -0,0 +1,52 @@ +object Test1 { + def one[T](x: T): Option[T] = Some(x) + val x = "one" + val y: Option[x.type] = one(x) +} + +object Test2 { + // Has never worked, but seems desirable given the recent changes to + // pattern type inference. + val a = "" + object Id { + def unapply(xxxx: Any): Some[a.type] = Some[a.type](a) + } + val b: a.type = (a: a.type) match { + case Id(x) => x + } +} + +object Test3 { + val a = "" + object Id { + def unapply(xxxx: Any): Some[Test3.type] = Some[Test3.type](Test3) + } + val b: Test3.type = a match { + case Id(x) => x + } +} + +class Test4 { + val a = "" + object Id { + def unapply(xxxx: Any): Some[Test4.this.type] = Some[Test4.this.type](Test4.this) + } + val b: Test4.this.type = a match { + case Id(x) => x + } +} + +class Super5 { + final val q = "" + def q1: q.type = q +} + +class Test5 extends Super5 { + val a = "" + object Id { + def unapply(xxxx: Any): Some[Test5.super.q.type] = Some[Test5.super.q.type](q1) + } + val b: Test5.super.q.type = a match { + case Id(x) => x + } +} diff --git a/tests/pending/pos/isApplicableSafe.scala b/tests/pending/pos/isApplicableSafe.scala new file mode 100644 index 000000000..b4cacbf28 --- /dev/null +++ b/tests/pending/pos/isApplicableSafe.scala @@ -0,0 +1,8 @@ +class A { + // Any of Array[List[Symbol]], List[Array[Symbol]], or List[List[Symbol]] compile. + var xs: Array[Array[Symbol]] = _ + var ys: Array[Map[Symbol, Set[Symbol]]] = _ + + xs = Array(Array()) + ys = Array(Map(), Map()) +} diff --git a/tests/pending/pos/lambdalift.scala b/tests/pending/pos/lambdalift.scala new file mode 100644 index 000000000..bc997d6f8 --- /dev/null +++ b/tests/pending/pos/lambdalift.scala @@ -0,0 +1,15 @@ +import scala._; + +object test { + + def f(x: Int) = { + def g() = h(); + def h() = x; + g(); + class inner() { + def g() = h(); + def h() = x; + } + g() + new inner().g(); + } +} diff --git a/tests/pending/pos/lambdalift1.scala b/tests/pending/pos/lambdalift1.scala new file mode 100644 index 000000000..01b224c3b --- /dev/null +++ b/tests/pending/pos/lambdalift1.scala @@ -0,0 +1,17 @@ +import scala._; + +object test { + + def f[a <: java.lang.Object](x: a) = { + def print() = java.lang.System.out.println(x); + class A() { + def g() = { + class B() { + def h() = print() + } + new B().h() + } + } + new A().g() + } +} diff --git a/tests/pending/pos/liftcode_polymorphic.scala b/tests/pending/pos/liftcode_polymorphic.scala new file mode 100644 index 000000000..249f5a056 --- /dev/null +++ b/tests/pending/pos/liftcode_polymorphic.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ + +object Append extends App { + + def append[A](l1: List[A], l2: List[A]):List[A] = + l1 match { + case Nil => l2 + case x::xs => x :: append(xs, l2) + } + + println(reify(append _).tree) +} diff --git a/tests/pending/pos/list-optim-check.flags b/tests/pending/pos/list-optim-check.flags new file mode 100644 index 000000000..49d036a88 --- /dev/null +++ b/tests/pending/pos/list-optim-check.flags @@ -0,0 +1 @@ +-optimize diff --git a/tests/pending/pos/list-optim-check.scala b/tests/pending/pos/list-optim-check.scala new file mode 100644 index 000000000..f6e6ddec7 --- /dev/null +++ b/tests/pending/pos/list-optim-check.scala @@ -0,0 +1,21 @@ +// Tests a map known to crash in optimizer with faster List map in SI-8240. +// Equivalent tests for collect and flatmap do not crash, but are provided +// anyway. +// See ticket SI-8334 for optimizer bug. +// TODO - Remove this test once SI-8334 is fixed and has its own test. +class A { + def f: Boolean = { + val xs = Nil map (_ => return false) + true + } + + def g: Boolean = { + val xs = Nil collect { case _ => return false } + true + } + + def h: Boolean = { + val xs = Nil flatMap { _ => return false } + true + } +} diff --git a/tests/pending/pos/lookupswitch.scala b/tests/pending/pos/lookupswitch.scala new file mode 100644 index 000000000..5d4825124 --- /dev/null +++ b/tests/pending/pos/lookupswitch.scala @@ -0,0 +1,36 @@ +// There's not a real test here, but on compilation the +// switch should have the cases arranged in order from 1-30. +class A { + def f(x: Int) = x match { + case 6 => "6" + case 18 => "18" + case 7 => "7" + case 2 => "2" + case 13 => "13" + case 11 => "11" + case 26 => "26" + case 27 => "27" + case 29 => "29" + case 25 => "25" + case 9 => "9" + case 17 => "17" + case 16 => "16" + case 1 => "1" + case 30 => "30" + case 15 => "15" + case 22 => "22" + case 19 => "19" + case 23 => "23" + case 8 => "8" + case 28 => "28" + case 5 => "5" + case 12 => "12" + case 10 => "10" + case 21 => "21" + case 24 => "24" + case 4 => "4" + case 14 => "14" + case 3 => "3" + case 20 => "20" + } +} diff --git a/tests/pending/pos/looping-jsig.scala b/tests/pending/pos/looping-jsig.scala new file mode 100644 index 000000000..6e3313c46 --- /dev/null +++ b/tests/pending/pos/looping-jsig.scala @@ -0,0 +1,18 @@ +import scala.collection.mutable._ + +trait BugTrack { + trait B[+T] + val cache : HashMap[A[_], B[_]] = HashMap.empty + + def A[T](f: Int => B[T]): A[T] + = new A[T]{def apply(in: Int) = f(in)} + + abstract class A[+T] extends (Int => B[T]) { + def giveMeSame = this + } + + def amethod[T](p: =>A[T]): A[T] = A(in => cache.get(p) match { + case Some(res) => res + case None => p(in) + }).giveMeSame.asInstanceOf[A[T]] +} diff --git a/tests/pending/pos/lubs.scala b/tests/pending/pos/lubs.scala new file mode 100644 index 000000000..d7651f86b --- /dev/null +++ b/tests/pending/pos/lubs.scala @@ -0,0 +1,3 @@ +object Test { + List(new { def f = 1; def g = 1}, new { def f = 2}).map(_.f) +} diff --git a/tests/pending/pos/macro-bundle-disambiguate-bundle.check b/tests/pending/pos/macro-bundle-disambiguate-bundle.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/macro-bundle-disambiguate-bundle.check diff --git a/tests/pending/pos/macro-bundle-disambiguate-bundle.scala b/tests/pending/pos/macro-bundle-disambiguate-bundle.scala new file mode 100644 index 000000000..40d965b0e --- /dev/null +++ b/tests/pending/pos/macro-bundle-disambiguate-bundle.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: Context) { + def impl = ??? +} + +object Macros { + def impl(c: Context)(x: c.Tree) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +} diff --git a/tests/pending/pos/macro-bundle-disambiguate-nonbundle.check b/tests/pending/pos/macro-bundle-disambiguate-nonbundle.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/macro-bundle-disambiguate-nonbundle.check diff --git a/tests/pending/pos/macro-bundle-disambiguate-nonbundle.scala b/tests/pending/pos/macro-bundle-disambiguate-nonbundle.scala new file mode 100644 index 000000000..185177607 --- /dev/null +++ b/tests/pending/pos/macro-bundle-disambiguate-nonbundle.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: Context) { + def impl(x: c.Tree) = ??? +} + +object Macros { + def impl(c: Context) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +} diff --git a/tests/pending/pos/macro-deprecate-dont-touch-backquotedidents.flags b/tests/pending/pos/macro-deprecate-dont-touch-backquotedidents.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/pending/pos/macro-deprecate-dont-touch-backquotedidents.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/macro-deprecate-dont-touch-backquotedidents.scala b/tests/pending/pos/macro-deprecate-dont-touch-backquotedidents.scala new file mode 100644 index 000000000..8eb5a0238 --- /dev/null +++ b/tests/pending/pos/macro-deprecate-dont-touch-backquotedidents.scala @@ -0,0 +1,56 @@ +object Test1 { + val `macro` = ??? +} + +object Test2 { + var `macro` = ??? +} + +object Test3 { + type `macro` = Int +} + +package test4 { + class `macro` +} + +object Test5 { + class `macro` +} + +package test6 { + object `macro` +} + +object Test7 { + object `macro` +} + +package test8 { + trait `macro` +} + +object Test9 { + trait `macro` +} + +package `macro` { + package `macro`.bar { + } +} + +package foo { + package `macro`.foo { + } +} + +//object Test12 { +// val Some(`macro`) = Some(42) +// `macro` match { +// case `macro` => println(`macro`) +// } +//} + +object Test13 { + def `macro` = 2 +} diff --git a/tests/pending/pos/macro-implicit-invalidate-on-error.check b/tests/pending/pos/macro-implicit-invalidate-on-error.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/macro-implicit-invalidate-on-error.check diff --git a/tests/pending/pos/macro-implicit-invalidate-on-error.scala b/tests/pending/pos/macro-implicit-invalidate-on-error.scala new file mode 100644 index 000000000..bb83e3cc3 --- /dev/null +++ b/tests/pending/pos/macro-implicit-invalidate-on-error.scala @@ -0,0 +1,25 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +trait LegacyLiftable[T] { + def apply(universe: scala.reflect.api.Universe, value: T): universe.Tree +} + +object LegacyLiftable { + implicit def liftCaseClass[T <: Product]: LegacyLiftable[T] = macro liftCaseClassImpl[T] + + def liftCaseClassImpl[T: c.WeakTypeTag](c: Context): c.Expr[LegacyLiftable[T]] = { + import c.universe._ + val tpe = weakTypeOf[T] + if (!tpe.typeSymbol.asClass.isCaseClass) c.abort(c.enclosingPosition, "denied") + val p = List(q"Literal(Constant(1))") + c.Expr[LegacyLiftable[T]] { q""" + new LegacyLiftable[$tpe] { + def apply(universe: scala.reflect.api.Universe, value: $tpe): universe.Tree = { + import universe._ + Apply(Select(Ident(TermName("C")), TermName("apply")), List(..$p)) + } + } + """ } + } +} diff --git a/tests/pending/pos/macro-qmarkqmarkqmark.scala b/tests/pending/pos/macro-qmarkqmarkqmark.scala new file mode 100644 index 000000000..de94d69d5 --- /dev/null +++ b/tests/pending/pos/macro-qmarkqmarkqmark.scala @@ -0,0 +1,7 @@ +import language.experimental.macros + +object Macros { + def foo1 = macro ??? + def foo2(x: Int) = macro ??? + def foo3[T] = macro ??? +} diff --git a/tests/pending/pos/manifest1-new.scala b/tests/pending/pos/manifest1-new.scala new file mode 100644 index 000000000..3a957bf0d --- /dev/null +++ b/tests/pending/pos/manifest1-new.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ + +object Test { + def foo[T](x: T)(implicit m: TypeTag[T]): Unit = { + foo(List(x)) + } + foo(1) + foo("abc") + foo(List(1, 2, 3)) + val x: List[Int] with Ordered[List[Int]] = null + foo(x) + foo[x.type](x) + abstract class C { type T = String; val x: T } + val c = new C { val x = "abc" } + foo(c.x) + abstract class D { type T; implicit val m: TypeTag[T]; val x: T } + val stringm = implicitly[TypeTag[String]] + val d: D = new D { type T = String; val m = stringm; val x = "x" } + import d.m + foo(d.x) +} diff --git a/tests/pending/pos/manifest1-old.scala b/tests/pending/pos/manifest1-old.scala new file mode 100644 index 000000000..b24311bd3 --- /dev/null +++ b/tests/pending/pos/manifest1-old.scala @@ -0,0 +1,21 @@ +import scala.reflect.Manifest + +object Test { + def foo[T](x: T)(implicit m: Manifest[T]): Unit = { + foo(List(x)) + } + foo(1) + foo("abc") + foo(List(1, 2, 3)) + val x: List[Int] with Ordered[List[Int]] = null + foo(x) + foo[x.type](x) + abstract class C { type T = String; val x: T } + val c = new C { val x = "abc" } + foo(c.x) + abstract class D { type T; implicit val m: Manifest[T]; val x: T } + val stringm = implicitly[Manifest[String]] + val d: D = new D { type T = String; val m = stringm; val x = "x" } + import d.m + foo(d.x) +} diff --git a/tests/pending/pos/matthias1.scala b/tests/pending/pos/matthias1.scala new file mode 100644 index 000000000..a923a529f --- /dev/null +++ b/tests/pending/pos/matthias1.scala @@ -0,0 +1,15 @@ +class A() { + class B() { + def foo(x: B) = 0 + } +} +object test { + def main = { + val a = new A(); + val b = new a.B(); + val c = new a.B(); + val d = b.foo(c); + () + } +} + diff --git a/tests/pending/pos/matthias4.scala b/tests/pending/pos/matthias4.scala new file mode 100644 index 000000000..18599ae71 --- /dev/null +++ b/tests/pending/pos/matthias4.scala @@ -0,0 +1,84 @@ +/* +object A requires B { + B.X getX() { + return B.getX(); + } + void setX(B.X x) {} +} +object B { + class X {} + X getX() { + return new X(); + } + void setX(X x) {} +} +object C requires B { + object A; + void test() { + A.setX(B.getX()); + } +} +*/ + +trait _a extends AnyRef with _b { + val a: _a; + val A: A; + type A <: a.AObject; + trait AObject { + def getX(): B.X; + def setX(x: B.X): Unit; + } +} +trait a123 extends AnyRef with _a with _b { + val a: this.type = this; + val A: A = new A(); + class A() extends AObject { + def getX(): B.X = B.getX(); + def setX(x: B.X) = B.setX(x); + } +} + +trait _b { + val b: _b; + val B: B; + type B <: b.BObject; + trait BObject { + type X; + def getX(): X; + def setX(x: X): Unit; + } +} +abstract class b() extends AnyRef with _b { + val b: this.type = this; + val B: B = new B(); + class B() extends BObject { + class X() {} + def getX(): X = new X(); + def setX(x: X) = (); + } +} + +trait _m { + val m: _m; + val M: M; + type M <: m.MObject; + trait MObject {} +} +abstract class m() extends AnyRef with _m with _b { + val m: this.type = this; + val M: M = new M(); + class M() extends MObject with a123 with Linker { + def test() = { + val x: B.X = B.getX(); + A.setX(x); + } + } + trait Linker { + val b: m.this.b.type = m.this.b; + val B: m.this.B.type = m.this.B; + type B = m.this.B; + val m: m.this.m.type = m.this.m; + val M: m.this.M.type = m.this.M; + type M = m.this.M; + } +} diff --git a/tests/pending/pos/michel6.scala b/tests/pending/pos/michel6.scala new file mode 100644 index 000000000..b32e8bed7 --- /dev/null +++ b/tests/pending/pos/michel6.scala @@ -0,0 +1,6 @@ +object M { + def f(x: Int): Unit = {} + + def g(): Int => Unit = + if (0 == 0) f else g() + } diff --git a/tests/pending/pos/mixins.scala b/tests/pending/pos/mixins.scala new file mode 100644 index 000000000..846d6a41b --- /dev/null +++ b/tests/pending/pos/mixins.scala @@ -0,0 +1,22 @@ +package mixins +abstract class Super { + def foo: Int +} +trait Mixin extends Super { + abstract override def foo = super.foo +} +trait MixinSub extends Super with Mixin { + abstract override def foo: Int = super.foo +} +trait MixinSubSub extends MixinSub { + abstract override def foo = super.foo +} +class Sub extends Super { + def foo: Int = 1 +} +class Base extends Sub with MixinSubSub { + override def foo = super.foo +} +trait Mixin1 extends Sub with MixinSubSub {} +class Base1 extends Mixin1 {} + diff --git a/tests/pending/pos/moduletrans.scala b/tests/pending/pos/moduletrans.scala new file mode 100644 index 000000000..51538417e --- /dev/null +++ b/tests/pending/pos/moduletrans.scala @@ -0,0 +1,8 @@ +object m1 { + + class m() { + def f() = 5 + } + final val m: m = new m() + +} diff --git a/tests/pending/pos/native-warning.flags b/tests/pending/pos/native-warning.flags new file mode 100644 index 000000000..65faf5357 --- /dev/null +++ b/tests/pending/pos/native-warning.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation
\ No newline at end of file diff --git a/tests/pending/pos/native-warning.scala b/tests/pending/pos/native-warning.scala new file mode 100644 index 000000000..f721a57e8 --- /dev/null +++ b/tests/pending/pos/native-warning.scala @@ -0,0 +1,3 @@ +class A { + @native def setup(): Unit +} diff --git a/tests/pending/pos/nonlocal-unchecked.flags b/tests/pending/pos/nonlocal-unchecked.flags new file mode 100644 index 000000000..144ddac9d --- /dev/null +++ b/tests/pending/pos/nonlocal-unchecked.flags @@ -0,0 +1 @@ +-unchecked -Xfatal-warnings diff --git a/tests/pending/pos/nonlocal-unchecked.scala b/tests/pending/pos/nonlocal-unchecked.scala new file mode 100644 index 000000000..6bd3dc479 --- /dev/null +++ b/tests/pending/pos/nonlocal-unchecked.scala @@ -0,0 +1,6 @@ +class A { + def f: Boolean = { + val xs = Nil map (_ => return false) + true + } +} diff --git a/tests/pending/pos/nothing_manifest_disambig-new.scala b/tests/pending/pos/nothing_manifest_disambig-new.scala new file mode 100644 index 000000000..64afdee60 --- /dev/null +++ b/tests/pending/pos/nothing_manifest_disambig-new.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ + +object Test { + def mani[T: TypeTag](xs: T) = xs + mani(List()) + + def listElMani[T: TypeTag](xs: List[T]) = xs + listElMani(List()) + + def foo[A, C](m : C)(implicit ev: C <:< Traversable[A], mani: TypeTag[A]): (C, A, TypeTag[A]) = (m, m.head, mani) + foo(List(1,2,3)) +} diff --git a/tests/pending/pos/nothing_manifest_disambig-old.scala b/tests/pending/pos/nothing_manifest_disambig-old.scala new file mode 100644 index 000000000..f282cb914 --- /dev/null +++ b/tests/pending/pos/nothing_manifest_disambig-old.scala @@ -0,0 +1,10 @@ +object Test { + def mani[T: Manifest](xs: T) = xs + mani(List()) + + def listElMani[T: Manifest](xs: List[T]) = xs + listElMani(List()) + + def foo[A, C](m : C)(implicit ev: C <:< Traversable[A], mani: Manifest[A]): (C, A, Manifest[A]) = (m, m.head, mani) + foo(List(1,2,3)) +} diff --git a/tests/pending/pos/optmatch.scala b/tests/pending/pos/optmatch.scala new file mode 100644 index 000000000..354be65da --- /dev/null +++ b/tests/pending/pos/optmatch.scala @@ -0,0 +1,33 @@ +// final case class NonZeroLong(value: Long) extends AnyVal { +// def get: Long = value +// def isEmpty: Boolean = get == 0l +// } + +class NonZeroLong(val value: Long) extends AnyVal { + def get: Long = value + def isEmpty: Boolean = get == 0l +} +object NonZeroLong { + def unapply(value: Long): NonZeroLong = new NonZeroLong(value) +} + + +object Foo { + def unapply(x: Int): NonZeroLong = new NonZeroLong(1L << x) + // public long unapply(int); + // 0: lconst_1 + // 1: iload_1 + // 2: lshl + // 3: lreturn +} + +object Test { + def f(x: Int): Int = x match { + case Foo(1024l) => 1 + case _ => 2 + } + def main(args: Array[String]): Unit = { + println(f(10)) + println(f(11)) + } +} diff --git a/tests/pending/pos/overloaded-unapply.scala b/tests/pending/pos/overloaded-unapply.scala new file mode 100644 index 000000000..4105a25f1 --- /dev/null +++ b/tests/pending/pos/overloaded-unapply.scala @@ -0,0 +1,8 @@ +trait Baz { + type Type >: Null + + case class HoleType(a: String, b: String, c: String) + object HoleType { def unapply(tpe: Type): Option[HoleType] = ??? } + + (null: Type) match { case HoleType(holeTpe) => holeTpe } +} diff --git a/tests/pending/pos/overloaded_extractor_and_regular_def.scala b/tests/pending/pos/overloaded_extractor_and_regular_def.scala new file mode 100644 index 000000000..72b9f65d8 --- /dev/null +++ b/tests/pending/pos/overloaded_extractor_and_regular_def.scala @@ -0,0 +1,32 @@ +trait TreesBase { + type Tree + + type Apply <: Tree + + val Apply: ApplyExtractor + + abstract class ApplyExtractor { + def apply(x: Int): Apply + def unapply(apply: Apply): Option[Int] + } +} + +trait TreesApi extends TreesBase { + def Apply(x: String): Unit +} + +class Universe extends TreesApi { + abstract class Tree + case class Apply(x: Int) extends Tree + object Apply extends ApplyExtractor + def Apply(x: String) = Apply(x.toInt) +} + +object Test extends App { + def foo(tapi: TreesApi): Unit = { + import tapi._ + def bar(tree: Tree): Unit = { + val Apply(x) = tree + } + } +} diff --git a/tests/pending/pos/override-object-yes.flags b/tests/pending/pos/override-object-yes.flags new file mode 100644 index 000000000..22e9a95c4 --- /dev/null +++ b/tests/pending/pos/override-object-yes.flags @@ -0,0 +1 @@ +-Yoverride-objects
\ No newline at end of file diff --git a/tests/pending/pos/override-object-yes.scala b/tests/pending/pos/override-object-yes.scala new file mode 100644 index 000000000..858f9b21f --- /dev/null +++ b/tests/pending/pos/override-object-yes.scala @@ -0,0 +1,40 @@ +package case1 { + class Bippy { + def f = 1 + } + + trait Foo { + object Bar extends Bippy { + override def f = 2 + } + } + + trait Foo2 extends Foo { + override object Bar extends Bippy { + override def f = 3 + } + } + + trait Foo3 { + object Bar { + def g: Traversable[Int] = Nil + } + } + trait Foo4 extends Foo3 { + override object Bar { + def g: List[Int] = Nil + } + } +} + +package case2 { + class Bar[T] + + class Foo[T] { + object A extends Bar[T] + } + + class Baz[S] extends Foo[S] { + override object A extends Bar[S] + } +} diff --git a/tests/pending/pos/package-case.scala b/tests/pending/pos/package-case.scala new file mode 100644 index 000000000..906f1eb3f --- /dev/null +++ b/tests/pending/pos/package-case.scala @@ -0,0 +1,4 @@ +// a.scala +// Sat Jul 16 00:34:36 EDT 2011 + +package object io { case class TextReader() } diff --git a/tests/pending/pos/package-implicit/ActorRef.scala b/tests/pending/pos/package-implicit/ActorRef.scala new file mode 100644 index 000000000..de57e61ce --- /dev/null +++ b/tests/pending/pos/package-implicit/ActorRef.scala @@ -0,0 +1,7 @@ +package t1000647.foo + +trait ActorRef { + def stop(): Unit = {} +} + +trait ScalaActorRef { self: ActorRef => } diff --git a/tests/pending/pos/package-implicit/DataFlow.scala b/tests/pending/pos/package-implicit/DataFlow.scala new file mode 100644 index 000000000..d948280d0 --- /dev/null +++ b/tests/pending/pos/package-implicit/DataFlow.scala @@ -0,0 +1,7 @@ +package t1000647.bar + +import t1000647.foo.{ScalaActorRef} + +object DataFlow { + def foo(ref: ScalaActorRef) = ref.stop() +} diff --git a/tests/pending/pos/package-implicit/package.scala b/tests/pending/pos/package-implicit/package.scala new file mode 100644 index 000000000..d0f28b36b --- /dev/null +++ b/tests/pending/pos/package-implicit/package.scala @@ -0,0 +1,6 @@ +package t1000647 + +package object foo { + implicit def scala2ActorRef(ref: ScalaActorRef): ActorRef = + ref.asInstanceOf[ActorRef] +} diff --git a/tests/pending/pos/package-ob-case/A_1.scala b/tests/pending/pos/package-ob-case/A_1.scala new file mode 100644 index 000000000..91a1fb7e4 --- /dev/null +++ b/tests/pending/pos/package-ob-case/A_1.scala @@ -0,0 +1,5 @@ +package foo { + package object foo { + case class X(z: Int) { } + } +} diff --git a/tests/pending/pos/package-ob-case/B_2.scala b/tests/pending/pos/package-ob-case/B_2.scala new file mode 100644 index 000000000..91a1fb7e4 --- /dev/null +++ b/tests/pending/pos/package-ob-case/B_2.scala @@ -0,0 +1,5 @@ +package foo { + package object foo { + case class X(z: Int) { } + } +} diff --git a/tests/pending/pos/pat_iuli.scala b/tests/pending/pos/pat_iuli.scala new file mode 100644 index 000000000..46356ff58 --- /dev/null +++ b/tests/pending/pos/pat_iuli.scala @@ -0,0 +1,22 @@ +trait Ops { self: MyCodes => + abstract class Instru + object opcodes { + case class SWITCH(i:Int) extends Instru + case object EmptyInstr extends Instru + } +} + +trait Blox { self: MyCodes => + import opcodes._ + class Basick { + var foo: Instru = null + + def bar = foo match { + case SWITCH(i) => i + case EmptyInstr => 0 + } + } +} + +abstract class MyCodes extends AnyRef with Ops with Blox { +} diff --git a/tests/pending/pos/patmat.scala b/tests/pending/pos/patmat.scala new file mode 100644 index 000000000..53e1c5f1f --- /dev/null +++ b/tests/pending/pos/patmat.scala @@ -0,0 +1,163 @@ +// these used to be in test/files/run/patmatnew.scala +// the ticket numbers are from the old tracker, not Trac + +object ZipFun { + //just compilation + def zipFun[a, b](xs: List[a], ys: List[b]): List[Tuple2[a, b]] = ((xs, ys): @unchecked) match { + // !!! case (List(), _), (_, List()) => List() + case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1) + } +} + +object Test1253 { // compile-only + def foo(t: (Int, String)) = t match { + case (1, "") => throw new Exception + case (r, _) => throw new Exception(r.toString) + } +} + +object Foo1258 { + case object baz + def foo(bar: AnyRef) = { + val Baz = baz + bar match { + case Baz => () + } + } +} + +object t1261 { + sealed trait Elem + case class Foo() extends Elem + case class Bar() extends Elem + trait Row extends Elem + object Row { + def unapply(r: Row) = true + + def f(elem: Elem): Unit = { + elem match { + case Bar() => ; + case Row() => ; + case Foo() => ; // used to give ERROR (unreachable code) + } + } + } +} + +sealed abstract class Tree +case class Node(l: Tree, v: Int, r: Tree) extends Tree +case object EmptyTree extends Tree + +object Ticket335 { // compile-only + def runTest(): Unit = { + (EmptyTree: Tree @unchecked) match { + case Node(_, v, _) if (v == 0) => 0 + case EmptyTree => 2 + } + } +} + +object TestIfOpt { //compile-only "test EqualsPatternClass in combination with MixTypes opt, bug #1278" + trait Token { + val offset: Int + def matching: Option[Token] + } + def go(tok: Token) = (tok.matching: @unchecked) match { + case Some(other) if true => Some(other) + case _ if true => tok.matching match { + case Some(other) => Some(other) + case _ => None + } + } +} + +object Go { // bug #1277 compile-only + trait Core { def next: Position = null } + trait Dir + val NEXT = new Dir {} + + trait Position extends Core + + (null: Core, null: Dir) match { + case (_, NEXT) if true => false // no matter whether NEXT test succeed, cannot throw column because of guard + case (at2: Position, dir) => true + } +} + +trait Outer { // bug #1282 compile-only + object No + trait File { + (null: AnyRef) match { + case No => false + } + } +} + +class Test806_818 { // #806, #811 compile only -- type of bind + // t811 + trait Core { + trait NodeImpl + trait OtherImpl extends NodeImpl + trait DoubleQuoteImpl extends NodeImpl + def asDQ(node: OtherImpl) = node match { + case dq: DoubleQuoteImpl => dq + } + } + + trait IfElseMatcher { + type Node <: NodeImpl + trait NodeImpl + trait IfImpl + private def coerceIf(node: Node) = node match { + case node: IfImpl => node // var node is of type Node with IfImpl! + case _ => null + } + } +} + +object Ticket495bis { + def signum(x: Int): Int = + x match { + case 0 => 0 + case _ if x < 0 => -1 + case _ if x > 0 => 1 + } + def pair_m(x: Int, y: Int) = + (x, y) match { + case (_, 0) => 0 + case (-1, _) => -1 + case (_, _) => 1 + } +} + +object Ticket522 { + class Term[X] + object App { + // i'm hidden + case class InternalApply[Y, Z](fun: Y => Z, arg: Y) extends Term[Z] + + def apply[Y, Z](fun: Y => Z, arg: Y): Term[Z] = + new InternalApply[Y, Z](fun, arg) + + def unapply[X](arg: Term[X]): Option[(Y => Z, Y)] forSome { type Y; type Z } = + arg match { + case i: InternalApply[y, z] => Some(i.fun, i.arg) + case _ => None + } + } + + App({ x: Int => x }, 5) match { + case App(arg, a) => + } +} + +object Ticket710 { + def method: Unit = { + sealed class Parent() + case object Child extends Parent() + val x: Parent = Child + x match { + case Child => () + } + } +} diff --git a/tests/pending/pos/patterns.scala b/tests/pending/pos/patterns.scala new file mode 100644 index 000000000..547d692d8 --- /dev/null +++ b/tests/pending/pos/patterns.scala @@ -0,0 +1,38 @@ +trait Option[+a] {} + +case class Some[a](x: a) extends Option[a] { + override def toString(): String = "Some(" + x + ")" + override def equals(that: Any): Boolean = that match { + case Some(x) => this.x == x + case _ => false + } + override def hashCode(): Int = getClass().hashCode() * 41 + x.hashCode() +} + +case object None extends Option[Nothing] { + override def toString(): String = "None" + override def equals(that: Any) = that match { + case None => true + case _ => false + } + override def hashCode(): Int = getClass().hashCode() +} + +object test { + + def println(str: String): Unit = java.lang.System.out.println(str) + + def print(opt: Option[String]) = opt match { + case Some(x) => println(x) + case None => println("nothing") + } +} + +// if bodies are duplicated, then we would get an error like "double definition" + +trait John[A,B] { + def filter(x:Any) = x match { + case (x::xs, _) => "ga" + case _ => {x:String => "foobar"} + } +} diff --git a/tests/pending/pos/patterns1.scala b/tests/pending/pos/patterns1.scala new file mode 100644 index 000000000..f660ea054 --- /dev/null +++ b/tests/pending/pos/patterns1.scala @@ -0,0 +1,15 @@ +trait Option[+a] + +case class Some[a](x: a) extends Option[a] + +case object None extends Option[Nothing] + +object test { + + def println(str: String): Unit = java.lang.System.out.println(str) + + def print(opt: Option[String]) = opt match { + case Some(x) => println(x) + case None => println("nothing") + } +} diff --git a/tests/pending/pos/philippe4.scala b/tests/pending/pos/philippe4.scala new file mode 100644 index 000000000..9ce3691f5 --- /dev/null +++ b/tests/pending/pos/philippe4.scala @@ -0,0 +1,3 @@ +trait Foo[t <: Foo[t]] { self: t => + def foo(that: t): Boolean; +} diff --git a/tests/pending/pos/pmbug.scala b/tests/pending/pos/pmbug.scala new file mode 100644 index 000000000..7d94e7a8b --- /dev/null +++ b/tests/pending/pos/pmbug.scala @@ -0,0 +1,8 @@ +object Test { + + def flatten[a](l: List[List[a]]): List[a] = l match { + case Nil => Nil + case head :: tail => head ::: flatten(tail) + } + +} diff --git a/tests/pending/pos/pos-bug1241.scala b/tests/pending/pos/pos-bug1241.scala new file mode 100644 index 000000000..1038dc304 --- /dev/null +++ b/tests/pending/pos/pos-bug1241.scala @@ -0,0 +1,8 @@ +object test extends App { + // more.. + type T = { def hello(): Unit } + //val x4 = new AnyRef { def hello() { println("4") } } // ok! + val x4: T = new { def hello(): Unit = { println("4") } } // error! + x4.hello() + // more.. +} diff --git a/tests/pending/pos/presuperContext.scala b/tests/pending/pos/presuperContext.scala new file mode 100644 index 000000000..ae677c08e --- /dev/null +++ b/tests/pending/pos/presuperContext.scala @@ -0,0 +1,18 @@ +class A { + class C extends AnyRef { +// TODO NEEDS MANUAL CHANGE (early initializers) +// BEGIN copied early initializers +val x: A = this +// END copied early initializers +} +} + +class B(x: Int) + +class D { + class C(x: Int) extends B({val test: D = this; x}) { + def this() = { + this({val test: D = this; 1}) + } + } +} diff --git a/tests/pending/pos/private-types-after-typer.scala b/tests/pending/pos/private-types-after-typer.scala new file mode 100644 index 000000000..5c20cac2a --- /dev/null +++ b/tests/pending/pos/private-types-after-typer.scala @@ -0,0 +1,9 @@ +// Testing that the type of the outer accessor in O2 +// doesn't crash the compiler over private type escaping scope. +trait T { + class C { + private object O1 { + object O2 + } + } +} diff --git a/tests/pending/pos/proj-rec-test.flags b/tests/pending/pos/proj-rec-test.flags new file mode 100644 index 000000000..ad928f52a --- /dev/null +++ b/tests/pending/pos/proj-rec-test.flags @@ -0,0 +1 @@ +-Yrecursion 1 diff --git a/tests/pending/pos/proj-rec-test.scala b/tests/pending/pos/proj-rec-test.scala new file mode 100644 index 000000000..b7efcf3e8 --- /dev/null +++ b/tests/pending/pos/proj-rec-test.scala @@ -0,0 +1,13 @@ +object ProjTest { + trait MInt { type Type } + trait _0 extends MInt { type Type = Boolean } + trait Succ[Pre <: MInt] extends MInt { type Type = Pre#Type } + + type _1 = Succ[_0] + type _2 = Succ[_1] + + type X1 = _0#Type // Ok + type X2 = _1#Type // Ok + type X3 = _2#Type // Compiler error, illegal cyclic reference involving type Type +} + diff --git a/tests/pending/pos/protected-t1010.scala b/tests/pending/pos/protected-t1010.scala new file mode 100644 index 000000000..8575ddaaf --- /dev/null +++ b/tests/pending/pos/protected-t1010.scala @@ -0,0 +1,27 @@ +/** Check protected accessors involving polymorphic methods. */ + +package pkg2 { + +trait PresentationsX extends pkg1.Presentations { + trait ProjectImpl extends super.ProjectImpl { + trait FileImpl extends super.FileImpl { + lockTyper(Console.println) + } + } +} + +} // pkg2 + +package pkg1 { + +trait Presentations { + trait ProjectImpl { + trait FileImpl + protected def lockTyper[T](f : => T) = { + if (this == null) None + else Some(f) + } + } +} + +} // pkg1 diff --git a/tests/pending/pos/rangepos-anonapply.flags b/tests/pending/pos/rangepos-anonapply.flags new file mode 100644 index 000000000..281f0a10c --- /dev/null +++ b/tests/pending/pos/rangepos-anonapply.flags @@ -0,0 +1 @@ +-Yrangepos diff --git a/tests/pending/pos/rangepos-anonapply.scala b/tests/pending/pos/rangepos-anonapply.scala new file mode 100644 index 000000000..0fd04855e --- /dev/null +++ b/tests/pending/pos/rangepos-anonapply.scala @@ -0,0 +1,9 @@ +class Test { + trait PropTraverser { + def apply(x: Int): Unit = {} + } + + def gather(x: Int): Unit = { + (new PropTraverser {})(x) + } +} diff --git a/tests/pending/pos/reflection-compat-api-universe.check b/tests/pending/pos/reflection-compat-api-universe.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/reflection-compat-api-universe.check diff --git a/tests/pending/pos/reflection-compat-api-universe.scala b/tests/pending/pos/reflection-compat-api-universe.scala new file mode 100644 index 000000000..0add9704c --- /dev/null +++ b/tests/pending/pos/reflection-compat-api-universe.scala @@ -0,0 +1,136 @@ +object Test extends App { + val u: scala.reflect.api.Universe = ??? + import u._ + import scala.reflect.ClassTag + import compat._ + + val tree: Tree = ??? + val ttree: TypeTree = ??? + val stree: SymTree = ??? + val trees: List[Tree] = ??? + val mods: Modifiers = ??? + val impl: Template = ??? + val vparamss: List[List[ValDef]] = ??? + val rhs: Tree = ??? + val sym: Symbol = ??? + val tsym: TypeSymbol = ??? + val syms: List[Symbol] = ??? + val params: List[Symbol] = ??? + val tparams: List[Symbol] = ??? + val tpe: Type = ??? + val tpes: List[Type] = ??? + val manifest: Manifest[Int] = ??? + val tag: TypeTag[Int] = ??? + val mirror: Mirror = ??? + val decls: Scope = ??? + val pos: Position = ??? + val ann: Annotation = ??? + val anns: List[Annotation] = ??? + val const: Constant = ??? + val name: Name = ??? + val tyname: TypeName = ??? + val tename: TermName = ??? + val flags: FlagSet = ??? + val str: String = ??? + val i: Int = ??? + val b: Boolean = ??? + + // abstract class BuildApi + // abstract class ReferenceToBoxedExtractor + // abstract trait AttachableApi + // abstract trait FreeTermSymbolApi + // abstract trait FreeTypeSymbolApi + // abstract trait IdentContextApi + // abstract trait ReferenceToBoxedApi + // abstract trait SymTreeContextApi + // abstract trait SymbolContextApi + // abstract trait TreeContextApi + // abstract trait TypeTreeContextApi + locally(ClassDef(sym, impl): ClassDef) + locally(DefDef(sym, mods, vparamss, rhs): DefDef) + locally(DefDef(sym, vparamss, rhs): DefDef) + locally(DefDef(sym, mods, rhs): DefDef) + locally(DefDef(sym, rhs): DefDef) + locally(DefDef(sym, (??? : List[List[Symbol]] => Tree)): DefDef) + locally(LabelDef(sym, params, rhs): LabelDef) + locally(ModuleDef(sym, impl): ModuleDef) + locally(TypeDef(sym, rhs): TypeDef) + locally(TypeDef(sym): TypeDef) + locally(ValDef(sym, rhs): ValDef) + locally(ValDef(sym): ValDef) + locally(AnnotatedType(anns, tpe): AnnotatedType) + locally(BoundedWildcardType(??? : TypeBounds): BoundedWildcardType) + locally(TypeBounds(tpe, tpe): TypeBounds) + locally(MethodType(params, tpe): MethodType) + locally(RefinedType(tpes, decls): RefinedType) + locally(RefinedType(tpes, decls, sym): RefinedType) + locally(ClassInfoType(tpes, decls, sym): ClassInfoType) + locally(SingleType(tpe, sym): Type) + locally(TypeRef(tpe, sym, tpes): Type) + locally(ExistentialType(syms, tpe): ExistentialType) + locally(NullaryMethodType(tpe): NullaryMethodType) + locally(ThisType(sym): Type) + locally(SuperType(tpe, tpe): Type) + locally(PolyType(syms, tpe): PolyType) + locally(ConstantType(const): ConstantType) + locally(sym.asFreeTerm: FreeTermSymbol) + locally(sym.asFreeType: FreeTypeSymbol) + locally(existentialAbstraction(tparams, tpe): Type) + locally(tree.freeTerms: List[FreeTermSymbol]) + locally(tree.freeTypes: List[FreeTypeSymbol]) + locally(intersectionType(tpes): Type) + locally(intersectionType(tpes, sym): Type) + locally(sym.isErroneous: Boolean) + locally(sym.isFreeTerm: Boolean) + locally(sym.isFreeType: Boolean) + locally(sym.isLocal: Boolean) + locally(sym.isOverride: Boolean) + locally(tsym.isSkolem: Boolean) + locally(manifestToTypeTag(mirror, manifest): scala.reflect.api.Universe#TypeTag[Int]) + locally(mkImporter(scala.reflect.runtime.universe): Importer{val from: scala.reflect.runtime.universe.type}) + locally(sym.newClassSymbol(tyname, pos, flags): ClassSymbol) + locally(sym.newMethodSymbol(tename, pos, flags): MethodSymbol) + locally(sym.newModuleAndClassSymbol(name, pos, flags): (ModuleSymbol, ClassSymbol)) + locally(newScopeWith(sym, sym, sym): Scope) + locally(sym.newTermSymbol(tename, pos, flags): TermSymbol) + locally(sym.newTypeSymbol(tyname, pos, flags): TypeSymbol) + locally(polyType(tparams, tpe): Type) + locally(sym.pos: Position) + locally(refinedType(tpes, sym): Type) + locally(refinedType(tpes, sym, decls, pos): Type) + locally(singleType(tpe, sym): Type) + locally(tree.substituteSymbols(syms, syms): Tree) + locally(tree.substituteThis(sym, tree): Tree) + locally(tree.substituteTypes(syms, tpes): Tree) + locally(typeRef(tpe, sym, tpes): Type) + locally(typeTagToManifest(mirror, tag): Manifest[Int]) + locally(FreeTermSymbolTag: ClassTag[FreeTermSymbol]) + locally((??? : FreeTermSymbol).origin) + locally((??? : FreeTermSymbol).value) + locally(FreeTypeSymbolTag: ClassTag[FreeTypeSymbol]) + locally((??? : FreeTypeSymbol).origin) + locally(ReferenceToBoxedTag: ClassTag[ReferenceToBoxed]) + locally(build: BuildApi) + locally(ReferenceToBoxed(??? : Ident): ReferenceToBoxed) + locally((??? : ReferenceToBoxed).ident: Tree) + locally(ReferenceToBoxed.unapply(???): Option[Ident]) + locally(build.selectType(sym, str): TypeSymbol) + locally(build.selectTerm(sym, str): TermSymbol) + locally(build.selectOverloadedMethod(sym, str, i): MethodSymbol) + locally(build.newNestedSymbol(sym, name, pos, flags, b): Symbol) + locally(build.newFreeTerm(str, i): FreeTermSymbol) + locally(build.newFreeTerm(str, i, flags, str): FreeTermSymbol) + locally(build.newFreeType(str): FreeTypeSymbol) + locally(build.newFreeType(str, flags, str): FreeTypeSymbol) + locally(build.setTypeSignature(sym, tpe): Symbol) + locally(build.setAnnotations(sym, anns): Symbol) + locally(build.flagsFromBits(??? : Long): FlagSet) + locally(build.emptyValDef: ValDef) + locally(build.This(sym): Tree) + locally(build.Select(tree, sym): Select) + locally(build.Ident(sym): Ident) + locally(build.TypeTree(tpe): TypeTree) + locally(build.thisPrefix(sym): Type) + locally(build.setType(tree, tpe): Tree) + locally(build.setSymbol(tree, sym): Tree) +} diff --git a/tests/pending/pos/reflection-compat-c.check b/tests/pending/pos/reflection-compat-c.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/reflection-compat-c.check diff --git a/tests/pending/pos/reflection-compat-c.scala b/tests/pending/pos/reflection-compat-c.scala new file mode 100644 index 000000000..f5e3b0129 --- /dev/null +++ b/tests/pending/pos/reflection-compat-c.scala @@ -0,0 +1,139 @@ +import scala.reflect.macros.Context + +object Test extends App { + def impl(c: Context) = { + import c.universe._ + import scala.reflect.ClassTag + import compat._ + + val tree: Tree = ??? + val ttree: TypeTree = ??? + val stree: SymTree = ??? + val trees: List[Tree] = ??? + val mods: Modifiers = ??? + val impl: Template = ??? + val vparamss: List[List[ValDef]] = ??? + val rhs: Tree = ??? + val sym: Symbol = ??? + val tsym: TypeSymbol = ??? + val syms: List[Symbol] = ??? + val params: List[Symbol] = ??? + val tparams: List[Symbol] = ??? + val tpe: Type = ??? + val tpes: List[Type] = ??? + val manifest: Manifest[Int] = ??? + val tag: TypeTag[Int] = ??? + val mirror: Mirror = ??? + val decls: Scope = ??? + val pos: Position = ??? + val ann: Annotation = ??? + val anns: List[Annotation] = ??? + val const: Constant = ??? + val name: Name = ??? + val tyname: TypeName = ??? + val tename: TermName = ??? + val flags: FlagSet = ??? + val str: String = ??? + val i: Int = ??? + val b: Boolean = ??? + + // abstract class BuildApi + // abstract class ReferenceToBoxedExtractor + // abstract trait AttachableApi + // abstract trait FreeTermSymbolApi + // abstract trait FreeTypeSymbolApi + // abstract trait IdentContextApi + // abstract trait ReferenceToBoxedApi + // abstract trait SymTreeContextApi + // abstract trait SymbolContextApi + // abstract trait TreeContextApi + // abstract trait TypeTreeContextApi + locally(ClassDef(sym, impl): ClassDef) + locally(DefDef(sym, mods, vparamss, rhs): DefDef) + locally(DefDef(sym, vparamss, rhs): DefDef) + locally(DefDef(sym, mods, rhs): DefDef) + locally(DefDef(sym, rhs): DefDef) + locally(DefDef(sym, (??? : List[List[Symbol]] => Tree)): DefDef) + locally(LabelDef(sym, params, rhs): LabelDef) + locally(ModuleDef(sym, impl): ModuleDef) + locally(TypeDef(sym, rhs): TypeDef) + locally(TypeDef(sym): TypeDef) + locally(ValDef(sym, rhs): ValDef) + locally(ValDef(sym): ValDef) + locally(AnnotatedType(anns, tpe): AnnotatedType) + locally(BoundedWildcardType(??? : TypeBounds): BoundedWildcardType) + locally(TypeBounds(tpe, tpe): TypeBounds) + locally(MethodType(params, tpe): MethodType) + locally(RefinedType(tpes, decls): RefinedType) + locally(RefinedType(tpes, decls, sym): RefinedType) + locally(ClassInfoType(tpes, decls, sym): ClassInfoType) + locally(SingleType(tpe, sym): Type) + locally(TypeRef(tpe, sym, tpes): Type) + locally(ExistentialType(syms, tpe): ExistentialType) + locally(NullaryMethodType(tpe): NullaryMethodType) + locally(ThisType(sym): Type) + locally(SuperType(tpe, tpe): Type) + locally(PolyType(syms, tpe): PolyType) + locally(ConstantType(const): ConstantType) + locally(sym.asFreeTerm: FreeTermSymbol) + locally(sym.asFreeType: FreeTypeSymbol) + locally(existentialAbstraction(tparams, tpe): Type) + locally(tree.freeTerms: List[FreeTermSymbol]) + locally(tree.freeTypes: List[FreeTypeSymbol]) + locally(intersectionType(tpes): Type) + locally(intersectionType(tpes, sym): Type) + locally(sym.isErroneous: Boolean) + locally(sym.isFreeTerm: Boolean) + locally(sym.isFreeType: Boolean) + locally(sym.isLocal: Boolean) + locally(sym.isOverride: Boolean) + locally(tsym.isSkolem: Boolean) + locally(manifestToTypeTag(mirror, manifest): scala.reflect.api.Universe#TypeTag[Int]) + locally(mkImporter(scala.reflect.runtime.universe): Importer{val from: scala.reflect.runtime.universe.type}) + locally(sym.newClassSymbol(tyname, pos, flags): ClassSymbol) + locally(sym.newMethodSymbol(tename, pos, flags): MethodSymbol) + locally(sym.newModuleAndClassSymbol(name, pos, flags): (ModuleSymbol, ClassSymbol)) + locally(newScopeWith(sym, sym, sym): Scope) + locally(sym.newTermSymbol(tename, pos, flags): TermSymbol) + locally(sym.newTypeSymbol(tyname, pos, flags): TypeSymbol) + locally(polyType(tparams, tpe): Type) + locally(sym.pos: Position) + locally(refinedType(tpes, sym): Type) + locally(refinedType(tpes, sym, decls, pos): Type) + locally(singleType(tpe, sym): Type) + locally(tree.substituteSymbols(syms, syms): Tree) + locally(tree.substituteThis(sym, tree): Tree) + locally(tree.substituteTypes(syms, tpes): Tree) + locally(typeRef(tpe, sym, tpes): Type) + locally(typeTagToManifest(mirror, tag): Manifest[Int]) + locally(FreeTermSymbolTag: ClassTag[FreeTermSymbol]) + locally((??? : FreeTermSymbol).origin) + locally((??? : FreeTermSymbol).value) + locally(FreeTypeSymbolTag: ClassTag[FreeTypeSymbol]) + locally((??? : FreeTypeSymbol).origin) + locally(ReferenceToBoxedTag: ClassTag[ReferenceToBoxed]) + locally(build: BuildApi) + locally(ReferenceToBoxed(??? : Ident): ReferenceToBoxed) + locally((??? : ReferenceToBoxed).ident: Tree) + locally(ReferenceToBoxed.unapply(???): Option[Ident]) + locally(build.selectType(sym, str): TypeSymbol) + locally(build.selectTerm(sym, str): TermSymbol) + locally(build.selectOverloadedMethod(sym, str, i): MethodSymbol) + locally(build.newNestedSymbol(sym, name, pos, flags, b): Symbol) + locally(build.newFreeTerm(str, i): FreeTermSymbol) + locally(build.newFreeTerm(str, i, flags, str): FreeTermSymbol) + locally(build.newFreeType(str): FreeTypeSymbol) + locally(build.newFreeType(str, flags, str): FreeTypeSymbol) + locally(build.setTypeSignature(sym, tpe): Symbol) + locally(build.setAnnotations(sym, anns): Symbol) + locally(build.flagsFromBits(??? : Long): FlagSet) + locally(build.emptyValDef: ValDef) + locally(build.This(sym): Tree) + locally(build.Select(tree, sym): Select) + locally(build.Ident(sym): Ident) + locally(build.TypeTree(tpe): TypeTree) + locally(build.thisPrefix(sym): Type) + locally(build.setType(tree, tpe): Tree) + locally(build.setSymbol(tree, sym): Tree) + } +} diff --git a/tests/pending/pos/reflection-compat-macro-universe.check b/tests/pending/pos/reflection-compat-macro-universe.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/reflection-compat-macro-universe.check diff --git a/tests/pending/pos/reflection-compat-macro-universe.scala b/tests/pending/pos/reflection-compat-macro-universe.scala new file mode 100644 index 000000000..028d8b129 --- /dev/null +++ b/tests/pending/pos/reflection-compat-macro-universe.scala @@ -0,0 +1,177 @@ +object Test extends App { + val u: scala.reflect.macros.Universe = ??? + import u._ + import scala.reflect.macros.Attachments + import scala.reflect.ClassTag + import compat._ + + val tree: Tree = ??? + val ttree: TypeTree = ??? + val stree: SymTree = ??? + val trees: List[Tree] = ??? + val mods: Modifiers = ??? + val impl: Template = ??? + val vparamss: List[List[ValDef]] = ??? + val rhs: Tree = ??? + val sym: Symbol = ??? + val tsym: TypeSymbol = ??? + val syms: List[Symbol] = ??? + val params: List[Symbol] = ??? + val tparams: List[Symbol] = ??? + val tpe: Type = ??? + val tpes: List[Type] = ??? + val manifest: Manifest[Int] = ??? + val tag: TypeTag[Int] = ??? + val mirror: Mirror = ??? + val decls: Scope = ??? + val pos: Position = ??? + val ann: Annotation = ??? + val anns: List[Annotation] = ??? + val const: Constant = ??? + val name: Name = ??? + val tyname: TypeName = ??? + val tename: TermName = ??? + val flags: FlagSet = ??? + val str: String = ??? + val i: Int = ??? + val b: Boolean = ??? + + // abstract class BuildApi + // abstract class ReferenceToBoxedExtractor + // abstract trait AttachableApi + // abstract trait FreeTermSymbolApi + // abstract trait FreeTypeSymbolApi + // abstract trait IdentContextApi + // abstract trait ReferenceToBoxedApi + // abstract trait SymTreeContextApi + // abstract trait SymbolContextApi + // abstract trait TreeContextApi + // abstract trait TypeTreeContextApi + locally(ClassDef(sym, impl): ClassDef) + locally(DefDef(sym, mods, vparamss, rhs): DefDef) + locally(DefDef(sym, vparamss, rhs): DefDef) + locally(DefDef(sym, mods, rhs): DefDef) + locally(DefDef(sym, rhs): DefDef) + locally(DefDef(sym, (??? : List[List[Symbol]] => Tree)): DefDef) + locally(LabelDef(sym, params, rhs): LabelDef) + locally(ModuleDef(sym, impl): ModuleDef) + locally(TypeDef(sym, rhs): TypeDef) + locally(TypeDef(sym): TypeDef) + locally(ValDef(sym, rhs): ValDef) + locally(ValDef(sym): ValDef) + locally(AnnotatedType(anns, tpe): AnnotatedType) + locally(BoundedWildcardType(??? : TypeBounds): BoundedWildcardType) + locally(TypeBounds(tpe, tpe): TypeBounds) + locally(MethodType(params, tpe): MethodType) + locally(RefinedType(tpes, decls): RefinedType) + locally(RefinedType(tpes, decls, sym): RefinedType) + locally(ClassInfoType(tpes, decls, sym): ClassInfoType) + locally(SingleType(tpe, sym): Type) + locally(TypeRef(tpe, sym, tpes): Type) + locally(ExistentialType(syms, tpe): ExistentialType) + locally(NullaryMethodType(tpe): NullaryMethodType) + locally(ThisType(sym): Type) + locally(SuperType(tpe, tpe): Type) + locally(PolyType(syms, tpe): PolyType) + locally(ConstantType(const): ConstantType) + locally(sym.asFreeTerm: FreeTermSymbol) + locally(sym.asFreeType: FreeTypeSymbol) + locally(sym.attachments: Attachments { type Pos = Position }) + locally(tree.attachments: Attachments { type Pos = Position }) + locally(captureVariable(sym): Unit) + locally(capturedVariableType(sym): Type) + locally(sym.deSkolemize: Symbol) + locally(tree.defineType(tpe): Tree) + locally(existentialAbstraction(tparams, tpe): Type) + locally(tree.freeTerms: List[FreeTermSymbol]) + locally(tree.freeTypes: List[FreeTypeSymbol]) + locally(intersectionType(tpes): Type) + locally(intersectionType(tpes, sym): Type) + locally(sym.isErroneous: Boolean) + locally(sym.isFreeTerm: Boolean) + locally(sym.isFreeType: Boolean) + locally(sym.isLocal: Boolean) + locally(sym.isOverride: Boolean) + locally(tsym.isSkolem: Boolean) + locally(manifestToTypeTag(mirror, manifest): scala.reflect.api.Universe#TypeTag[Int]) + locally(treeBuild.mkAttributedIdent(sym): RefTree) + locally(treeBuild.mkAttributedQualifier(tpe): Tree) + locally(treeBuild.mkAttributedQualifier(tpe, sym): Tree) + locally(treeBuild.mkAttributedRef(tpe, sym): RefTree) + locally(treeBuild.mkAttributedRef(sym): RefTree) + locally(treeBuild.mkAttributedSelect(tree, sym): RefTree) + locally(treeBuild.mkAttributedThis(sym): This) + locally(mkImporter(scala.reflect.runtime.universe): Importer{val from: scala.reflect.runtime.universe.type}) + locally(treeBuild.mkMethodCall(sym, trees): Tree) + locally(treeBuild.mkMethodCall(sym, tpes, trees): Tree) + locally(treeBuild.mkMethodCall(sym, name, trees): Tree) + locally(treeBuild.mkMethodCall(sym, name, tpes, trees): Tree) + locally(treeBuild.mkMethodCall(tree, sym, tpes, trees): Tree) + locally(treeBuild.mkMethodCall(tree, trees): Tree) + locally(treeBuild.mkMethodCall(tree, tpes, trees): Tree) + locally(treeBuild.mkNullaryCall(sym, tpes): Tree) + locally(treeBuild.mkRuntimeUniverseRef: Tree) + locally(treeBuild.mkUnattributedRef(name): RefTree) + locally(treeBuild.mkUnattributedRef(sym): RefTree) + locally(sym.newClassSymbol(tyname, pos, flags): ClassSymbol) + locally(sym.newMethodSymbol(tename, pos, flags): MethodSymbol) + locally(sym.newModuleAndClassSymbol(name, pos, flags): (ModuleSymbol, ClassSymbol)) + locally(newScopeWith(sym, sym, sym): Scope) + locally(sym.newTermSymbol(tename, pos, flags): TermSymbol) + locally(sym.newTypeSymbol(tyname, pos, flags): TypeSymbol) + locally(polyType(tparams, tpe): Type) + locally(sym.pos: Position) + locally((tree.pos = pos): Unit) + locally(referenceCapturedVariable(sym): Tree) + locally(refinedType(tpes, sym): Type) + locally(refinedType(tpes, sym, decls, pos): Type) + locally(sym.removeAttachment[Int]: Symbol) + locally(tree.removeAttachment[Int]: Tree) + locally(sym.setAnnotations(ann, ann, ann): Symbol) + locally(sym.setName(name): Symbol) + locally(ttree.setOriginal(tree): TypeTree) + locally(tree.setPos(pos): Tree) + locally(sym.setPrivateWithin(sym): Symbol) + locally(tree.setSymbol(sym): Tree) + locally(tree.setType(tpe): Tree) + locally(sym.setTypeSignature(tpe): Symbol) + locally(singleType(tpe, sym): Type) + locally(tree.substituteSymbols(syms, syms): Tree) + locally(tree.substituteThis(sym, tree): Tree) + locally(tree.substituteTypes(syms, tpes): Tree) + locally((tree.symbol = sym): Unit) + locally((tree.tpe = tpe): Unit) + locally(typeRef(tpe, sym, tpes): Type) + locally(typeTagToManifest(mirror, tag): Manifest[Int]) + locally(sym.updateAttachment(42): Symbol) + locally(tree.updateAttachment(42): Tree) + locally(FreeTermSymbolTag: ClassTag[FreeTermSymbol]) + locally((??? : FreeTermSymbol).origin) + locally((??? : FreeTermSymbol).value) + locally(FreeTypeSymbolTag: ClassTag[FreeTypeSymbol]) + locally((??? : FreeTypeSymbol).origin) + locally(ReferenceToBoxedTag: ClassTag[ReferenceToBoxed]) + locally(build: BuildApi) + locally(ReferenceToBoxed(??? : Ident): ReferenceToBoxed) + locally((??? : ReferenceToBoxed).ident: Tree) + locally(ReferenceToBoxed.unapply(???): Option[Ident]) + locally(build.selectType(sym, str): TypeSymbol) + locally(build.selectTerm(sym, str): TermSymbol) + locally(build.selectOverloadedMethod(sym, str, i): MethodSymbol) + locally(build.newNestedSymbol(sym, name, pos, flags, b): Symbol) + locally(build.newFreeTerm(str, i): FreeTermSymbol) + locally(build.newFreeTerm(str, i, flags, str): FreeTermSymbol) + locally(build.newFreeType(str): FreeTypeSymbol) + locally(build.newFreeType(str, flags, str): FreeTypeSymbol) + locally(build.setTypeSignature(sym, tpe): Symbol) + locally(build.setAnnotations(sym, anns): Symbol) + locally(build.flagsFromBits(??? : Long): FlagSet) + locally(build.emptyValDef: ValDef) + locally(build.This(sym): Tree) + locally(build.Select(tree, sym): Select) + locally(build.Ident(sym): Ident) + locally(build.TypeTree(tpe): TypeTree) + locally(build.thisPrefix(sym): Type) + locally(build.setType(tree, tpe): Tree) + locally(build.setSymbol(tree, sym): Tree) +} diff --git a/tests/pending/pos/reflection-compat-ru.check b/tests/pending/pos/reflection-compat-ru.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/reflection-compat-ru.check diff --git a/tests/pending/pos/reflection-compat-ru.scala b/tests/pending/pos/reflection-compat-ru.scala new file mode 100644 index 000000000..f3f493fba --- /dev/null +++ b/tests/pending/pos/reflection-compat-ru.scala @@ -0,0 +1,135 @@ +object Test extends App { + import scala.reflect.runtime.universe._ + import scala.reflect.ClassTag + import compat._ + + val tree: Tree = ??? + val ttree: TypeTree = ??? + val stree: SymTree = ??? + val trees: List[Tree] = ??? + val mods: Modifiers = ??? + val impl: Template = ??? + val vparamss: List[List[ValDef]] = ??? + val rhs: Tree = ??? + val sym: Symbol = ??? + val tsym: TypeSymbol = ??? + val syms: List[Symbol] = ??? + val params: List[Symbol] = ??? + val tparams: List[Symbol] = ??? + val tpe: Type = ??? + val tpes: List[Type] = ??? + val manifest: Manifest[Int] = ??? + val tag: TypeTag[Int] = ??? + val mirror: Mirror = ??? + val decls: Scope = ??? + val pos: Position = ??? + val ann: Annotation = ??? + val anns: List[Annotation] = ??? + val const: Constant = ??? + val name: Name = ??? + val tyname: TypeName = ??? + val tename: TermName = ??? + val flags: FlagSet = ??? + val str: String = ??? + val i: Int = ??? + val b: Boolean = ??? + + // abstract class BuildApi + // abstract class ReferenceToBoxedExtractor + // abstract trait AttachableApi + // abstract trait FreeTermSymbolApi + // abstract trait FreeTypeSymbolApi + // abstract trait IdentContextApi + // abstract trait ReferenceToBoxedApi + // abstract trait SymTreeContextApi + // abstract trait SymbolContextApi + // abstract trait TreeContextApi + // abstract trait TypeTreeContextApi + locally(ClassDef(sym, impl): ClassDef) + locally(DefDef(sym, mods, vparamss, rhs): DefDef) + locally(DefDef(sym, vparamss, rhs): DefDef) + locally(DefDef(sym, mods, rhs): DefDef) + locally(DefDef(sym, rhs): DefDef) + locally(DefDef(sym, (??? : List[List[Symbol]] => Tree)): DefDef) + locally(LabelDef(sym, params, rhs): LabelDef) + locally(ModuleDef(sym, impl): ModuleDef) + locally(TypeDef(sym, rhs): TypeDef) + locally(TypeDef(sym): TypeDef) + locally(ValDef(sym, rhs): ValDef) + locally(ValDef(sym): ValDef) + locally(AnnotatedType(anns, tpe): AnnotatedType) + locally(BoundedWildcardType(??? : TypeBounds): BoundedWildcardType) + locally(TypeBounds(tpe, tpe): TypeBounds) + locally(MethodType(params, tpe): MethodType) + locally(RefinedType(tpes, decls): RefinedType) + locally(RefinedType(tpes, decls, sym): RefinedType) + locally(ClassInfoType(tpes, decls, sym): ClassInfoType) + locally(SingleType(tpe, sym): Type) + locally(TypeRef(tpe, sym, tpes): Type) + locally(ExistentialType(syms, tpe): ExistentialType) + locally(NullaryMethodType(tpe): NullaryMethodType) + locally(ThisType(sym): Type) + locally(SuperType(tpe, tpe): Type) + locally(PolyType(syms, tpe): PolyType) + locally(ConstantType(const): ConstantType) + locally(sym.asFreeTerm: FreeTermSymbol) + locally(sym.asFreeType: FreeTypeSymbol) + locally(existentialAbstraction(tparams, tpe): Type) + locally(tree.freeTerms: List[FreeTermSymbol]) + locally(tree.freeTypes: List[FreeTypeSymbol]) + locally(intersectionType(tpes): Type) + locally(intersectionType(tpes, sym): Type) + locally(sym.isErroneous: Boolean) + locally(sym.isFreeTerm: Boolean) + locally(sym.isFreeType: Boolean) + locally(sym.isLocal: Boolean) + locally(sym.isOverride: Boolean) + locally(tsym.isSkolem: Boolean) + locally(manifestToTypeTag(mirror, manifest): scala.reflect.api.Universe#TypeTag[Int]) + locally(mkImporter(scala.reflect.runtime.universe): Importer{val from: scala.reflect.runtime.universe.type}) + locally(sym.newClassSymbol(tyname, pos, flags): ClassSymbol) + locally(sym.newMethodSymbol(tename, pos, flags): MethodSymbol) + locally(sym.newModuleAndClassSymbol(name, pos, flags): (ModuleSymbol, ClassSymbol)) + locally(newScopeWith(sym, sym, sym): Scope) + locally(sym.newTermSymbol(tename, pos, flags): TermSymbol) + locally(sym.newTypeSymbol(tyname, pos, flags): TypeSymbol) + locally(polyType(tparams, tpe): Type) + locally(sym.pos: Position) + locally(refinedType(tpes, sym): Type) + locally(refinedType(tpes, sym, decls, pos): Type) + locally(singleType(tpe, sym): Type) + locally(tree.substituteSymbols(syms, syms): Tree) + locally(tree.substituteThis(sym, tree): Tree) + locally(tree.substituteTypes(syms, tpes): Tree) + locally(typeRef(tpe, sym, tpes): Type) + locally(typeTagToManifest(mirror, tag): Manifest[Int]) + locally(FreeTermSymbolTag: ClassTag[FreeTermSymbol]) + locally((??? : FreeTermSymbol).origin) + locally((??? : FreeTermSymbol).value) + locally(FreeTypeSymbolTag: ClassTag[FreeTypeSymbol]) + locally((??? : FreeTypeSymbol).origin) + locally(ReferenceToBoxedTag: ClassTag[ReferenceToBoxed]) + locally(build: BuildApi) + locally(ReferenceToBoxed(??? : Ident): ReferenceToBoxed) + locally((??? : ReferenceToBoxed).ident: Tree) + locally(ReferenceToBoxed.unapply(???): Option[Ident]) + locally(build.selectType(sym, str): TypeSymbol) + locally(build.selectTerm(sym, str): TermSymbol) + locally(build.selectOverloadedMethod(sym, str, i): MethodSymbol) + locally(build.newNestedSymbol(sym, name, pos, flags, b): Symbol) + locally(build.newFreeTerm(str, i): FreeTermSymbol) + locally(build.newFreeTerm(str, i, flags, str): FreeTermSymbol) + locally(build.newFreeType(str): FreeTypeSymbol) + locally(build.newFreeType(str, flags, str): FreeTypeSymbol) + locally(build.setTypeSignature(sym, tpe): Symbol) + locally(build.setAnnotations(sym, anns): Symbol) + locally(build.flagsFromBits(??? : Long): FlagSet) + locally(build.emptyValDef: ValDef) + locally(build.This(sym): Tree) + locally(build.Select(tree, sym): Select) + locally(build.Ident(sym): Ident) + locally(build.TypeTree(tpe): TypeTree) + locally(build.thisPrefix(sym): Type) + locally(build.setType(tree, tpe): Tree) + locally(build.setSymbol(tree, sym): Tree) +} diff --git a/tests/pending/pos/return_thistype.scala b/tests/pending/pos/return_thistype.scala new file mode 100644 index 000000000..c0736c0ad --- /dev/null +++ b/tests/pending/pos/return_thistype.scala @@ -0,0 +1,8 @@ +// tests transformation of return type in typedTypeApply (see also tcpoly_gm.scala) +class As { + class A { + def foo: A.this.type = bar.asInstanceOf[A.this.type] + def foo2: this.type = bar.asInstanceOf[this.type] + def bar: A = null + } +} diff --git a/tests/pending/pos/sammy_poly.flags b/tests/pending/pos/sammy_poly.flags new file mode 100644 index 000000000..48fd86716 --- /dev/null +++ b/tests/pending/pos/sammy_poly.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/tests/pending/pos/sammy_poly.scala b/tests/pending/pos/sammy_poly.scala new file mode 100644 index 000000000..f43fa292c --- /dev/null +++ b/tests/pending/pos/sammy_poly.scala @@ -0,0 +1,7 @@ +// test synthesizeSAMFunction where the sam type is not fully defined +class T { + trait F[T, U] { def apply(x: T): U } + // NOTE: the f(x) desugaring for now assumes the single abstract method is called 'apply' + def app[T, U](x: T)(f: F[T, U]): U = f(x) + app(1)(x => List(x)) +} diff --git a/tests/pending/pos/scoping1.scala b/tests/pending/pos/scoping1.scala new file mode 100644 index 000000000..9fe1b5f3e --- /dev/null +++ b/tests/pending/pos/scoping1.scala @@ -0,0 +1,12 @@ +object This extends App { + trait A { + def foo(): Unit + } + class C { self: A => + def bar() = this.foo() + } + class D extends C with A { + def foo() = () + } + val c: C = new D +} diff --git a/tests/pending/pos/sealed-final.flags b/tests/pending/pos/sealed-final.flags new file mode 100644 index 000000000..cfabf7a5b --- /dev/null +++ b/tests/pending/pos/sealed-final.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Yinline-warnings -optimise
\ No newline at end of file diff --git a/tests/pending/pos/sealed-final.scala b/tests/pending/pos/sealed-final.scala new file mode 100644 index 000000000..bdedb5c1f --- /dev/null +++ b/tests/pending/pos/sealed-final.scala @@ -0,0 +1,14 @@ +sealed abstract class Foo { + @inline def bar(x: Int) = x + 1 +} +object Foo { + def mkFoo(): Foo = new Baz2 +} + +object Baz1 extends Foo +final class Baz2 extends Foo + +object Test { + // bar should be inlined now + def f = Foo.mkFoo() bar 10 +} diff --git a/tests/pending/pos/self-type-override.scala b/tests/pending/pos/self-type-override.scala new file mode 100644 index 000000000..7c40ef37e --- /dev/null +++ b/tests/pending/pos/self-type-override.scala @@ -0,0 +1,13 @@ +trait TCommon { + def f: String +} + +class C1 extends TCommon { + def f = "in C1" +} + +trait TOverrider { this: TCommon => + override def f = "in TOverrider" // The overridden self-type member... +} + +class C2 extends C1 with TOverrider // ... fails to override, here. diff --git a/tests/pending/pos/selftails.scala b/tests/pending/pos/selftails.scala new file mode 100644 index 000000000..a4253b80c --- /dev/null +++ b/tests/pending/pos/selftails.scala @@ -0,0 +1,23 @@ +package net.liftweb.util + +/** +* This trait adds functionality to Scala standard types +*/ +trait BasicTypesHelpers { self: StringHelpers with ControlHelpers => + + /** + * Compare two arrays of Byte for byte equality. + * @return true if two Byte arrays contain the same bytes + */ + def isEq(a: Array[Byte], b: Array[Byte]) = { + def eq(a: Array[Byte], b: Array[Byte], pos: Int, len: Int): Boolean = { + if (pos == len) true + else if (a(pos) != b(pos)) false + else eq(a , b, pos + 1, len) + } + a.length == b.length && eq(a, b, 0, a.length) + } +} + +trait StringHelpers +trait ControlHelpers diff --git a/tests/pending/pos/seq-ordering.scala b/tests/pending/pos/seq-ordering.scala new file mode 100644 index 000000000..517d8ae8a --- /dev/null +++ b/tests/pending/pos/seq-ordering.scala @@ -0,0 +1,9 @@ +import Ordering.Implicits._ + +class A { + import Predef.{ implicitly => ? } + + ?[Ordering[List[Int]]] + ?[Ordering[IndexedSeq[(Int, String)]]] + ?[Ordering[Seq[Seq[Int]]]] +} diff --git a/tests/pending/pos/seqtest2.scala b/tests/pending/pos/seqtest2.scala new file mode 100644 index 000000000..239b1b581 --- /dev/null +++ b/tests/pending/pos/seqtest2.scala @@ -0,0 +1,13 @@ +object test { + + val b = List(1, 2, 3); + + def main(args: Array[String]) = + Console.println( + b match { + case List(1, 2, 3) => true; + case _ => false; + } + ) + +} diff --git a/tests/pending/pos/setter-not-implicit.flags b/tests/pending/pos/setter-not-implicit.flags new file mode 100644 index 000000000..792c40565 --- /dev/null +++ b/tests/pending/pos/setter-not-implicit.flags @@ -0,0 +1 @@ +-feature -Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/setter-not-implicit.scala b/tests/pending/pos/setter-not-implicit.scala new file mode 100644 index 000000000..9bfffc2ce --- /dev/null +++ b/tests/pending/pos/setter-not-implicit.scala @@ -0,0 +1,3 @@ +object O { + implicit var x: Int = 0 +} diff --git a/tests/pending/pos/spec-annotations.scala b/tests/pending/pos/spec-annotations.scala new file mode 100644 index 000000000..b23abf48e --- /dev/null +++ b/tests/pending/pos/spec-annotations.scala @@ -0,0 +1,35 @@ +class ann(i: Int) extends scala.annotation.Annotation + +// annotations on abstract types +abstract class C1[@annotation.elidable(0) +T, U, V[_]] +abstract class C2[@deprecated + @ann(1) T <: Number, + V] +abstract class C3 { + @ann(2) type X <: Number +} + +object Test { + + // bug #1028 + val x = 1 + @ann(x) val a = () + @ann({val y = 2; y}) val b = () + + def c: Int @ann(x) = 1 + def d: String @ann({val z = 0; z - 1}) = "2" + def e[@deprecated T, U](x: T) = x + + //bug #1214 + val y = new (Integer @ann(0))(2) + + import scala.beans.BeanProperty + + // bug #637 + trait S { def getField(): Int } + class O extends S { @BeanProperty val field = 0 } + + // bug #1070 + trait T { @BeanProperty var field = 1 } +} + diff --git a/tests/pending/pos/spec-asseenfrom.scala b/tests/pending/pos/spec-asseenfrom.scala new file mode 100644 index 000000000..ede579170 --- /dev/null +++ b/tests/pending/pos/spec-asseenfrom.scala @@ -0,0 +1,29 @@ +class Automaton[@specialized(Double) W,State] { + + def finalWeight(s: State): W = sys.error("todo"); + + def allStates: Set[State] = sys.error("toodo"); + + /** + * Returns a map from states to its final weight. may expand all nodes. + */ + def finalStateWeights = Map.empty ++ allStates.map { s => (s,finalWeight(s)) } + + // This works fine: + /* + def finalStateWeights() = { + val it = allStates.iterator; + while(it.hasNext) { + finalWeight(it.next); + } + } + */ + +} + +abstract class Automaton2[@specialized T1, T2] { + def finalWeight(s: T2): T1 + def allStates: Set[T2] + + def f = allStates map finalWeight +} diff --git a/tests/pending/pos/spec-constr-new.scala b/tests/pending/pos/spec-constr-new.scala new file mode 100644 index 000000000..c6acc862a --- /dev/null +++ b/tests/pending/pos/spec-constr-new.scala @@ -0,0 +1,9 @@ +import scala.reflect.{ClassTag, classTag} + +class SparseArray2[@specialized(Int) T:ClassTag](val maxSize: Int, initialLength:Int = 3) { + private var data = new Array[T](initialLength); + private var index = new Array[Int](initialLength); + + // comment out to compile correctly + data.length + 3; +} diff --git a/tests/pending/pos/spec-doubledef-new.scala b/tests/pending/pos/spec-doubledef-new.scala new file mode 100644 index 000000000..de438d6e9 --- /dev/null +++ b/tests/pending/pos/spec-doubledef-new.scala @@ -0,0 +1,30 @@ +import scala.reflect.runtime.universe._ + +object Test { + def fn[@specialized T, @specialized U](t : T => Int, u : U => Int) : T = + null.asInstanceOf[T] +} + +trait A[@specialized(Int) T] { + var value: T + def getWith[@specialized(Int) Z](f: T => Z) = f(value) +} + +class C extends A[Int] { + var value = 10 + override def getWith[@specialized(Int) Z](f: Int => Z) = f(value) +} + +abstract class B[T, @specialized(scala.Int) U : TypeTag, @specialized(scala.Int) V <% Ordered[V]] { + val u: U + val v: V + + def f(t: T, v2: V): Tuple2[U, V] = { + val m: Array[U] = null + if (m.isEmpty) { + (u, v) + } else { + (u, v2) + } + } +} diff --git a/tests/pending/pos/spec-doubledef-old.scala b/tests/pending/pos/spec-doubledef-old.scala new file mode 100644 index 000000000..bde259e4f --- /dev/null +++ b/tests/pending/pos/spec-doubledef-old.scala @@ -0,0 +1,28 @@ +object Test { + def fn[@specialized T, @specialized U](t : T => Int, u : U => Int) : T = + null.asInstanceOf[T] +} + +trait A[@specialized(Int) T] { + var value: T + def getWith[@specialized(Int) Z](f: T => Z) = f(value) +} + +class C extends A[Int] { + var value = 10 + override def getWith[@specialized(Int) Z](f: Int => Z) = f(value) +} + +abstract class B[T, @specialized(scala.Int) U : Manifest, @specialized(scala.Int) V <% Ordered[V]] { + val u: U + val v: V + + def f(t: T, v2: V): Tuple2[U, V] = { + val m: Array[U] = null + if (m.isEmpty) { + (u, v) + } else { + (u, v2) + } + } +} diff --git a/tests/pending/pos/spec-foo.scala b/tests/pending/pos/spec-foo.scala new file mode 100644 index 000000000..aabe0d51e --- /dev/null +++ b/tests/pending/pos/spec-foo.scala @@ -0,0 +1,4 @@ +class Foo { + val xs = List(1, 2) + 1 :: xs +} diff --git a/tests/pending/pos/spec-groups.scala b/tests/pending/pos/spec-groups.scala new file mode 100644 index 000000000..9b6359a98 --- /dev/null +++ b/tests/pending/pos/spec-groups.scala @@ -0,0 +1,65 @@ +import Specializable._ + +class A[@specialized(Primitives) T](x: T) { + def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y)) + def f2[@specialized(Everything) U](x: T, y: U) = ((x, y)) + def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y)) + def f4[@specialized(Integral) U](x: T, y: U) = ((x, y)) + def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y)) + def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y)) + def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y)) +} +class B[@specialized(Everything) T] { + def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y)) + def f2[@specialized(Everything) U](x: T, y: U) = ((x, y)) + def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y)) + def f4[@specialized(Integral) U](x: T, y: U) = ((x, y)) + def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y)) + def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y)) + def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y)) +} +class C[@specialized(Bits32AndUp) T] { + def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y)) + def f2[@specialized(Everything) U](x: T, y: U) = ((x, y)) + def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y)) + def f4[@specialized(Integral) U](x: T, y: U) = ((x, y)) + def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y)) + def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y)) + def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y)) +} +class D[@specialized(Integral) T] { + def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y)) + def f2[@specialized(Everything) U](x: T, y: U) = ((x, y)) + def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y)) + def f4[@specialized(Integral) U](x: T, y: U) = ((x, y)) + def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y)) + def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y)) + def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y)) +} +class E[@specialized(AllNumeric) T] { + def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y)) + def f2[@specialized(Everything) U](x: T, y: U) = ((x, y)) + def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y)) + def f4[@specialized(Integral) U](x: T, y: U) = ((x, y)) + def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y)) + def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y)) + def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y)) +} +class F[@specialized(BestOfBreed) T] { + def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y)) + def f2[@specialized(Everything) U](x: T, y: U) = ((x, y)) + def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y)) + def f4[@specialized(Integral) U](x: T, y: U) = ((x, y)) + def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y)) + def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y)) + def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y)) +} +class G[@specialized(Byte, Double, AnyRef) T] { + def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y)) + def f2[@specialized(Everything) U](x: T, y: U) = ((x, y)) + def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y)) + def f4[@specialized(Integral) U](x: T, y: U) = ((x, y)) + def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y)) + def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y)) + def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y)) +} diff --git a/tests/pending/pos/spec-partialmap.scala b/tests/pending/pos/spec-partialmap.scala new file mode 100644 index 000000000..09684e024 --- /dev/null +++ b/tests/pending/pos/spec-partialmap.scala @@ -0,0 +1,17 @@ + +// ticket #3378, overloaded specialized variants +import scala.collection.{Traversable,TraversableLike}; +import scala.collection.generic.CanBuildFrom; + +trait PartialMap[@specialized A,@specialized B] +extends PartialFunction[A,B] with Iterable[(A,B)] { + + // commenting out this declaration gives a different exception. + /** Getter for all values for which the given key function returns true. */ + def apply(f : (A => Boolean)) : Iterator[B] = + for ((k,v) <- iterator; if f(k)) yield v; + + // if this is commented, it compiles fine: + def apply[This <: Traversable[A], That](keys : TraversableLike[A,This]) + (implicit bf: CanBuildFrom[This, B, That]) : That = keys.map(apply); +} diff --git a/tests/pending/pos/spec-sealed.scala b/tests/pending/pos/spec-sealed.scala new file mode 100644 index 000000000..d7ecfaaab --- /dev/null +++ b/tests/pending/pos/spec-sealed.scala @@ -0,0 +1,32 @@ +sealed abstract class MyList[@specialized +A] { + def head: A + def tail: MyList[A] + + def ::[@specialized B >: A](x: B): MyList[B] = + new Cons[B](x, this) +} + +case object MyNil extends MyList[Nothing] { + def head = sys.error("nil") + def tail = sys.error("nil") +} + +case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList[a] { + def head = hd + def tail = tl +} + +abstract class IntList extends MyList[Int] + +object Main extends App { + val xs = 1 :: 2 :: 3 :: MyNil + println(xs) +} + +/* +final class ConsI(hd1: Int, tl1: MyList[Int]) extends Cons[Int](hd1, tl1) { + override val hd = hd1 + override val tl = tl1 +} +*/ +//class IntCons(_hd: Int, _tl: MyList[Int]) extends Cons[Int](_hd, _tl) diff --git a/tests/pending/pos/spec-traits.scala b/tests/pending/pos/spec-traits.scala new file mode 100644 index 000000000..c8c8000d8 --- /dev/null +++ b/tests/pending/pos/spec-traits.scala @@ -0,0 +1,64 @@ +trait A[@specialized(Int) T] { def foo: T } +class B extends A[Int] { val foo = 10 } +class C extends B + +// issue 3309 +class Lazy { + def test[U](block: => U): Unit = { block } + + test { lazy val x = 1 } +} + +// issue 3307 +class Bug3307 { + def f[Z](block: String => Z): Unit = { + block("abc") + } + + ({ () => + f { implicit x => println(x) } })() +} + +// issue 3301 + trait T[X] + +class Bug3301 { + def t[A]: T[A] = sys.error("stub") + + () => { + type X = Int + + def foo[X] = t[X] + () + } +} +// issue 3299 +object Failure { + def thunk(): Unit = { + for (i <- 1 to 2) { + val Array(a, b) = Array(1,2) + () + } + } +} + +// issue 3296 + +object AA +{ + def f(block: => Unit): Unit = {} + + object BB + { + f { + object CC + + () + } + } + + def foo[T](x: T) = { object A; false } +} + +// issue 3325 +object O { def f[@specialized T]: Unit = { for(k <- Nil: List[T]) { } } } diff --git a/tests/pending/pos/specializes-sym-crash.scala b/tests/pending/pos/specializes-sym-crash.scala new file mode 100644 index 000000000..7778ba277 --- /dev/null +++ b/tests/pending/pos/specializes-sym-crash.scala @@ -0,0 +1,26 @@ +import scala.collection._ + +trait Foo[+A, + +Coll, + +This <: SeqView[A, Coll] with SeqViewLike[A, Coll, This]] +extends Seq[A] with SeqLike[A, This] with IterableView[A, Coll] with IterableViewLike[A, Coll, This] { +self => + + trait Transformed[+B] extends SeqView[B, Coll] with super.Transformed[B] { + def length: Int + def apply(idx: Int): B + override def toString = viewToString + } + trait Reversed extends Transformed[A] { + override def iterator: Iterator[A] = createReversedIterator + def length: Int = self.length + def apply(idx: Int): A = self.apply(length - 1 - idx) + final override protected[this] def viewIdentifier = "R" + + private def createReversedIterator = { + var lst = List[A]() + for (elem <- self) lst ::= elem + lst.iterator + } + } +} diff --git a/tests/pending/pos/stable.scala b/tests/pending/pos/stable.scala new file mode 100644 index 000000000..267a36fe5 --- /dev/null +++ b/tests/pending/pos/stable.scala @@ -0,0 +1,11 @@ +trait Base { + val x: Int; + val y: Int; + var z: Int; +} + +class Sub() extends Base { + val x: Int = 1; + val y: Int = 2; + var z: Int = 3; +} diff --git a/tests/pending/pos/strip-tvars-for-lubbasetypes.scala b/tests/pending/pos/strip-tvars-for-lubbasetypes.scala new file mode 100644 index 000000000..2be8625ba --- /dev/null +++ b/tests/pending/pos/strip-tvars-for-lubbasetypes.scala @@ -0,0 +1,25 @@ +object Test { + + implicit final class EqualOps[T](val x: T) extends AnyVal { + def ===[T1, Ph >: T <: T1, Ph2 >: Ph <: T1](other: T1): Boolean = x == other + def !!![T1, Ph2 >: Ph <: T1, Ph >: T <: T1](other: T1): Boolean = x == other + } + + class A + class B extends A + class C extends A + + val a = new A + val b = new B + val c = new C + + val x1 = a === b + val x2 = b === a + val x3 = b === c // error, infers Object{} for T1 + val x4 = b.===[A, B, B](c) + + val x5 = b !!! c // always compiled due to the order of Ph2 and Ph + + + +} diff --git a/tests/pending/pos/super/Super_1.java b/tests/pending/pos/super/Super_1.java new file mode 100644 index 000000000..9acbba0ec --- /dev/null +++ b/tests/pending/pos/super/Super_1.java @@ -0,0 +1,6 @@ +// A.java +interface Inter<T> { } + +class Super implements Inter<Super.Inner> { + public class Inner { }; +} diff --git a/tests/pending/pos/super/Super_2.scala b/tests/pending/pos/super/Super_2.scala new file mode 100644 index 000000000..486d6b700 --- /dev/null +++ b/tests/pending/pos/super/Super_2.scala @@ -0,0 +1,6 @@ +object Test { + val x: Super = null + + def main(args: Array[String]): Unit = { + } +} diff --git a/tests/pending/pos/t2613.scala b/tests/pending/pos/t2613.scala new file mode 100644 index 000000000..3a64dbc28 --- /dev/null +++ b/tests/pending/pos/t2613.scala @@ -0,0 +1,11 @@ +import language.existentials + +object Test { + class Row + + abstract class MyRelation [R <: Row, +Relation <: MyRelation[R, Relation]] + + type M = MyRelation[R, Relation] forSome {type R <: Row; type Relation <: MyRelation[R, Relation]} + + var (x,y): (String, M) = null +} diff --git a/tests/pending/pos/t2624.scala b/tests/pending/pos/t2624.scala new file mode 100644 index 000000000..76f0e3036 --- /dev/null +++ b/tests/pending/pos/t2624.scala @@ -0,0 +1,4 @@ +object Test { + List(1).map(identity(_)) + List(1).map(identity) // this didn't typecheck before the fix +} diff --git a/tests/pending/pos/t2660.scala b/tests/pending/pos/t2660.scala new file mode 100644 index 000000000..d42dcc72b --- /dev/null +++ b/tests/pending/pos/t2660.scala @@ -0,0 +1,25 @@ +package hoho + +class G + +class H extends G + +class A[T](x: T) { + + def this(y: G, z: T) = { + this(z) + print(1) + } + + def this(z: H, h: T) = { + this(h) + print(2) + } +} + +object T { + def main(args: Array[String]): Unit = { + implicit def g2h(g: G): H = new H + new A(new H, 23) + } +} diff --git a/tests/pending/pos/t267.scala b/tests/pending/pos/t267.scala new file mode 100644 index 000000000..7e5876eae --- /dev/null +++ b/tests/pending/pos/t267.scala @@ -0,0 +1,55 @@ +package expAbstractData + +/** A base class consisting of + * - a root trait (i.e. abstract class) `Exp' with an `eval' function + * - an abstract type `exp' bounded by `Exp' + * - a concrete instance class `Num' of `Exp' for numeric literals + */ +trait Base { + type exp <: Exp + + trait Exp { + def eval: Int + } + class Num(v: Int) extends Exp { self: exp => + val value = v + def eval = value + } +} + +object testBase extends App with Base { + type exp = Exp + val term = new Num(2); + Console.println(term.eval) +} + +/** Data extension: An extension of `Base' with `Plus' expressions + */ +trait BasePlus extends Base { + class Plus(l: exp, r: exp) extends Exp { self: exp => + val left = l + val right = r + def eval = left.eval + right.eval + } +} + +/** Operation extension: An extension of `Base' with 'show' methods. + */ +trait Show extends Base { + type exp <: Exp1 + + trait Exp1 extends Exp { + def show: String + } + class Num1(v: Int) extends Num(v) with Exp1 { self: exp with Num1 => + def show = value.toString() + } +} + +/** Operation extension: An extension of `BasePlus' with 'show' methods. + */ +trait ShowPlus extends BasePlus with Show { + class Plus1(l: exp, r: exp) extends Plus(l, r) with Exp1 { self: exp with Plus1 => + def show = left.show + " + " + right.show + } +} diff --git a/tests/pending/pos/t3020.scala b/tests/pending/pos/t3020.scala new file mode 100644 index 000000000..016563e27 --- /dev/null +++ b/tests/pending/pos/t3020.scala @@ -0,0 +1,9 @@ +object Test { + def main(args: Array[String]): Unit = { + var x = true + + ( { if (x) new scala.util.Random() } .asInstanceOf[Runnable] ) + } +} + + diff --git a/tests/pending/pos/t3037.scala b/tests/pending/pos/t3037.scala new file mode 100644 index 000000000..b71ffe041 --- /dev/null +++ b/tests/pending/pos/t3037.scala @@ -0,0 +1,13 @@ +package test + +object A { + println(("a" match { + case "a" => 1 + case _ => "a" + }).asInstanceOf[Object]) + def foo[T](x: T) = x + var x: Int = 1 + var y: Long = 1L + x = foo(x) + y = foo(y) +} diff --git a/tests/pending/pos/t304.scala b/tests/pending/pos/t304.scala new file mode 100644 index 000000000..76da44157 --- /dev/null +++ b/tests/pending/pos/t304.scala @@ -0,0 +1,5 @@ +object O { + def f1 = -1; + def f2 = 0-1; + def f3 = -f1; +} diff --git a/tests/pending/pos/t3106.scala b/tests/pending/pos/t3106.scala new file mode 100644 index 000000000..a9591d0aa --- /dev/null +++ b/tests/pending/pos/t3106.scala @@ -0,0 +1,7 @@ +class Sample[A] (val d0: ((A,A)) => A) {} + +object Sample { + implicit def apply[A] (x:A): Sample[A] = { + new Sample(p => p._1) + } +} diff --git a/tests/pending/pos/t3137.scala b/tests/pending/pos/t3137.scala new file mode 100644 index 000000000..cb7317af0 --- /dev/null +++ b/tests/pending/pos/t3137.scala @@ -0,0 +1,17 @@ +trait A { + val C: Any +} + +class B extends A { + class C + object C +} + +trait AA { + type C + def C: Int => C +} + +class BB extends AA { + case class C(v: Int) +} diff --git a/tests/pending/pos/t3152.scala b/tests/pending/pos/t3152.scala new file mode 100644 index 000000000..3d1dcbd6f --- /dev/null +++ b/tests/pending/pos/t3152.scala @@ -0,0 +1,20 @@ +trait Applicative[M[_]] + +sealed trait MA[M[_], A] { + def sequence[N[_], B](implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = sys.error("stub") + // def sequence3[N[_], B]()(implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = sys.error("stub") +} + +object test { + implicit def ListMA[A](l: List[A]): MA[List, A] = sys.error("stub") + implicit val ao: Applicative[Option] = sys.error("stub") + + /* This compiles OK: + (Nil: List[Option[Int]]).sequence3(): Option[List[Int]] + */ + + // BUG: error: immutable is not an enclosing class + // !!! No line number is reported with the error + (Nil: List[Option[Int]]).sequence: Option[List[Int]] + (List[Option[Int]]()).sequence: Option[List[Int]] +} diff --git a/tests/pending/pos/t3174.scala b/tests/pending/pos/t3174.scala new file mode 100755 index 000000000..8d9b2578d --- /dev/null +++ b/tests/pending/pos/t3174.scala @@ -0,0 +1,14 @@ +object test { + def method(): Unit = { + class Foo extends AnyRef { + object Color { + object Blue + } + + class Board { + val grid = Color.Blue + } + } + new Foo + } + } diff --git a/tests/pending/pos/t3175-pos.scala b/tests/pending/pos/t3175-pos.scala new file mode 100644 index 000000000..89bbf8b5f --- /dev/null +++ b/tests/pending/pos/t3175-pos.scala @@ -0,0 +1,7 @@ +object Test { + def f(g:{val update:Unit}) = g.update + + def main(args: Array[String]): Unit = { + + } +} diff --git a/tests/pending/pos/t3177.scala b/tests/pending/pos/t3177.scala new file mode 100644 index 000000000..12dfce6ee --- /dev/null +++ b/tests/pending/pos/t3177.scala @@ -0,0 +1,39 @@ +trait InvariantFunctor[F[_]] { + def xmap[A, B](ma: F[A], f: A => B, g: B => A): F[B] +} + +object InvariantFunctor { + import Endo._ + + implicit val EndoInvariantFunctor: InvariantFunctor[Endo] = new InvariantFunctor[Endo] { + def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + } + + // The definition about fails with: + // anon-type.scala:9: error: not found: value b + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + // ^ + // anon-type.scala:8: error: not found: type $anon + // implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] { + // ^ + + + // These both work: + // implicit val EndoInvariantFunctorAscribed: InvariantFunctor[Endo] = new InvariantFunctor[Endo] { + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + // } + // + // implicit val EndoInvariantFunctorStubbed = new InvariantFunctor[Endo] { + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = error("stub") + // } +} + +trait Endo[X] + +object Endo { + implicit def EndoTo[A](f: A => A): Endo[A] = new Endo[A] { + def apply(a: A) = f(a) + } + + implicit def EndoFrom[A](e: Endo[A]): A => A = e.apply(_) +} diff --git a/tests/pending/pos/t319.scala b/tests/pending/pos/t319.scala new file mode 100644 index 000000000..eed25eb84 --- /dev/null +++ b/tests/pending/pos/t319.scala @@ -0,0 +1,21 @@ +object test { + + trait A { type T; } + + trait B { type T; } + + /** def functor(x: A): B { type T = x.T } */ + abstract class functor() { + val arg: A; + val res: B { type T = arg.T } = + new B { type T = arg.T; }; + } + + val a = new A { type T = String }; + /** val b: B { type T = String } = functor(a) */ + val b: B { type T = String } = { + val tmp = new functor() { val arg = a }; + tmp.res + } + +} diff --git a/tests/pending/pos/t3252.flags b/tests/pending/pos/t3252.flags new file mode 100644 index 000000000..eb4d19bcb --- /dev/null +++ b/tests/pending/pos/t3252.flags @@ -0,0 +1 @@ +-optimise
\ No newline at end of file diff --git a/tests/pending/pos/t3252.scala b/tests/pending/pos/t3252.scala new file mode 100644 index 000000000..3ecc1e7ce --- /dev/null +++ b/tests/pending/pos/t3252.scala @@ -0,0 +1,15 @@ +class A { + def f(x : Boolean) : Thread = { + g { + x match { + case false => + B.h { } + } + } + } + + private def g[T](block : => T) = sys.error("") +} +object B { + def h(block : => Unit) : Nothing = sys.error("") +} diff --git a/tests/pending/pos/t3274.scala b/tests/pending/pos/t3274.scala new file mode 100644 index 000000000..bd8b080c9 --- /dev/null +++ b/tests/pending/pos/t3274.scala @@ -0,0 +1,9 @@ +trait A { this: B => + trait X { + class Y1 extends Y + } +} + +trait B extends A { + trait Y { def f: Unit = {} } +} diff --git a/tests/pending/pos/t3278.scala b/tests/pending/pos/t3278.scala new file mode 100644 index 000000000..458070c5e --- /dev/null +++ b/tests/pending/pos/t3278.scala @@ -0,0 +1,15 @@ +class Foo +class Test { + def update[B](x : B, b : Int): Unit = {} + def apply[B](x : B) = 1 +} + +object Test { + def main(a : Array[String]): Unit = { + val a = new Test + val f = new Foo + a(f) = 1 //works + a(f) = a(f) + 1 //works + a(f) += 1 //error: reassignment to val + } +} diff --git a/tests/pending/pos/t3343.scala b/tests/pending/pos/t3343.scala new file mode 100644 index 000000000..9d1bc9355 --- /dev/null +++ b/tests/pending/pos/t3343.scala @@ -0,0 +1,15 @@ +import scala.collection.mutable.{ Builder, ListBuffer } + +object Test { + class Converter[T] + object SimpleIntConverter extends Converter[Int] + + class TraversableConverter[T, Coll[X] <: Traversable[X]](converter: Converter[T], builder: Builder[T, Coll[T]]) extends Converter[Coll[T]] { + def convert(x: T): List[T] = List(x) + } + val tc: Converter[List[Int]] = new TraversableConverter(SimpleIntConverter, new ListBuffer[Int]) + val tc2 = new TraversableConverter(SimpleIntConverter, new ListBuffer[Int]) + + def main(args: Array[String]): Unit = { + } +} diff --git a/tests/pending/pos/t3363-new.scala b/tests/pending/pos/t3363-new.scala new file mode 100644 index 000000000..f935cfe1a --- /dev/null +++ b/tests/pending/pos/t3363-new.scala @@ -0,0 +1,20 @@ +import scala.reflect.runtime.universe._ + +object TestCase { + + //now matter if you put (abstract) class or trait it will fail in all cases + trait MapOps[T] + + //if fs was reduced to List (generic type with one parameter) then the code compiles + //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine + implicit def map2ops[T,F](fs: Map[T,F]): TestCase.MapOps[F]{lazy val m: reflect.runtime.universe.TypeTag[T]; def is(xs: List[T]): List[List[T]]} = new MapOps[F] { + //if you remove this line, then code compiles + lazy val m: TypeTag[T] = sys.error("just something to make it compile") + def is(xs: List[T]) = List(xs) + } + + def main(args: Array[String]): Unit = { + println(Map(1 -> "2") is List(2)) + } + + } diff --git a/tests/pending/pos/t3363-old.scala b/tests/pending/pos/t3363-old.scala new file mode 100644 index 000000000..8e54d4b4a --- /dev/null +++ b/tests/pending/pos/t3363-old.scala @@ -0,0 +1,18 @@ +object TestCase { + + //now matter if you put (abstract) class or trait it will fail in all cases + trait MapOps[T] + + //if fs was reduced to List (generic type with one parameter) then the code compiles + //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine + implicit def map2ops[T,F](fs: Map[T,F]): TestCase.MapOps[F]{lazy val m: Manifest[T]; def is(xs: List[T]): List[List[T]]} = new MapOps[F] { + //if you remove this line, then code compiles + lazy val m: Manifest[T] = sys.error("just something to make it compile") + def is(xs: List[T]) = List(xs) + } + + def main(args: Array[String]): Unit = { + println(Map(1 -> "2") is List(2)) + } + + } diff --git a/tests/pending/pos/t3411.scala b/tests/pending/pos/t3411.scala new file mode 100644 index 000000000..6d46be4e4 --- /dev/null +++ b/tests/pending/pos/t3411.scala @@ -0,0 +1,8 @@ +object A { + def g(c: PartialFunction[Any,Unit]): Unit = {} + + def f: Unit = { + lazy val x = 0 + g { case `x` => } + } +} diff --git a/tests/pending/pos/t344.scala b/tests/pending/pos/t344.scala new file mode 100644 index 000000000..449a763af --- /dev/null +++ b/tests/pending/pos/t344.scala @@ -0,0 +1,12 @@ +object Bug { + class A; + case class A1() extends A; + case class A2() extends A; + def f: A = + if (true) + A1() + else { + val a = if (true) A1() else A2(); + a + }; +} diff --git a/tests/pending/pos/t3477.scala b/tests/pending/pos/t3477.scala new file mode 100644 index 000000000..6a94baa6c --- /dev/null +++ b/tests/pending/pos/t3477.scala @@ -0,0 +1,7 @@ +class J3 { + def f[K, K1 >: K, V](x: Map[K1, V]): Map[K, V] = sys.error("") +} + +object Test { + (new J3).f(Map[Int, Int]()) +} diff --git a/tests/pending/pos/t3480.scala b/tests/pending/pos/t3480.scala new file mode 100644 index 000000000..d9a092e8a --- /dev/null +++ b/tests/pending/pos/t3480.scala @@ -0,0 +1,4 @@ +object Test { + val List(_*) = List(1) + val Array( who, what : _* ) = "Eclipse plugin cannot not handle this" split (" ") +} diff --git a/tests/pending/pos/t3494.scala b/tests/pending/pos/t3494.scala new file mode 100644 index 000000000..dd54b0f82 --- /dev/null +++ b/tests/pending/pos/t3494.scala @@ -0,0 +1,7 @@ +object Test { + def f[T](xs: T*) = () + + val x = "abc" + + f[x.type](x) +} diff --git a/tests/pending/pos/t3498-new.scala b/tests/pending/pos/t3498-new.scala new file mode 100644 index 000000000..ccf2af9de --- /dev/null +++ b/tests/pending/pos/t3498-new.scala @@ -0,0 +1,17 @@ +import scala.reflect.{ClassTag, classTag} + +abstract class A[T, @specialized(scala.Int) U : ClassTag] { + def f(state: T): Array[U] +} + +abstract class B extends A[ Array[Byte], Int ] { + type T = Array[Byte] + type U = Int + + val N = 0 + + def f(state: T): Array[U] = + { + new Array[U](N + state(N)) + } +} diff --git a/tests/pending/pos/t3498-old.scala b/tests/pending/pos/t3498-old.scala new file mode 100644 index 000000000..118a8d849 --- /dev/null +++ b/tests/pending/pos/t3498-old.scala @@ -0,0 +1,15 @@ +abstract class A[T, @specialized(scala.Int) U : Manifest] { + def f(state: T): Array[U] +} + +abstract class B extends A[ Array[Byte], Int ] { + type T = Array[Byte] + type U = Int + + val N = 0 + + def f(state: T): Array[U] = + { + new Array[U](N + state(N)) + } +} diff --git a/tests/pending/pos/t3534.scala b/tests/pending/pos/t3534.scala new file mode 100644 index 000000000..44d3aafb6 --- /dev/null +++ b/tests/pending/pos/t3534.scala @@ -0,0 +1,6 @@ +object Test { + List[Option[Int]]() match { + case None :: bb :: cc => () + case x => throw new Exception(x.filter(_.isDefined).mkString) + } + } diff --git a/tests/pending/pos/t3568.scala b/tests/pending/pos/t3568.scala new file mode 100755 index 000000000..50f0cdb2e --- /dev/null +++ b/tests/pending/pos/t3568.scala @@ -0,0 +1,46 @@ +import scala.annotation._ +import scala.annotation.unchecked._ +import scala.collection._ + + +package object buffer { + val broken = new ArrayVec2() // commenting out this line causes the file to compile. + + val works = Class.forName("buffer.ArrayVec2").newInstance().asInstanceOf[ArrayVec2] +} + +package buffer { + object Main { + // ArrayVec2 can be compiled, instantiated and used. + def main(args: Array[String]): Unit = { println(works) } + } + + trait ElemType { type Element; type Component <: ElemType } + trait Float1 extends ElemType { type Element = Float; type Component = Float1} + class Vec2 extends ElemType { type Element = Vec2; type Component = Float1 } + + abstract class BaseSeq[T <: ElemType, E] + extends IndexedSeq[E] with IndexedSeqOptimized[E, IndexedSeq[E]] { + def length = 1 + def apply(i: Int) :E + } + + abstract class GenericSeq[T <: ElemType] extends BaseSeq[T, T#Element] + trait DataArray[T <: ElemType] extends BaseSeq[T, T#Element] + trait DataView[T <: ElemType] extends BaseSeq[T, T#Element] + abstract class BaseFloat1 extends BaseSeq[Float1, Float] + + class ArrayFloat1 extends BaseFloat1 with DataArray[Float1] { + def apply(i: Int) :Float = 0f + } + + class ViewFloat1 extends BaseFloat1 with DataView[Float1] { + def apply(i: Int) :Float = 0f + } + + class ArrayVec2(val backingSeq: ArrayFloat1) + extends GenericSeq[Vec2] with DataArray[Vec2] { + def this() = this(new ArrayFloat1) + def apply(i: Int) :Vec2 = null + } +} diff --git a/tests/pending/pos/t3577.scala b/tests/pending/pos/t3577.scala new file mode 100644 index 000000000..1ac1786c1 --- /dev/null +++ b/tests/pending/pos/t3577.scala @@ -0,0 +1,29 @@ +case class Check[A](val value: A) + +case class C2(checks: Check[_]*); + +object C { + def m(x : C2): Any = (null: Any) match { + case C2(_, rest : _*) => { + rest.map(_.value) + } + } +} + +/////////////////// + +object Container { + trait Exp[+T] + abstract class FuncExp[-S, +T] + + sealed abstract class FoundNode[T, Repr] { + def optimize[TupleT, U, That](parentNode: FlatMap[T, Repr, U, That]): Any + def optimize2[TupleT, U, That](parentNode: Any): Any + } + + class FlatMap[T, Repr, U, That] + + val Seq(fn: FoundNode[t, repr]) = Seq[FoundNode[_, _]]() + fn.optimize(null) // was: scala.MatchError: ? (of class BoundedWildcardType) @ Variances#varianceInType + fn.optimize2(null) // was: fatal error: bad type: ?(class scala.reflect.internal.Types$BoundedWildcardType) @ Pickle.putType +} diff --git a/tests/pending/pos/t3582b.scala b/tests/pending/pos/t3582b.scala new file mode 100644 index 000000000..f7778148e --- /dev/null +++ b/tests/pending/pos/t3582b.scala @@ -0,0 +1,5 @@ +object ParamScoping { + // scoping worked fine in the result type, but was wrong in body + // reason: typedTypeDef needs new context, which was set up by typed1 but not by typedDefDef and typedClassDef + def noOverlapFOwithHO[T, G[T]]: G[T] = null.asInstanceOf[G[T]] +} diff --git a/tests/pending/pos/t360.scala b/tests/pending/pos/t360.scala new file mode 100644 index 000000000..f3716d4f9 --- /dev/null +++ b/tests/pending/pos/t360.scala @@ -0,0 +1,9 @@ +abstract class Bug360A { self: Bug360C => + def f: String = "hello"; +} +trait Bug360B { self: Bug360C => + object d { + Console.println(f); + } +} +abstract class Bug360C extends Bug360A with Bug360B; diff --git a/tests/pending/pos/t3612.scala b/tests/pending/pos/t3612.scala new file mode 100644 index 000000000..a9d063998 --- /dev/null +++ b/tests/pending/pos/t3612.scala @@ -0,0 +1,6 @@ +trait C + +class Outer { + object O0 extends C {} + object O extends C { self => } +} diff --git a/tests/pending/pos/t3631.scala b/tests/pending/pos/t3631.scala new file mode 100644 index 000000000..e72374130 --- /dev/null +++ b/tests/pending/pos/t3631.scala @@ -0,0 +1,3 @@ +case class X22(x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) { } + +case class X23(x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int, x23: Int) { } diff --git a/tests/pending/pos/t3688.scala b/tests/pending/pos/t3688.scala new file mode 100644 index 000000000..bf7983081 --- /dev/null +++ b/tests/pending/pos/t3688.scala @@ -0,0 +1,14 @@ +import collection.mutable +import collection.JavaConversions._ +import java.{util => ju} + +object Test { + + implicitly[mutable.Map[Int, String] => ju.Dictionary[Int, String]] + +} + +object Test2 { + def m[P <% ju.List[Int]](l: P) = 1 + m(List(1)) // bug: should compile +} diff --git a/tests/pending/pos/t3777.scala b/tests/pending/pos/t3777.scala new file mode 100644 index 000000000..165eeebfd --- /dev/null +++ b/tests/pending/pos/t3777.scala @@ -0,0 +1,7 @@ +object Test { + type Point = Map[Symbol, String] + type Points = IndexedSeq[Point] + + def makePoints2: Points = IndexedSeq[Point]() + val spoints2 = util.Random.shuffle(makePoints2) +} diff --git a/tests/pending/pos/t3800.scala b/tests/pending/pos/t3800.scala new file mode 100644 index 000000000..096502174 --- /dev/null +++ b/tests/pending/pos/t3800.scala @@ -0,0 +1,6 @@ +class meh extends annotation.StaticAnnotation + +class ALike[C] +abstract class AFactory[CC[x] <: ALike[CC[x]]] { + def aCompanion : AFactory[CC @meh] +} diff --git a/tests/pending/pos/t3856.scala b/tests/pending/pos/t3856.scala new file mode 100644 index 000000000..6b38edc52 --- /dev/null +++ b/tests/pending/pos/t3856.scala @@ -0,0 +1,9 @@ +case class C[T](x: T) + +case class CS(xs: C[_]*) + +// t3856 +object Test { + val x = CS(C(5), C("abc")) match { case CS(C(5), xs : _*) => xs } + println(x) +} diff --git a/tests/pending/pos/t3859.scala b/tests/pending/pos/t3859.scala new file mode 100644 index 000000000..992207301 --- /dev/null +++ b/tests/pending/pos/t3859.scala @@ -0,0 +1,4 @@ +class Test { + def foo: Unit = bar(Array(): _*) + def bar(values: AnyRef*): Unit = () +} diff --git a/tests/pending/pos/t3869.scala b/tests/pending/pos/t3869.scala new file mode 100644 index 000000000..581c11c81 --- /dev/null +++ b/tests/pending/pos/t3869.scala @@ -0,0 +1,10 @@ + +// see ticket #3869 +object Test { + def f: Unit = + try return finally while(true) () + + def main(args: Array[String]): Unit = { + f + } +} diff --git a/tests/pending/pos/t3880.scala b/tests/pending/pos/t3880.scala new file mode 100644 index 000000000..f778eb71a --- /dev/null +++ b/tests/pending/pos/t3880.scala @@ -0,0 +1,16 @@ +abstract class Bar[+B] { +} +abstract class C1[+B] extends Bar[B] { + private[this] def g(x: C1[B]): Unit = () + + // this method is fine: notice that it allows the call to g, + // which requires C1[B], even though we matched on C1[_]. + // (That is good news.) + private[this] def f1(x: Bar[B]): Unit = x match { + case x: C1[_] => g(x) + } + // this one crashes. + private[this] def f2(x: Bar[B]): Unit = x match { + case x: C1[_] => f2(x) + } +} diff --git a/tests/pending/pos/t3938/Parent.java b/tests/pending/pos/t3938/Parent.java new file mode 100644 index 000000000..08fae330b --- /dev/null +++ b/tests/pending/pos/t3938/Parent.java @@ -0,0 +1,9 @@ +public class Parent<A>{ + class I1 {} + class I2 extends Parent.I1 {} + + // OKAY: + class I3 extends I1 {} + static class I4 {} + static class I5 extends Parent.I4 {} +} diff --git a/tests/pending/pos/t3938/UseParent.scala b/tests/pending/pos/t3938/UseParent.scala new file mode 100644 index 000000000..685d1a03a --- /dev/null +++ b/tests/pending/pos/t3938/UseParent.scala @@ -0,0 +1,7 @@ +object UseParent { + classOf[Parent[AnyRef]#I2] + + // OKAY + classOf[Parent[AnyRef]#I3] + classOf[Parent.I5] +} diff --git a/tests/pending/pos/t3960.flags b/tests/pending/pos/t3960.flags new file mode 100644 index 000000000..4449dbbdf --- /dev/null +++ b/tests/pending/pos/t3960.flags @@ -0,0 +1 @@ +-Ycheck:typer
\ No newline at end of file diff --git a/tests/pending/pos/t3960.scala b/tests/pending/pos/t3960.scala new file mode 100644 index 000000000..5c658e9fb --- /dev/null +++ b/tests/pending/pos/t3960.scala @@ -0,0 +1,7 @@ +class A { + class C[x] + val cs = new scala.collection.mutable.HashMap[C[_], Int] + def c: C[_] = sys.error("") + val eval: C[_] = c + cs(c) += 1 +} diff --git a/tests/pending/pos/t3986.scala b/tests/pending/pos/t3986.scala new file mode 100644 index 000000000..ea6c64fde --- /dev/null +++ b/tests/pending/pos/t3986.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]): Unit = { + new AnyRef { +// TODO NEEDS MANUAL CHANGE (early initializers) +// BEGIN copied early initializers +val x = "abc" +// END copied early initializers + } + } +} diff --git a/tests/pending/pos/t3999/a_1.scala b/tests/pending/pos/t3999/a_1.scala new file mode 100644 index 000000000..be9cc371e --- /dev/null +++ b/tests/pending/pos/t3999/a_1.scala @@ -0,0 +1,9 @@ +package foo + +class Outside + +package object bar { + class Val(b: Boolean) + implicit def boolean2Val(b: Boolean): foo.bar.package.Val = new Val(b) + implicit def boolean2Outside(b: Boolean): foo.Outside = new Outside +} diff --git a/tests/pending/pos/t3999/b_2.scala b/tests/pending/pos/t3999/b_2.scala new file mode 100644 index 000000000..775b839d9 --- /dev/null +++ b/tests/pending/pos/t3999/b_2.scala @@ -0,0 +1,7 @@ +package foo +package bar + +class A { + val s: Val = false + val o: Outside = false +} diff --git a/tests/pending/pos/t3999b.scala b/tests/pending/pos/t3999b.scala new file mode 100644 index 000000000..0f3f7d642 --- /dev/null +++ b/tests/pending/pos/t3999b.scala @@ -0,0 +1,20 @@ +object `package` { + trait Score { def toString : String } + trait Test[+T <: Score] { def apply(s : String) : T } + + case class FT(f : Float) extends Score + implicit object FT extends Test[FT] { def apply(s : String) : FT = new FT(s.toFloat) } + + case class IT(i : Int) extends Score + implicit object IT extends Test[IT] { def apply(s : String) : IT = new IT(s.toInt) } +} + +class TT[+T <: Score](implicit val tb : Test[T]) { + def read(s : String) : T = tb(s) +} + +object Tester { + val tt = new TT[FT] + val r = tt.read("1.0") + r.toString +} diff --git a/tests/pending/pos/t404.scala b/tests/pending/pos/t404.scala new file mode 100644 index 000000000..8f5e8bef5 --- /dev/null +++ b/tests/pending/pos/t404.scala @@ -0,0 +1,12 @@ +trait AbsIterator { + type T + def next: T +} +class StringIterator extends AbsIterator { + type T = Char + def next = 'a' +} +trait SyncIterator extends AbsIterator { + abstract override def next: T = super.next +} +class I extends StringIterator with SyncIterator diff --git a/tests/pending/pos/t415.scala b/tests/pending/pos/t415.scala new file mode 100644 index 000000000..355b6136d --- /dev/null +++ b/tests/pending/pos/t415.scala @@ -0,0 +1,9 @@ +abstract class A { + type T <: String; + def x: T; +} + +abstract class B { + def a: A; + val y: String = a.x; +} diff --git a/tests/pending/pos/t4176.scala b/tests/pending/pos/t4176.scala new file mode 100644 index 000000000..b4f1e705b --- /dev/null +++ b/tests/pending/pos/t4176.scala @@ -0,0 +1,6 @@ +// a.scala +// Fri Jan 20 12:22:51 PST 2012 + +class A(xs: Int*) { def getXs = xs } + +class B extends A { override def getXs = Nil } diff --git a/tests/pending/pos/t4176b.scala b/tests/pending/pos/t4176b.scala new file mode 100644 index 000000000..11914c50c --- /dev/null +++ b/tests/pending/pos/t4176b.scala @@ -0,0 +1,5 @@ +object Test { + def foo(a: String*) = a + val fooEta = foo _ + (foo: Seq[String] => Seq[String]) +} diff --git a/tests/pending/pos/t4188.scala b/tests/pending/pos/t4188.scala new file mode 100644 index 000000000..40e7d4924 --- /dev/null +++ b/tests/pending/pos/t4188.scala @@ -0,0 +1,6 @@ +class A { + object Ding + class B { + (null: Any) match { case _: Ding.type => () } + } +} diff --git a/tests/pending/pos/t4202.scala b/tests/pending/pos/t4202.scala new file mode 100644 index 000000000..b2a0c0120 --- /dev/null +++ b/tests/pending/pos/t4202.scala @@ -0,0 +1,18 @@ +object t4202_1 { + () => { + trait T { + def t = () + } + } +} + +object t4202_2 { + () => { + trait T { + def t = () + } + object T2 extends T { + t + } + } +} diff --git a/tests/pending/pos/t4237.scala b/tests/pending/pos/t4237.scala new file mode 100644 index 000000000..44bc81462 --- /dev/null +++ b/tests/pending/pos/t4237.scala @@ -0,0 +1,6 @@ +class A { + (new { def field = 0; def field_=(i: Int) = () }).field = 5 // compiles as expected + (new { def field(implicit i: Int) = 0; def field_=(i: Int) = () }).field = 5 // compiles even with implicit params on getter + (new { def field = 0; def field_=[T](i: Int) = () }).field = 5 // compiles with type param on setter + (new { def field[T] = 0; def field_=(i: Int) = () }).field = 5 // DOESN'T COMPILE +} diff --git a/tests/pending/pos/t4269.scala b/tests/pending/pos/t4269.scala new file mode 100644 index 000000000..99a30785b --- /dev/null +++ b/tests/pending/pos/t4269.scala @@ -0,0 +1,5 @@ +class A { + PartialFunction.condOpt(Nil) { + case items@List(_*) if true => + } +} diff --git a/tests/pending/pos/t4273.scala b/tests/pending/pos/t4273.scala new file mode 100644 index 000000000..8c4cbbbaf --- /dev/null +++ b/tests/pending/pos/t4273.scala @@ -0,0 +1,8 @@ +class A { + implicit def compareComparables[T](x: T)(implicit ord: Ordering[T]): ord.Ops = new ord.Ops(x) + + class Bippy + implicit val bippyOrdering: Ordering[A.this.Bippy] = new Ordering[Bippy] { def compare(x: Bippy, y: Bippy) = util.Random.nextInt } + + (new Bippy) < (new Bippy) +} diff --git a/tests/pending/pos/t430-feb09.scala b/tests/pending/pos/t430-feb09.scala new file mode 100644 index 000000000..1499f32b7 --- /dev/null +++ b/tests/pending/pos/t430-feb09.scala @@ -0,0 +1,34 @@ +// Compiles +package a { + case class A[T]() +} + +// Compiles +package b.scala { + class B[T] +} + +// Doesn't compile: type Nothing is not a member of c.scala +package c.scala { + case class C[T]() +} + +// Doesn't compile: type Nothing is not a member of d.scala +package d.scala.d { + case class D[T]() +} + +// Doesn't compile: type Any is not a member of e.scala +package e.scala { + case class E[T >: Nothing]() +} + +// Compiles +package f.scala { + case class F[T >: Nothing <: Any]() +} + +// Doesn't compile: type <byname> is not a member of package h.scala +package h.scala { + case class H(s: String)(t: =>String) +} diff --git a/tests/pending/pos/t4336.scala b/tests/pending/pos/t4336.scala new file mode 100644 index 000000000..e10d00158 --- /dev/null +++ b/tests/pending/pos/t4336.scala @@ -0,0 +1,19 @@ +object Main { + class NonGeneric {} + class Generic[T] {} + + class Composite { + def contains(setup : Composite => Unit) : Composite = this + } + + def generic[T](parent: Composite): Generic[T] = new Generic[T] + def nonGeneric(parent: Composite): NonGeneric = new NonGeneric + + new Composite().contains( + nonGeneric // should have type Composite => NonGeneric + ) + + new Composite().contains( + generic[Int] // should have type Composite => Generic[Int] + ) +} diff --git a/tests/pending/pos/t4345.scala b/tests/pending/pos/t4345.scala new file mode 100644 index 000000000..b0131d5fa --- /dev/null +++ b/tests/pending/pos/t4345.scala @@ -0,0 +1,7 @@ +trait C1[+A, +CC[X]] { + protected[this] def f: A => CC[A] = sys.error("") +} + +trait C2[+A, +CC[X]] extends C1[A, CC] { + override protected[this] def f = super.f +} diff --git a/tests/pending/pos/t4363.scala b/tests/pending/pos/t4363.scala new file mode 100644 index 000000000..64cdcd935 --- /dev/null +++ b/tests/pending/pos/t4363.scala @@ -0,0 +1,8 @@ +object Test { + trait Suite { def bar() = () } + + () => { + trait FunkySuite extends Suite { override def bar() = () } + class MySuite extends FunkySuite { } + } +} diff --git a/tests/pending/pos/t4365/a_1.scala b/tests/pending/pos/t4365/a_1.scala new file mode 100644 index 000000000..a24b57772 --- /dev/null +++ b/tests/pending/pos/t4365/a_1.scala @@ -0,0 +1,18 @@ +import scala.collection._ + +trait SeqViewLike[+A, + +Coll, + +This <: SeqView[A, Coll] with SeqViewLike[A, Coll, Nothing]] + extends Seq[A] with GenSeqViewLike[A, Coll, Nothing] +{ + + trait Transformed[+B] extends super[GenSeqViewLike].Transformed[B] + + abstract class AbstractTransformed[+B] extends Seq[B] with Transformed[B] { + def underlying: Coll = error("") + } + + trait Reversed extends Transformed[A] with super[GenSeqViewLike].Reversed + + protected def newReversed: Transformed[A] = new AbstractTransformed[A] with Reversed +} diff --git a/tests/pending/pos/t4365/b_1.scala b/tests/pending/pos/t4365/b_1.scala new file mode 100644 index 000000000..e1423813f --- /dev/null +++ b/tests/pending/pos/t4365/b_1.scala @@ -0,0 +1,24 @@ +import scala.collection._ + +trait GenSeqView0[+A, +Coll] + +trait GenSeqViewLike[+A, + +Coll, + +This <: GenSeqView0[A, Coll] with GenSeqViewLike[A, Coll, Nothing]] +extends GenSeq[A] { +self => + + trait Transformed[+B] { + def length: Int = 0 + def apply(idx: Int): B = error("") + } + + trait Reversed extends Transformed[A] { + def iterator: Iterator[A] = createReversedIterator + + private def createReversedIterator: Iterator[A] = { + self.foreach(_ => ()) + null + } + } +} diff --git a/tests/pending/pos/t4545.scala b/tests/pending/pos/t4545.scala new file mode 100644 index 000000000..b2b67fa8f --- /dev/null +++ b/tests/pending/pos/t4545.scala @@ -0,0 +1,14 @@ +object Test { + def f[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](table: Tuple20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T])(fun: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => Unit): Unit = { + } + def g[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](table: Tuple21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U])(fun: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => Unit): Unit = { + } + + def g20 = f( + ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) + ) { case ((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)) => () } + + def g21 = g( + (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) + ) { case ((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)) => () } +} diff --git a/tests/pending/pos/t4553.scala b/tests/pending/pos/t4553.scala new file mode 100755 index 000000000..e9bef4099 --- /dev/null +++ b/tests/pending/pos/t4553.scala @@ -0,0 +1,11 @@ +trait VectorLike[+T, +V[A] <: Vector[A]] { + def +[S, VResult[S] >: V[S]](v: VResult[S]): Unit +} + +trait Vector[+T] extends VectorLike[T, Vector] +trait ImmutableVector[T] extends Vector[T] with VectorLike[T, ImmutableVector] +trait MutableVector[T] extends Vector[T] with VectorLike[T, MutableVector] + +object Test { + def f = (null: MutableVector[Int]) + (null: ImmutableVector[Int]) +} diff --git a/tests/pending/pos/t4579.flags b/tests/pending/pos/t4579.flags new file mode 100644 index 000000000..1182725e8 --- /dev/null +++ b/tests/pending/pos/t4579.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/tests/pending/pos/t4579.scala b/tests/pending/pos/t4579.scala new file mode 100644 index 000000000..b298ee579 --- /dev/null +++ b/tests/pending/pos/t4579.scala @@ -0,0 +1,518 @@ +//############################################################################ +// Lisp interpreter (revived as an optimizer test.) +//############################################################################ + +//############################################################################ +// Lisp Scanner + +class LispTokenizer(s: String) extends Iterator[String] { + private var i = 0; + private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')' + def hasNext: Boolean = { + while (i < s.length() && s.charAt(i) <= ' ') i += 1 + i < s.length() + } + def next: String = + if (hasNext) { + val start = i + if (isDelimiter(s charAt i)) i += 1 + else + do i = i + 1 + while (!isDelimiter(s charAt i)) + s.substring(start, i) + } else sys.error("premature end of string") +} + +//############################################################################ +// Lisp Interface + +trait Lisp { + type Data + + def string2lisp(s: String): Data + def lisp2string(s: Data): String + + def evaluate(d: Data): Data + // !!! def evaluate(s: String): Data = evaluate(string2lisp(s)) + def evaluate(s: String): Data +} + +//############################################################################ +// Lisp Implementation Using Case Classes + +object LispCaseClasses extends Lisp { + + import List.range + + trait Data { + def elemsToString(): String = toString(); + } + case class CONS(car: Data, cdr: Data) extends Data { + override def toString() = "(" + elemsToString() + ")"; + override def elemsToString() = car.toString() + (cdr match { + case NIL() => "" + case _ => " " + cdr.elemsToString(); + }) + } + case class NIL() extends Data { // !!! use case object + override def toString() = "()"; + } + case class SYM(name: String) extends Data { + override def toString() = name; + } + case class NUM(x: Int) extends Data { + override def toString() = x.toString(); + } + case class STR(x: String) extends Data { + override def toString() = "\"" + x + "\""; + } + case class FUN(f: List[Data] => Data) extends Data { + override def toString() = "<fn>"; + } + + def list(): Data = + NIL(); + def list(x0: Data): Data = + CONS(x0, NIL()); + def list(x0: Data, x1: Data): Data = + CONS(x0, list(x1)); + def list(x0: Data, x1: Data, x2: Data): Data = + CONS(x0, list(x1, x2)); + def list(x0: Data, x1: Data, x2: Data, x3: Data): Data = + CONS(x0, list(x1, x2, x3)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data): Data = + CONS(x0, list(x1, x2, x3, x4)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data, x8: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data, x8: Data, x9: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8, x9)); + + var curexp: Data = null + var trace: Boolean = false + var indent: Int = 0 + + def lispError[a](msg: String): a = + sys.error("error: " + msg + "\n" + curexp); + + trait Environment { + def lookup(n: String): Data; + def extendRec(name: String, expr: Environment => Data) = + new Environment { + def lookup(n: String): Data = + if (n == name) expr(this) else Environment.this.lookup(n); + } + def extend(name: String, v: Data) = extendRec(name, (env1 => v)); + } + val EmptyEnvironment = new Environment { + def lookup(n: String): Data = lispError("undefined: " + n); + } + + def toList(x: Data): List[Data] = x match { + case NIL() => List() + case CONS(y, ys) => y :: toList(ys) + case _ => lispError("malformed list: " + x); + } + + def toBoolean(x: Data) = x match { + case NUM(0) => false + case _ => true + } + + def normalize(x: Data): Data = x match { + case CONS(SYM("def"), + CONS(CONS(SYM(name), args), CONS(body, CONS(expr, NIL())))) => + normalize(list(SYM("def"), + SYM(name), list(SYM("lambda"), args, body), expr)) + case CONS(SYM("cond"), CONS(CONS(SYM("else"), CONS(expr, NIL())),NIL())) => + normalize(expr) + case CONS(SYM("cond"), CONS(CONS(test, CONS(expr, NIL())), rest)) => + normalize(list(SYM("if"), test, expr, CONS(SYM("cond"), rest))) + case CONS(h, t) => CONS(normalize(h), normalize(t)) + case _ => x + } + + def eval(x: Data, env: Environment): Data = { + val prevexp = curexp; + curexp = x; + if (trace) { + for (x <- range(1, indent)) Console.print(" "); + Console.println("===> " + x); + indent = indent + 1; + } + val result = eval1(x, env); + if (trace) { + indent = indent - 1; + for (x <- range(1, indent)) Console.print(" "); + Console.println("<=== " + result); + } + curexp = prevexp; + result + } + + def eval1(x: Data, env: Environment): Data = x match { + case SYM(name) => + env lookup name + case CONS(SYM("def"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) => + eval(z, env.extendRec(name, (env1 => eval(y, env1)))) + case CONS(SYM("val"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) => + eval(z, env.extend(name, eval(y, env))) + case CONS(SYM("lambda"), CONS(params, CONS(y, NIL()))) => + mkLambda(params, y, env) + case CONS(SYM("if"), CONS(c, CONS(t, CONS(e, NIL())))) => + if (toBoolean(eval(c, env))) eval(t, env) else eval(e, env) + case CONS(SYM("quote"), CONS(x, NIL())) => + x + case CONS(y, xs) => + apply(eval(y, env), toList(xs) map (x => eval(x, env))) + case NUM(_) => x + case STR(_) => x + case FUN(_) => x + case _ => + lispError("illegal term") + } + + def apply(fn: Data, args: List[Data]): Data = fn match { + case FUN(f) => f(args); + case _ => lispError("application of non-function: " + fn); + } + + def mkLambda(params: Data, expr: Data, env: Environment): Data = { + + def extendEnv(env: Environment, + ps: List[String], args: List[Data]): Environment = + (ps, args) match { + case (List(), List()) => + env + case (p :: ps1, arg :: args1) => + extendEnv(env.extend(p, arg), ps1, args1) + case _ => + lispError("wrong number of arguments") + } + + val ps: List[String] = toList(params) map { + case SYM(name) => name + case _ => sys.error("illegal parameter list"); + } + + FUN(args => eval(expr, extendEnv(env, ps, args))) + } + + val globalEnv = EmptyEnvironment + .extend("=", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(if (arg1 == arg2) 1 else 0) + case List(STR(arg1),STR(arg2)) => NUM(if (arg1 == arg2) 1 else 0)})) + .extend("+", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 + arg2) + case List(STR(arg1),STR(arg2)) => STR(arg1 + arg2)})) + .extend("-", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 - arg2)})) + .extend("*", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 * arg2)})) + .extend("/", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 / arg2)})) + .extend("car", FUN({ + case List(CONS(x, xs)) => x})) + .extend("cdr", FUN({ + case List(CONS(x, xs)) => xs})) + .extend("null?", FUN({ + case List(NIL()) => NUM(1) + case _ => NUM(0)})) + .extend("cons", FUN({ + case List(x, y) => CONS(x, y)})); + + def evaluate(x: Data): Data = eval(normalize(x), globalEnv); + def evaluate(s: String): Data = evaluate(string2lisp(s)); + + def string2lisp(s: String): Data = { + val it = new LispTokenizer(s); + def parse(token: String): Data = { + if (token == "(") parseList + else if (token == ")") sys.error("unbalanced parentheses") + else if ('0' <= token.charAt(0) && token.charAt(0) <= '9') + NUM(token.toInt) + else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') + STR(token.substring(1,token.length() - 1)) + else SYM(token) + } + def parseList: Data = { + val token = it.next; + if (token == ")") NIL() else CONS(parse(token), parseList) + } + parse(it.next) + } + + def lisp2string(d: Data): String = d.toString(); +} + +//############################################################################ +// Lisp Implementation Using Any + +object LispAny extends Lisp { + + import List._; + + type Data = Any; + + case class Lambda(f: List[Data] => Data); + + var curexp: Data = null; + var trace: Boolean = false; + var indent: Int = 0; + + def lispError[a](msg: String): a = + sys.error("error: " + msg + "\n" + curexp); + + trait Environment { + def lookup(n: String): Data; + def extendRec(name: String, expr: Environment => Data) = + new Environment { + def lookup(n: String): Data = + if (n == name) expr(this) else Environment.this.lookup(n); + } + def extend(name: String, v: Data) = extendRec(name, (env1 => v)); + } + val EmptyEnvironment = new Environment { + def lookup(n: String): Data = lispError("undefined: " + n); + } + + def asList(x: Data): List[Data] = x match { + case y: List[_] => y + case _ => lispError("malformed list: " + x) + } + + def asInt(x: Data): Int = x match { + case y: Int => y + case _ => lispError("not an integer: " + x) + } + + def asString(x: Data): String = x match { + case y: String => y + case _ => lispError("not a string: " + x) + } + + def asBoolean(x: Data): Boolean = x != 0 + + def normalize(x: Data): Data = x match { + case 'and :: x :: y :: Nil => + normalize('if :: x :: y :: 0 :: Nil) + case 'or :: x :: y :: Nil => + normalize('if :: x :: 1 :: y :: Nil) + case 'def :: (name :: args) :: body :: expr :: Nil => + normalize('def :: name :: ('lambda :: args :: body :: Nil) :: expr :: Nil) + case 'cond :: ('else :: expr :: Nil) :: rest => + normalize(expr); + case 'cond :: (test :: expr :: Nil) :: rest => + normalize('if :: test :: expr :: ('cond :: rest) :: Nil) + case 'cond :: 'else :: expr :: Nil => + normalize(expr) + case h :: t => + normalize(h) :: asList(normalize(t)) + case _ => + x + } + + def eval(x: Data, env: Environment): Data = { + val prevexp = curexp; + curexp = x; + if (trace) { + for (x <- range(1, indent)) Console.print(" "); + Console.println("===> " + x); + indent += 1; + } + val result = eval1(x, env); + if (trace) { + indent -= 1; + for (x <- range(1, indent)) Console.print(" "); + Console.println("<=== " + result); + } + curexp = prevexp; + result + } + + def eval1(x: Data, env: Environment): Data = x match { + case Symbol(name) => + env lookup name + case 'def :: Symbol(name) :: y :: z :: Nil => + eval(z, env.extendRec(name, (env1 => eval(y, env1)))) + case 'val :: Symbol(name) :: y :: z :: Nil => + eval(z, env.extend(name, eval(y, env))) + case 'lambda :: params :: y :: Nil => + mkLambda(params, y, env) + case 'if :: c :: y :: z :: Nil => + if (asBoolean(eval(c, env))) eval(y, env) else eval(z, env) + case 'quote :: y :: Nil => + y + case y :: z => + apply(eval(y, env), z map (x => eval(x, env))) + case Lambda(_) => x + case y: String => x + case y: Int => x + case y => lispError("illegal term") + } + + def lisp2string(x: Data): String = x match { + case Symbol(name) => name + case Nil => "()" + case y :: ys => + def list2string(xs: List[Data]): String = xs match { + case List() => "" + case y :: ys => " " + lisp2string(y) + list2string(ys) + } + "(" + lisp2string(y) + list2string(ys) + ")" + case _ => if (x.isInstanceOf[String]) "\"" + x + "\""; else x.toString() + } + + def apply(fn: Data, args: List[Data]): Data = fn match { + case Lambda(f) => f(args); + case _ => lispError("application of non-function: " + fn + " to " + args); + } + + def mkLambda(params: Data, expr: Data, env: Environment): Data = { + + def extendEnv(env: Environment, + ps: List[String], args: List[Data]): Environment = + (ps, args) match { + case (List(), List()) => + env + case (p :: ps1, arg :: args1) => + extendEnv(env.extend(p, arg), ps1, args1) + case _ => + lispError("wrong number of arguments") + } + + val ps: List[String] = asList(params) map { + case Symbol(name) => name + case _ => sys.error("illegal parameter list"); + } + + Lambda(args => eval(expr, extendEnv(env, ps, args))) + } + + val globalEnv = EmptyEnvironment + .extend("=", Lambda{ + case List(arg1, arg2) => if(arg1 == arg2) 1 else 0}) + .extend("+", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 + arg2 + case List(arg1: String, arg2: String) => arg1 + arg2}) + .extend("-", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 - arg2}) + .extend("*", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 * arg2}) + .extend("/", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 / arg2}) + .extend("nil", Nil) + .extend("cons", Lambda{ + case List(arg1, arg2) => arg1 :: asList(arg2)}) + .extend("car", Lambda{ + case List(x :: xs) => x}) + .extend("cdr", Lambda{ + case List(x :: xs) => xs}) + .extend("null?", Lambda{ + case List(Nil) => 1 + case _ => 0}); + + def evaluate(x: Data): Data = eval(normalize(x), globalEnv); + def evaluate(s: String): Data = evaluate(string2lisp(s)); + + def string2lisp(s: String): Data = { + val it = new LispTokenizer(s); + def parse(token: String): Data = { + if (token == "(") parseList + else if (token == ")") sys.error("unbalanced parentheses") + //else if (Character.isDigit(token.charAt(0))) + else if (token.charAt(0).isDigit) + token.toInt + else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') + token.substring(1,token.length() - 1) + else Symbol(token) + } + def parseList: List[Data] = { + val token = it.next; + if (token == ")") Nil else parse(token) :: parseList + } + parse(it.next) + } +} + +//############################################################################ +// List User + +class LispUser(lisp: Lisp) { + + import lisp._; + + def evaluate(s: String) = lisp2string(lisp.evaluate(s)); + + def run = { + + Console.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[AnyRef]); + Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))"))); + Console.println; + + Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))")); + Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))")); + Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))")); + Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))")); + Console.println("(null? '()) = " + evaluate("(null? (quote()))")); + Console.println; + + Console.println("faculty(10) = " + evaluate( + "(def (faculty n) " + + "(if (= n 0) " + + "1 " + + "(* n (faculty (- n 1)))) " + + "(faculty 10))")); + Console.println("faculty(10) = " + evaluate( + "(def (faculty n) " + + "(cond " + + "((= n 0) 1) " + + "(else (* n (faculty (- n 1))))) " + + "(faculty 10))")); + Console.println("foobar = " + evaluate( + "(def (foo n) " + + "(cond " + + "((= n 0) \"a\")" + + "((= n 1) \"b\")" + + "((= (/ n 2) 1) " + + "(cond " + + "((= n 2) \"c\")" + + "(else \"d\")))" + + "(else " + + "(def (bar m) " + + "(cond " + + "((= m 0) \"e\")" + + "((= m 1) \"f\")" + + "(else \"z\"))" + + "(bar (- n 4)))))" + + "(val nil (quote ())" + + "(val v1 (foo 0) " + + "(val v2 (+ (foo 1) (foo 2)) " + + "(val v3 (+ (+ (foo 3) (foo 4)) (foo 5)) " + + "(val v4 (foo 6) " + + "(cons v1 (cons v2 (cons v3 (cons v4 nil))))))))))")); + Console.println; + } +} + +//############################################################################ +// Main + +object Test { + def main(args: Array[String]): Unit = { + new LispUser(LispCaseClasses).run; + new LispUser(LispAny).run; + () + } +} + +//############################################################################ diff --git a/tests/pending/pos/t460.scala b/tests/pending/pos/t460.scala new file mode 100644 index 000000000..3fc13e4dd --- /dev/null +++ b/tests/pending/pos/t460.scala @@ -0,0 +1,9 @@ +object Bug460 { + def testFun(x : Int, y : Int) = x + y + val fn = testFun _ + + fn(1, 2) // Ok + (testFun(_, _))(1, 2) // Ok + (testFun _).apply(1, 2) + (testFun _)(1, 2) // Error! (but no longer) +} diff --git a/tests/pending/pos/t4737/J_1.java b/tests/pending/pos/t4737/J_1.java new file mode 100644 index 000000000..284afd6c1 --- /dev/null +++ b/tests/pending/pos/t4737/J_1.java @@ -0,0 +1,9 @@ +package j; + +public class J_1 { + protected class JavaInnerClass { + } + public void method(JavaInnerClass javaInnerclass) { + System.out.println("hello"); + } +} diff --git a/tests/pending/pos/t4737/S_2.scala b/tests/pending/pos/t4737/S_2.scala new file mode 100644 index 000000000..dc89d1316 --- /dev/null +++ b/tests/pending/pos/t4737/S_2.scala @@ -0,0 +1,10 @@ +package s + +import j.J_1 + +class ScalaSubClass extends J_1 { + override def method(javaInnerClass: J_1#JavaInnerClass): Unit = { + println("world") + } +} + diff --git a/tests/pending/pos/t4760.scala b/tests/pending/pos/t4760.scala new file mode 100644 index 000000000..d4407a86b --- /dev/null +++ b/tests/pending/pos/t4760.scala @@ -0,0 +1,34 @@ + +class Test { + // parses + def f1 = { + import scala._; + } + // b.scala:7: error: ';' expected but '}' found. + // } + // ^ + // one error found + def f2 = { + import scala._ + } + def f2b = { + import scala.collection.mutable.{ Map => MMap } + } + def f(): Unit = { + locally { + import scala.util.Properties.lineSeparator + } + } + + // parses + def f3 = { + import scala._ + 5 + } + locally { (x: Int) => + import scala.util._ + } + 1 match { + case 1 => import scala.concurrent._ + } +} diff --git a/tests/pending/pos/t4853.scala b/tests/pending/pos/t4853.scala new file mode 100644 index 000000000..f227ef36e --- /dev/null +++ b/tests/pending/pos/t4853.scala @@ -0,0 +1,12 @@ +object Animal { + def main(args: Array[String]): Unit = { new Animal[Awake].goToSleep } +} + +class Animal[A <: AwakeOrAsleep] { + def goToSleep[B >: A <: Awake]: Animal[Asleep] = new Animal[Asleep] + def wakeUp[B >: A <: Asleep]: Animal[Awake] = new Animal[Awake] +} + +sealed trait AwakeOrAsleep +trait Awake extends AwakeOrAsleep +trait Asleep extends AwakeOrAsleep diff --git a/tests/pending/pos/t4859.scala b/tests/pending/pos/t4859.scala new file mode 100644 index 000000000..284a39b7a --- /dev/null +++ b/tests/pending/pos/t4859.scala @@ -0,0 +1,17 @@ +object O { + // error: C is not a legal prefix for a constructor + C().CC() + // but this works. + D().DD() +} + +case class C() { + case class CC() +} + +case class D() { + class DD() + object DD { + def apply() = new DD() + } +} diff --git a/tests/pending/pos/t4911.flags b/tests/pending/pos/t4911.flags new file mode 100644 index 000000000..779916d58 --- /dev/null +++ b/tests/pending/pos/t4911.flags @@ -0,0 +1 @@ +-unchecked -Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/t4911.scala b/tests/pending/pos/t4911.scala new file mode 100644 index 000000000..cfb3792ae --- /dev/null +++ b/tests/pending/pos/t4911.scala @@ -0,0 +1,16 @@ +import language._ + +object Test { + class Foo[T](val x: T) ; object Foo { def unapply[T](x: Foo[T]) = Some(x.x) } + def f1[T](x: Foo[T]) = x match { case Foo(y) => y } + def f2[M[_], T](x: M[T]) = x match { case Foo(y) => y } + + case class Bar[T](x: T) + def f3[T](x: Bar[T]) = x match { case Bar(y) => y } + def f4[M[_], T](x: M[T]) = x match { case Bar(y) => y } +} +// +// ./b.scala:4: warning: non variable type-argument T in type pattern Test.Foo[T] is unchecked since it is eliminated by erasure +// def f2[M[_], T](x: M[T]) = x match { case Foo(y) => y } +// ^ +// one warning found diff --git a/tests/pending/pos/t4970.scala b/tests/pending/pos/t4970.scala new file mode 100644 index 000000000..f2f284f91 --- /dev/null +++ b/tests/pending/pos/t4970.scala @@ -0,0 +1,13 @@ +trait OuterClass[V <: OuterClass[V]#InnerClass] { + trait InnerClass {self: V => + def method = () + } +} + +trait SubOuterClass[T <: SubOuterClass[T]#SubInnerClass] extends OuterClass[T] { + class SubInnerClass extends super.InnerClass {self: T => } +} + +trait SubOuterClass2[T <: SubOuterClass2[T]#SubInnerClass2] extends OuterClass[T] { + class SubInnerClass2 extends super.InnerClass {self: InnerClass with T => } +} diff --git a/tests/pending/pos/t4970b.scala b/tests/pending/pos/t4970b.scala new file mode 100644 index 000000000..cf9a6a6ae --- /dev/null +++ b/tests/pending/pos/t4970b.scala @@ -0,0 +1,32 @@ +object Traits { + trait OuterClass[V <: OuterClass[V]#InnerClass] { + trait InnerClass {self: V => + def method = () + } + } + + trait SubOuterClass[T <: SubOuterClass[T]#SubInnerClass] extends OuterClass[T] { + trait SubInnerClass extends super.InnerClass {self: T => } + } + + trait SubOuterClass2[T <: SubOuterClass2[T]#SubInnerClass2] extends OuterClass[T] { + trait SubInnerClass2 extends super.InnerClass {self: InnerClass with T => } + } + +} + +// object Classes { +// class OuterClass[V <: OuterClass[V]#InnerClass] { +// class InnerClass {self: V => +// def method = () +// } +// } + +// class SubOuterClass[T <: SubOuterClass[T]#SubInnerClass] extends OuterClass[T] { +// class SubInnerClass extends super.InnerClass {self: T => } +// } + +// class SubOuterClass2[T <: SubOuterClass2[T]#SubInnerClass2] extends OuterClass[T] { +// class SubInnerClass2 extends super.InnerClass {self: InnerClass with T => } +// } +// } diff --git a/tests/pending/pos/t4975.scala b/tests/pending/pos/t4975.scala new file mode 100644 index 000000000..3339631dc --- /dev/null +++ b/tests/pending/pos/t4975.scala @@ -0,0 +1,12 @@ +object ImplicitScope { + class A[T] + + def foo: Unit = { + trait B + object B { + implicit def ab: ImplicitScope.A[B] = new A[B] + } + + implicitly[A[B]] // Error + } +} diff --git a/tests/pending/pos/t5012.scala b/tests/pending/pos/t5012.scala new file mode 100644 index 000000000..772b8f448 --- /dev/null +++ b/tests/pending/pos/t5012.scala @@ -0,0 +1,12 @@ +class D { + object p // (program point 1) +} + +class C { + def m: D = { + if("abc".length == 0) { + object p // (program point 2) + } + null + } +} diff --git a/tests/pending/pos/t5022.scala b/tests/pending/pos/t5022.scala new file mode 100644 index 000000000..5db71c656 --- /dev/null +++ b/tests/pending/pos/t5022.scala @@ -0,0 +1,22 @@ +class ForSomeVsUnapply { + def test: Unit = { + def makeWrap: Wrap = ??? + def useRep[e](rep: (e, X[e])) = () + + val repUnapply = Wrap.unapply(makeWrap).get + useRep(repUnapply) // okay + + val Wrap(rep0) = makeWrap + useRep(rep0) // error + + val rep = makeWrap match { + case Wrap(r) => r + }; + + useRep(rep) // error + } +} + +class X[e] + +case class Wrap(rep: (e, X[e]) forSome { type e }) diff --git a/tests/pending/pos/t5029.flags b/tests/pending/pos/t5029.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/pending/pos/t5029.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/t5029.scala b/tests/pending/pos/t5029.scala new file mode 100644 index 000000000..b68fc0367 --- /dev/null +++ b/tests/pending/pos/t5029.scala @@ -0,0 +1,3 @@ +object Test { + (Vector(): Seq[_]) match { case List() => true; case Nil => false } +} diff --git a/tests/pending/pos/t5041.scala b/tests/pending/pos/t5041.scala new file mode 100644 index 000000000..78a1b27d5 --- /dev/null +++ b/tests/pending/pos/t5041.scala @@ -0,0 +1,9 @@ +case class Token(text: String, startIndex: Int) + +object Comment { + def unapply(s: String): Option[Token] = None +} + +object HiddenTokens { + "foo" match { case Comment(_) => } +} diff --git a/tests/pending/pos/t5082.scala b/tests/pending/pos/t5082.scala new file mode 100644 index 000000000..63eeda38b --- /dev/null +++ b/tests/pending/pos/t5082.scala @@ -0,0 +1,14 @@ +trait Something[T] +object Test { class A } +case class Test() extends Something[Test.A] + +object User { + val Test() = Test() +} + +object Wrap { + trait Something[T] + object Test { class A } + case class Test(a: Int, b: Int)(c: String) extends Something[Test.A] + val Test(x, y) = Test(1, 2)(""); (x + y).toString +} diff --git a/tests/pending/pos/t5119.scala b/tests/pending/pos/t5119.scala new file mode 100644 index 000000000..4a67244e5 --- /dev/null +++ b/tests/pending/pos/t5119.scala @@ -0,0 +1,13 @@ +import collection.mutable + +object Test { + class IMap0[K[_], V[_]](backing: Map[K[_], V[_]]) { + def mapSeparate[VL[_], VR[_]](f: V[_] => ({type l[T] = Either[VL[T], VR[T]]})#l[_] ) = { + backing.view.map { case (k,v) => f(v) match { + case Left(l) => Left((k, l)) + case Right(r) => Right((k, r)) + } + } + } + } +} diff --git a/tests/pending/pos/t5130.scala b/tests/pending/pos/t5130.scala new file mode 100644 index 000000000..676d3c705 --- /dev/null +++ b/tests/pending/pos/t5130.scala @@ -0,0 +1,46 @@ +import scala.language.reflectiveCalls + +class A { + this_a => + + def b = new B + class B { def a: this_a.type = this_a } +} +trait A2 { def c = () } + +object Test { + val v1 = new A { def c = () } + val v2 = new A with A2 { } + val v3: A { def c: Unit } = null + def d1 = new A { def c = () } + def d2 = new A with A2 { } + def d3: A { def c: Unit } = null + var x1 = new A { def c = () } + var x2 = new A with A2 { } + var x3: A { def c: Unit } = null + + def main(args: Array[String]): Unit = { + val mv1 = new A { def c = () } + val mv2 = new A with A2 { } + val mv3: A { def c: Unit } = null + def md1 = new A { def c = () } + def md2 = new A with A2 { } + def md3: A { def c: Unit } = null + + v1.b.a.c + v2.b.a.c + v3.b.a.c + d1.b.a.c + d2.b.a.c + d3.b.a.c + x1.b.a.c + x2.b.a.c + x3.b.a.c + mv1.b.a.c + mv2.b.a.c + mv3.b.a.c + md1.b.a.c + md2.b.a.c + md3.b.a.c + } +} diff --git a/tests/pending/pos/t5156.scala b/tests/pending/pos/t5156.scala new file mode 100644 index 000000000..41b1c296e --- /dev/null +++ b/tests/pending/pos/t5156.scala @@ -0,0 +1,21 @@ +sealed trait HList +final case class HCons[H, T <: HList](head : H, tail : T) extends HList +case object HNil extends HList + +object HList { + type ::[H, T <: HList] = HCons[H, T] + type HNil = HNil.type + + implicit def hlistOps[L <: HList](l : L): AnyRef{def ::[H](h: H): HList.::[H,L]; def last(implicit last: HList.Last[L]): Unit} = new { + def ::[H](h : H) : H :: L = HCons(h, l) + def last(implicit last : Last[L]): Unit = {} + } + + class Last[L <: HList] + implicit def hsingleLast[H]: HList.Last[HList.::[H,HList.HNil]] = new Last[H :: HNil] + implicit def hlistLast[H, T <: HList](implicit lt : Last[T]): HList.Last[HList.::[H,T]] = new Last[H :: T] + + type III = Int :: Int :: Int :: HNil + val iii : III = 0 :: 0 :: 0 :: HNil + val l = iii.last +} diff --git a/tests/pending/pos/t5165/TestAnnotation.java b/tests/pending/pos/t5165/TestAnnotation.java new file mode 100644 index 000000000..90886b753 --- /dev/null +++ b/tests/pending/pos/t5165/TestAnnotation.java @@ -0,0 +1,11 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +public @interface TestAnnotation { + public enum TestEnumOne { A, B } + public enum TestEnumTwo { C, D } + + public TestEnumOne one(); + public TestEnumTwo two(); + public String strVal(); +} diff --git a/tests/pending/pos/t5165/TestObject.scala b/tests/pending/pos/t5165/TestObject.scala new file mode 100644 index 000000000..eaf244e9d --- /dev/null +++ b/tests/pending/pos/t5165/TestObject.scala @@ -0,0 +1,3 @@ + +object TestObject extends TestTrait + diff --git a/tests/pending/pos/t5165/TestTrait.scala b/tests/pending/pos/t5165/TestTrait.scala new file mode 100644 index 000000000..b317e6c6a --- /dev/null +++ b/tests/pending/pos/t5165/TestTrait.scala @@ -0,0 +1,3 @@ + +@TestAnnotation(one=TestAnnotation.TestEnumOne.A, two=TestAnnotation.TestEnumTwo.C, strVal="something") +trait TestTrait diff --git a/tests/pending/pos/t5165b/TestAnnotation_1.java b/tests/pending/pos/t5165b/TestAnnotation_1.java new file mode 100644 index 000000000..02eb3f9d4 --- /dev/null +++ b/tests/pending/pos/t5165b/TestAnnotation_1.java @@ -0,0 +1,11 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +public @interface TestAnnotation_1 { + public enum TestEnumOne { A, B } + public enum TestEnumTwo { C, D } + + public TestEnumOne one(); + public TestEnumTwo two(); + public String strVal(); +} diff --git a/tests/pending/pos/t5165b/TestObject_3.scala b/tests/pending/pos/t5165b/TestObject_3.scala new file mode 100644 index 000000000..eaf244e9d --- /dev/null +++ b/tests/pending/pos/t5165b/TestObject_3.scala @@ -0,0 +1,3 @@ + +object TestObject extends TestTrait + diff --git a/tests/pending/pos/t5165b/TestTrait_2.scala b/tests/pending/pos/t5165b/TestTrait_2.scala new file mode 100644 index 000000000..ab4facebc --- /dev/null +++ b/tests/pending/pos/t5165b/TestTrait_2.scala @@ -0,0 +1,3 @@ + +@TestAnnotation_1(one=TestAnnotation_1.TestEnumOne.A, two=TestAnnotation_1.TestEnumTwo.C, strVal="something") +trait TestTrait diff --git a/tests/pending/pos/t5210.scala b/tests/pending/pos/t5210.scala new file mode 100644 index 000000000..e85037a90 --- /dev/null +++ b/tests/pending/pos/t5210.scala @@ -0,0 +1,10 @@ +object WithOpTest { + trait WithOp extends Cloneable { + def f: this.type = this + def g1: this.type = f + def g2: this.type = { + val t = f + t + } + } +} diff --git a/tests/pending/pos/t5223.scala b/tests/pending/pos/t5223.scala new file mode 100644 index 000000000..bfd1e153c --- /dev/null +++ b/tests/pending/pos/t5223.scala @@ -0,0 +1,6 @@ +import scala.reflect.runtime.universe._ + +object Foo extends App { + reify{def printf(format: String, args: Any*): String = null } + reify{def printf(format: String, args: Any*): String = ("abc": @deprecated)} +} diff --git a/tests/pending/pos/t5259.scala b/tests/pending/pos/t5259.scala new file mode 100644 index 000000000..40c508f7d --- /dev/null +++ b/tests/pending/pos/t5259.scala @@ -0,0 +1,21 @@ +class A[T] +class B { + def m(a: A[this.type] = new A[this.type]): Unit = { } +} + +class C { + def foo(a: Int, b: Int = 0) = 0 + def foo() = 0 +} + +object Test { + def newB = new B + newB.m() + + val stableB = new B + stableB.m() + + def f: Unit = { + println((new C).foo(0)) + } +} diff --git a/tests/pending/pos/t5317.scala b/tests/pending/pos/t5317.scala new file mode 100644 index 000000000..052e84438 --- /dev/null +++ b/tests/pending/pos/t5317.scala @@ -0,0 +1,12 @@ +object Test { + trait S { type T; val x: AnyRef } + trait A extends S { type T <: A; val x: A = null } + trait B extends S { type T <: B; val x: B = null } + + val a = new A{} + val b = new B{} + val y = if (true) a else b + + // lub of y should allow for this + println(y.x.x) +} diff --git a/tests/pending/pos/t533.scala b/tests/pending/pos/t533.scala new file mode 100644 index 000000000..9bc9995d9 --- /dev/null +++ b/tests/pending/pos/t533.scala @@ -0,0 +1,11 @@ +import scala.actors._ + +object test extends Actor { + def act(): Unit = { + receive { + case TIMEOUT => Console.println("TIMEOUT") + //case _ => Console.println("_") + } + } +} + diff --git a/tests/pending/pos/t5330.scala b/tests/pending/pos/t5330.scala new file mode 100644 index 000000000..24aab7733 --- /dev/null +++ b/tests/pending/pos/t5330.scala @@ -0,0 +1,22 @@ +trait FM[A] { + def map(f: A => Any): Unit +} + +trait M[A] extends FM[A] { + def map(f: A => Any): Unit +} + +trait N[A] extends FM[A] + +object test { + def kaboom(xs: M[_]) = xs map (x => ()) // missing parameter type. + + def okay1[A](xs: M[A]) = xs map (x => ()) + def okay2(xs: FM[_]) = xs map (x => ()) + def okay3(xs: N[_]) = xs map (x => ()) +} + +class CC2(xs: List[_]) { + def f(x1: Any, x2: Any) = null + def g = xs map (x => f(x, x)) +} diff --git a/tests/pending/pos/t5384.scala b/tests/pending/pos/t5384.scala new file mode 100644 index 000000000..4e297d593 --- /dev/null +++ b/tests/pending/pos/t5384.scala @@ -0,0 +1,7 @@ +class A(x: String, y: Int)(implicit o: String) +class B1(implicit o: String) extends A(y = 5, x = "a") +class B2(implicit o: String) extends A("a", 5) +class B3(implicit o: String) extends A(y = 5, x = "a")(o) + +class AM[E: Manifest](val x: Unit = (), y: Unit) +class BM[E: Manifest] extends AM[E](y = ()) diff --git a/tests/pending/pos/t5541.scala b/tests/pending/pos/t5541.scala new file mode 100644 index 000000000..90e5e4130 --- /dev/null +++ b/tests/pending/pos/t5541.scala @@ -0,0 +1,61 @@ +package philips.adolf.paul + +trait Sys[ S <: Sys[ S ]] { + type Tx +} + +object HASkipList { + sealed trait NodeLike[ S <: Sys[ S ], @specialized( Int ) A ] { + def size : Int + def key( i: Int ): A + } + sealed trait Node[ S <: Sys[ S ], @specialized( Int ) A ] extends NodeLike[ S, A ] { + def isLeaf : Boolean + def isBranch : Boolean + def asBranch : Branch[ S, A ] + } + sealed trait BranchLike[ S <: Sys[ S ], @specialized( Int ) A ] extends NodeLike[ S, A ] { + def down( i: Int )( implicit tx: S#Tx ) : Node[ S, A ] = sys.error("") + } + sealed trait HeadOrBranch[ S <: Sys[ S ], A ] + final class Branch[ S <: Sys[ S ], @specialized( Int ) A ]() + extends BranchLike[ S, A ] with HeadOrBranch[ S, A ] with Node[ S, A ] { + def size:Int=1234 + def key(i: Int):A=sys.error("TODO") + def isLeaf : Boolean = false + def isBranch : Boolean = true + def asBranch : Branch[ S, A ] = this + } +} +sealed trait HASkipList[ S <: Sys[ S ], @specialized( Int ) A ] + +class HASkipListView[ S <: Sys[ S ], A ]( private val l: HASkipList[ S, A ])( implicit system: S ) { + import HASkipList.Node + private def buildBoxMap( n: Node[ S, A ], isRight: Boolean )( implicit tx: S#Tx ) : (Box, NodeBox) = { + val sz = n.size + val szm = sz - 1 + val keys = IndexedSeq.tabulate( sz ) { i => + val key = n.key( i ) + (key, if( isRight && i == szm ) "M" else key.toString) + } + val chbo = if( n.isLeaf ) None else { + val nb = n.asBranch + Some( IndexedSeq.tabulate( sz )( i => buildBoxMap( nb.down( i ), isRight && (i == szm) ))) + } + val b = NodeBox( n, keys, chbo.map( _.map( _._2 ))) + val bb = chbo match { + case Some( chbt ) => + val chb = chbt.map( _._1 ) + val h = Horiz( bs = chb ) + Vert( bs = IndexedSeq[Box]( b, h )) + case None => b + } + + (bb, b) + } + + private trait Box + private case class Horiz( spacing: Int = 20, bs: IndexedSeq[ Box ]) extends Box + private final case class Vert( spacing: Int = 20, bs: IndexedSeq[ Box ]) extends Box + private final case class NodeBox( n: Node[ S, A ], keys: IndexedSeq[ (A, String) ], downs: Option[ IndexedSeq[ NodeBox ]]) extends Box +} diff --git a/tests/pending/pos/t5545/S_1.scala b/tests/pending/pos/t5545/S_1.scala new file mode 100644 index 000000000..59ec1fd85 --- /dev/null +++ b/tests/pending/pos/t5545/S_1.scala @@ -0,0 +1,4 @@ +trait F[@specialized(Int) T1, R] { + def f(v1: T1): R + def g = v1 => f(v1) +} diff --git a/tests/pending/pos/t5545/S_2.scala b/tests/pending/pos/t5545/S_2.scala new file mode 100644 index 000000000..59ec1fd85 --- /dev/null +++ b/tests/pending/pos/t5545/S_2.scala @@ -0,0 +1,4 @@ +trait F[@specialized(Int) T1, R] { + def f(v1: T1): R + def g = v1 => f(v1) +} diff --git a/tests/pending/pos/t5546.scala b/tests/pending/pos/t5546.scala new file mode 100644 index 000000000..8269bf18f --- /dev/null +++ b/tests/pending/pos/t5546.scala @@ -0,0 +1 @@ +class A { def foo: Class[_ <: A] = getClass } diff --git a/tests/pending/pos/t5604/ReplConfig.scala b/tests/pending/pos/t5604/ReplConfig.scala new file mode 100644 index 000000000..8c589eba6 --- /dev/null +++ b/tests/pending/pos/t5604/ReplConfig.scala @@ -0,0 +1,53 @@ +/* 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/pending/pos/t5604/ReplReporter.scala b/tests/pending/pos/t5604/ReplReporter.scala new file mode 100644 index 000000000..9423efd8a --- /dev/null +++ b/tests/pending/pos/t5604/ReplReporter.scala @@ -0,0 +1,30 @@ +/* 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/pending/pos/t5604b/T_1.scala b/tests/pending/pos/t5604b/T_1.scala new file mode 100644 index 000000000..179dcb10c --- /dev/null +++ b/tests/pending/pos/t5604b/T_1.scala @@ -0,0 +1,6 @@ +// sandbox/t5604/T.scala +package t6504 + +trait T { + def foo: Boolean = false +} diff --git a/tests/pending/pos/t5604b/T_2.scala b/tests/pending/pos/t5604b/T_2.scala new file mode 100644 index 000000000..179dcb10c --- /dev/null +++ b/tests/pending/pos/t5604b/T_2.scala @@ -0,0 +1,6 @@ +// sandbox/t5604/T.scala +package t6504 + +trait T { + def foo: Boolean = false +} diff --git a/tests/pending/pos/t5604b/Test_1.scala b/tests/pending/pos/t5604b/Test_1.scala new file mode 100644 index 000000000..f7c58ebe8 --- /dev/null +++ b/tests/pending/pos/t5604b/Test_1.scala @@ -0,0 +1,7 @@ +// sandbox/t5604/Test.scala +package t6504 + +object Test { + def blerg1(a: Any): Any = if (foo) blerg1(0) + def blerg2(a: Any): Any = if (t6504.foo) blerg2(0) +} diff --git a/tests/pending/pos/t5604b/Test_2.scala b/tests/pending/pos/t5604b/Test_2.scala new file mode 100644 index 000000000..f7c58ebe8 --- /dev/null +++ b/tests/pending/pos/t5604b/Test_2.scala @@ -0,0 +1,7 @@ +// sandbox/t5604/Test.scala +package t6504 + +object Test { + def blerg1(a: Any): Any = if (foo) blerg1(0) + def blerg2(a: Any): Any = if (t6504.foo) blerg2(0) +} diff --git a/tests/pending/pos/t5604b/pack_1.scala b/tests/pending/pos/t5604b/pack_1.scala new file mode 100644 index 000000000..f50d568bf --- /dev/null +++ b/tests/pending/pos/t5604b/pack_1.scala @@ -0,0 +1,5 @@ +// sandbox/t5604/pack.scala +package t6504 + +object `package` extends T { +} diff --git a/tests/pending/pos/t5626.scala b/tests/pending/pos/t5626.scala new file mode 100644 index 000000000..c501dfbe6 --- /dev/null +++ b/tests/pending/pos/t5626.scala @@ -0,0 +1,12 @@ +class C { + val blob = { + new { case class Foo() } + } + val blub = { + class Inner { case class Foo() } + new Inner + } + + val foo = blob.Foo() + val bar = blub.Foo() +} diff --git a/tests/pending/pos/t5654.scala b/tests/pending/pos/t5654.scala new file mode 100644 index 000000000..1f8d05bfe --- /dev/null +++ b/tests/pending/pos/t5654.scala @@ -0,0 +1,13 @@ +class T(val a: Array[_]) + +class U { + val a = Array(Array(1, 2), Array("a","b")) +} + +class T1 { val a: Array[_] = Array(1) } + +case class Bomb(a: Array[_]) +case class Bomb2(a: Array[T] forSome { type T }) +class Okay1(a: Array[_]) +case class Okay2(s: Seq[_]) + diff --git a/tests/pending/pos/t566.scala b/tests/pending/pos/t566.scala new file mode 100644 index 000000000..6a2a0a362 --- /dev/null +++ b/tests/pending/pos/t566.scala @@ -0,0 +1,4 @@ +object test { + def foo[a](ys: List[a]): List[a] = + return ys.head :: ys.tail +} diff --git a/tests/pending/pos/t5667.scala b/tests/pending/pos/t5667.scala new file mode 100644 index 000000000..353eec93d --- /dev/null +++ b/tests/pending/pos/t5667.scala @@ -0,0 +1,4 @@ +object Main { + implicit class C(val s: String) extends AnyVal + implicit class C2(val s: String) extends AnyRef +} diff --git a/tests/pending/pos/t5692a/Macros_1.scala b/tests/pending/pos/t5692a/Macros_1.scala new file mode 100644 index 000000000..6e5069aff --- /dev/null +++ b/tests/pending/pos/t5692a/Macros_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl[T](c: Context) = { import c.universe._; c.Expr[Unit](q"()") } + def foo[T] = macro impl[T] +} diff --git a/tests/pending/pos/t5692a/Test_2.scala b/tests/pending/pos/t5692a/Test_2.scala new file mode 100644 index 000000000..72ecd9576 --- /dev/null +++ b/tests/pending/pos/t5692a/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def x = Macros.foo +} diff --git a/tests/pending/pos/t5692b/Macros_1.scala b/tests/pending/pos/t5692b/Macros_1.scala new file mode 100644 index 000000000..82109075f --- /dev/null +++ b/tests/pending/pos/t5692b/Macros_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl[T, U](c: Context) = { import c.universe._; c.Expr[Unit](q"()") } + def foo[T, U] = macro impl[T, U] +} diff --git a/tests/pending/pos/t5692b/Test_2.scala b/tests/pending/pos/t5692b/Test_2.scala new file mode 100644 index 000000000..72ecd9576 --- /dev/null +++ b/tests/pending/pos/t5692b/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def x = Macros.foo +} diff --git a/tests/pending/pos/t5706.flags b/tests/pending/pos/t5706.flags new file mode 100644 index 000000000..cd66464f2 --- /dev/null +++ b/tests/pending/pos/t5706.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/tests/pending/pos/t5706.scala b/tests/pending/pos/t5706.scala new file mode 100644 index 000000000..6f0207366 --- /dev/null +++ b/tests/pending/pos/t5706.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.blackbox.{Context => BlackboxContext} +import scala.reflect.macros.whitebox.{Context => WhiteboxContext} + +class Logger { + def error1(message: String) = macro Impls.error1 + def error2(message: String) = macro Impls.error2 +} + +object Impls { + type LoggerContext1 = BlackboxContext { type PrefixType = Logger } + def error1(c: LoggerContext1)(message: c.Expr[String]): c.Expr[Unit] = ??? + + type LoggerContext2 = WhiteboxContext { type PrefixType = Logger } + def error2(c: LoggerContext2)(message: c.Expr[String]): c.Expr[Unit] = ??? +} diff --git a/tests/pending/pos/t5720-ownerous.scala b/tests/pending/pos/t5720-ownerous.scala new file mode 100644 index 000000000..e171ce9c2 --- /dev/null +++ b/tests/pending/pos/t5720-ownerous.scala @@ -0,0 +1,56 @@ + +/* + * The block under qual$1 must be owned by it. + * In the sample bug, the first default arg generates x$4, + * the second default arg generates qual$1, hence the maximal + * minimization. + * + <method> <triedcooking> def model: C.this.M = { + val qual$1: C.this.M = scala.Option.apply[C.this.M]({ + val x$1: lang.this.String("foo") = "foo"; + val x$2: String = C.this.M.apply$default$2("foo"); + C.this.M.apply("foo")(x$2) +}).getOrElse[C.this.M]({ + val x$3: lang.this.String("bar") = "bar"; + val x$4: String = C.this.M.apply$default$2("bar"); + C.this.M.apply("bar")(x$4) + }); + val x$5: lang.this.String("baz") = "baz"; + val x$6: String = qual$1.copy$default$2("baz"); + qual$1.copy("baz")(x$6) + } + */ +class C { + case class M(currentUser: String = "anon")(val message: String = "empty") + val m = M("foo")() + + // reported + //def model = Option(M("foo")()).getOrElse(M("bar")()).copy(currentUser = "")() + + // the bug + def model = Option(m).getOrElse(M("bar")()).copy("baz")("empty") + + // style points for this version + def modish = ((null: Option[M]) getOrElse new M()()).copy()("empty") + + // various simplifications are too simple + case class N(currentUser: String = "anon") + val n = N("fun") + def nudel = Option(n).getOrElse(N()).copy() +} + +object Test { + def main(args: Array[String]): Unit = { + val c = new C + println(c.model.currentUser) + println(c.model.message) + } +} +/* +symbol value x$4$1 does not exist in badcopy.C.model +at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:45) +at scala.tools.nsc.Global.abort(Global.scala:202) +at scala.tools.nsc.backend.icode.GenICode$ICodePhase.liftedTree2$1(GenICode.scala:998) +at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:992) +*/ + diff --git a/tests/pending/pos/t5726.scala b/tests/pending/pos/t5726.scala new file mode 100644 index 000000000..1ef14ac79 --- /dev/null +++ b/tests/pending/pos/t5726.scala @@ -0,0 +1,17 @@ +import scala.language.dynamics + +class DynamicTest extends Dynamic { + def selectDynamic(name: String) = s"value of $name" + def updateDynamic(name: String)(value: Any): Unit = { + println(s"You have just updated property '$name' with value: $value") + } +} + +object MyApp extends App { + def testing(): Unit = { + val test = new DynamicTest + test.firstName = "John" + } + + testing() +} diff --git a/tests/pending/pos/t5729.scala b/tests/pending/pos/t5729.scala new file mode 100644 index 000000000..944aa04d8 --- /dev/null +++ b/tests/pending/pos/t5729.scala @@ -0,0 +1,6 @@ +trait T[X] +object Test { + def join(in: Seq[T[_]]): Int = ??? + def join[S](in: Seq[T[S]]): String = ??? + join(null: Seq[T[_]]) +} diff --git a/tests/pending/pos/t573.scala b/tests/pending/pos/t573.scala new file mode 100644 index 000000000..694d001e3 --- /dev/null +++ b/tests/pending/pos/t573.scala @@ -0,0 +1,43 @@ +package lampion.collections; + +object DirX { + abstract class Dir { + def reverse : Dir; + } + object BEFORE extends Dir { + def reverse = AFTER; + } + object AFTER extends Dir { + def reverse = BEFORE; + } +} + +import DirX._; + +abstract class Linked { + type Node <: Node0; + + abstract class Node0 { + self: Node => + + var next : Node = _; + var prev : Node = _; + + def get(dir : Dir) = if (dir == BEFORE) prev; else next; + private def set(dir : Dir, node : Node) = + if (dir == BEFORE) prev = node; else next = node; + + def link(dir : Dir, node : Node) = { + assert(get(dir) == null); + assert(node.get(dir.reverse) == null); + set(dir, node); + node.set(dir.reverse, self); + } + + + def end(dir : Dir) : Node = { + if (get(dir) == null) this; + else get(dir).end(dir); + } + } +} diff --git a/tests/pending/pos/t5744/Macros_1.scala b/tests/pending/pos/t5744/Macros_1.scala new file mode 100644 index 000000000..11da37f17 --- /dev/null +++ b/tests/pending/pos/t5744/Macros_1.scala @@ -0,0 +1,22 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.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) + } +} diff --git a/tests/pending/pos/t5744/Test_2.scala b/tests/pending/pos/t5744/Test_2.scala new file mode 100644 index 000000000..dc3de03e4 --- /dev/null +++ b/tests/pending/pos/t5744/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import Macros._ + foo(42) + implicit val s = "" + bar(43) +} diff --git a/tests/pending/pos/t5756.scala b/tests/pending/pos/t5756.scala new file mode 100644 index 000000000..411f5b05d --- /dev/null +++ b/tests/pending/pos/t5756.scala @@ -0,0 +1,6 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + def tagme[T: TypeTag](x: T) = typeTag[T] + val foo = tagme{object Bar; Bar} +} diff --git a/tests/pending/pos/t5760-pkgobj-warn/stalepkg_1.scala b/tests/pending/pos/t5760-pkgobj-warn/stalepkg_1.scala new file mode 100644 index 000000000..a0256f633 --- /dev/null +++ b/tests/pending/pos/t5760-pkgobj-warn/stalepkg_1.scala @@ -0,0 +1,11 @@ + +package object stalepkg { + class Foo +} + +package stalepkg { + object Test { + def main(args: Array[String]): Unit = { + } + } +} diff --git a/tests/pending/pos/t5760-pkgobj-warn/stalepkg_2.scala b/tests/pending/pos/t5760-pkgobj-warn/stalepkg_2.scala new file mode 100644 index 000000000..924bf35fa --- /dev/null +++ b/tests/pending/pos/t5760-pkgobj-warn/stalepkg_2.scala @@ -0,0 +1,11 @@ + +package object stalepkg { +} + +package stalepkg { + class Foo + object Test { + def main(args: Array[String]): Unit = { + } + } +} diff --git a/tests/pending/pos/t5769.scala b/tests/pending/pos/t5769.scala new file mode 100644 index 000000000..d7ec23a56 --- /dev/null +++ b/tests/pending/pos/t5769.scala @@ -0,0 +1,9 @@ +// a.scala +import scala.reflect.{ClassTag, classTag} + +class A { + type AI = Array[Int] + + def f1 = classTag[Array[Int]] + def f2 = classTag[AI] +} diff --git a/tests/pending/pos/t5777.scala b/tests/pending/pos/t5777.scala new file mode 100644 index 000000000..24cea3616 --- /dev/null +++ b/tests/pending/pos/t5777.scala @@ -0,0 +1,45 @@ +// /scala/trac/5777/a.scala +// Wed May 9 08:44:57 PDT 2012 + +trait Ring { + trait E +} + +class Poly[C <: Ring](val ring: C) extends Ring +// This definition of Poly triggers the same failure on *both* versions +// class Poly(val ring: Ring) extends Ring + +object BigInt extends Ring + +object MyApp { + val r = new Poly(BigInt) + + implicitly[r.ring.E <:< BigInt.E] + + // fail on 2.10, works on 2.9.2 + (null.asInstanceOf[BigInt.E] : r.ring.E) + + // works on both versions + val r1 = new Poly[BigInt.type](BigInt) + (null.asInstanceOf[BigInt.E] : r1.ring.E) + + // Oddly, -Xprint:typer reports that r and r1 have the same inferred type. + // + // private[this] val r: Poly[BigInt.type] = new Poly[BigInt.type](BigInt); + // <stable> <accessor> def r: Poly[BigInt.type] = MyApp.this.r; + // (null.asInstanceOf[BigInt.E]: MyApp.r.ring.E); + // private[this] val r1: Poly[BigInt.type] = new Poly[BigInt.type](BigInt); + // <stable> <accessor> def r1: Poly[BigInt.type] = MyApp.this.r1; + // (null.asInstanceOf[BigInt.E]: MyApp.r1.ring.E) + + // diff typer-2.9.2.txt typer-2.10.txt + // ... + // --- + // > object MyApp extends scala.AnyRef { + // > def <init>(): MyApp.type = { + // > MyApp.super.<init>(); + // 30c30 + // < scala.this.Predef.implicitly[<:<[BigInt.E,MyApp.r.ring.E]](scala.this.Predef.conforms[BigInt.E]); + // --- + // > scala.this.Predef.implicitly[<:<[BigInt.E,MyApp.r.ring.E]](); +} diff --git a/tests/pending/pos/t578.scala b/tests/pending/pos/t578.scala new file mode 100644 index 000000000..6f95dd8ce --- /dev/null +++ b/tests/pending/pos/t578.scala @@ -0,0 +1,7 @@ +object Test { + val x = Nil + val x2: Nil.type = x + val y = None + val y2: None.type = y + Console.println("Okay") +} diff --git a/tests/pending/pos/t5845.scala b/tests/pending/pos/t5845.scala new file mode 100644 index 000000000..823c722c1 --- /dev/null +++ b/tests/pending/pos/t5845.scala @@ -0,0 +1,16 @@ +class Num[T] { + def mkOps = new Ops + class Ops { def +++(rhs: T) = () } +} + +class A { + implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) = num.mkOps + implicit val n1 = new Num[Int] { } + println(5 +++ 5) +} + +class B { + implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) : CC[T]#Ops = num.mkOps + implicit val n1 = new Num[Int] {} + println(5 +++ 5) +} diff --git a/tests/pending/pos/t5859.scala b/tests/pending/pos/t5859.scala new file mode 100644 index 000000000..2a31e68ee --- /dev/null +++ b/tests/pending/pos/t5859.scala @@ -0,0 +1,15 @@ + +class A { + def f(xs: List[Int], ys: AnyRef*) = () + def f(xs: AnyRef*) = () + + f() + f(List[AnyRef](): _*) + f(List(): _*) + f(Nil: _*) + f(Array(): _*) + f(Array[AnyRef](): _*) + f(List(1)) + f(List(1), Nil: _*) + f(List(1), Array(): _*) +} diff --git a/tests/pending/pos/t5877.scala b/tests/pending/pos/t5877.scala new file mode 100644 index 000000000..939013cd0 --- /dev/null +++ b/tests/pending/pos/t5877.scala @@ -0,0 +1,14 @@ +package foo { + class Foo + + object Test { + new Foo().huzzah + } +} + +package object foo { + // Crasher: No synthetics for method EnrichedFoo2: synthetics contains + implicit class EnrichedFoo2(value: Foo) { + def huzzah = "" + } +} diff --git a/tests/pending/pos/t5877b.scala b/tests/pending/pos/t5877b.scala new file mode 100644 index 000000000..43a2ea2f0 --- /dev/null +++ b/tests/pending/pos/t5877b.scala @@ -0,0 +1,13 @@ +package foo + +class Foo + +object Test { + new Foo().huzzah +} + +object `package` { + implicit class EnrichedFoo2(value: Foo) { + def huzzah = "" + } +} diff --git a/tests/pending/pos/t5899.flags b/tests/pending/pos/t5899.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/pending/pos/t5899.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/t5899.scala b/tests/pending/pos/t5899.scala new file mode 100644 index 000000000..852b4e3e7 --- /dev/null +++ b/tests/pending/pos/t5899.scala @@ -0,0 +1,19 @@ +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/pending/pos/t5900a.scala b/tests/pending/pos/t5900a.scala new file mode 100644 index 000000000..cb02f67fb --- /dev/null +++ b/tests/pending/pos/t5900a.scala @@ -0,0 +1,9 @@ +case class Transition[S](x: S) + +object C + +object Test { + (??? : Any) match { + case Transition(C) => + } +} diff --git a/tests/pending/pos/t5932.flags b/tests/pending/pos/t5932.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/pending/pos/t5932.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/t5932.scala b/tests/pending/pos/t5932.scala new file mode 100644 index 000000000..d824523d5 --- /dev/null +++ b/tests/pending/pos/t5932.scala @@ -0,0 +1,15 @@ +class A + +case object B extends A + +object Test { + val x1 = (B: A) + + println(x1 == B) // no warning + println(B == x1) // no warning + + val x2 = (B: A with Product) + + println(x2 == B) // no warning + println(B == x2) // spurious warning: "always returns false" +} diff --git a/tests/pending/pos/t5953.scala b/tests/pending/pos/t5953.scala new file mode 100644 index 000000000..7ba035ec3 --- /dev/null +++ b/tests/pending/pos/t5953.scala @@ -0,0 +1,16 @@ +import scala.collection.{ mutable, immutable, generic, GenTraversableOnce } + +package object foo { + @inline implicit class TravOps[A, CC[A] <: GenTraversableOnce[A]](val coll: CC[A]) extends AnyVal { + def build[CC2[X]](implicit cbf: generic.CanBuildFrom[Nothing, A, CC2[A]]): CC2[A] = { + cbf() ++= coll.toIterator result + } + } +} + +package foo { + object Test { + def f1[T](xs: Traversable[T]) = xs.to[immutable.Vector] + def f2[T](xs: Traversable[T]) = xs.build[immutable.Vector] + } +} diff --git a/tests/pending/pos/t5954a/A_1.scala b/tests/pending/pos/t5954a/A_1.scala new file mode 100644 index 000000000..10ead0b1c --- /dev/null +++ b/tests/pending/pos/t5954a/A_1.scala @@ -0,0 +1,6 @@ +package p1 { + object `package` { + implicit class Foo(a: Any) + object Foo + } +} diff --git a/tests/pending/pos/t5954a/B_2.scala b/tests/pending/pos/t5954a/B_2.scala new file mode 100644 index 000000000..10ead0b1c --- /dev/null +++ b/tests/pending/pos/t5954a/B_2.scala @@ -0,0 +1,6 @@ +package p1 { + object `package` { + implicit class Foo(a: Any) + object Foo + } +} diff --git a/tests/pending/pos/t5954b/A_1.scala b/tests/pending/pos/t5954b/A_1.scala new file mode 100644 index 000000000..8465e8f8c --- /dev/null +++ b/tests/pending/pos/t5954b/A_1.scala @@ -0,0 +1,6 @@ +package p { + package object base { + class B + object B + } +} diff --git a/tests/pending/pos/t5954b/B_2.scala b/tests/pending/pos/t5954b/B_2.scala new file mode 100644 index 000000000..f7e4704b3 --- /dev/null +++ b/tests/pending/pos/t5954b/B_2.scala @@ -0,0 +1,5 @@ +package p { + package object base { + case class B() + } +} diff --git a/tests/pending/pos/t5954c/A_1.scala b/tests/pending/pos/t5954c/A_1.scala new file mode 100644 index 000000000..29ad9547a --- /dev/null +++ b/tests/pending/pos/t5954c/A_1.scala @@ -0,0 +1,18 @@ +package object A { + // these used to should be prevented by the implementation restriction + // but are now allowed + class B + object B + trait C + object C + case class D() + // all the rest of these should be ok + class E + object F + val g = "omg" + var h = "wtf" + def i = "lol" + type j = String + class K(val k : Int) extends AnyVal + implicit class L(val l : Int) +} diff --git a/tests/pending/pos/t5954c/B_2.scala b/tests/pending/pos/t5954c/B_2.scala new file mode 100644 index 000000000..29ad9547a --- /dev/null +++ b/tests/pending/pos/t5954c/B_2.scala @@ -0,0 +1,18 @@ +package object A { + // these used to should be prevented by the implementation restriction + // but are now allowed + class B + object B + trait C + object C + case class D() + // all the rest of these should be ok + class E + object F + val g = "omg" + var h = "wtf" + def i = "lol" + type j = String + class K(val k : Int) extends AnyVal + implicit class L(val l : Int) +} diff --git a/tests/pending/pos/t5954d/A_1.scala b/tests/pending/pos/t5954d/A_1.scala new file mode 100644 index 000000000..8465e8f8c --- /dev/null +++ b/tests/pending/pos/t5954d/A_1.scala @@ -0,0 +1,6 @@ +package p { + package object base { + class B + object B + } +} diff --git a/tests/pending/pos/t5954d/B_2.scala b/tests/pending/pos/t5954d/B_2.scala new file mode 100644 index 000000000..a4aa2eb58 --- /dev/null +++ b/tests/pending/pos/t5954d/B_2.scala @@ -0,0 +1,7 @@ +package p { + trait T { + class B + object B + } + package object base extends T +} diff --git a/tests/pending/pos/t596.scala b/tests/pending/pos/t596.scala new file mode 100644 index 000000000..b1b5471b2 --- /dev/null +++ b/tests/pending/pos/t596.scala @@ -0,0 +1,7 @@ +trait T1 { + protected abstract class C +} + +trait T2 extends T1 { + class D extends C +} diff --git a/tests/pending/pos/t5967.scala b/tests/pending/pos/t5967.scala new file mode 100644 index 000000000..eb9bd6dfa --- /dev/null +++ b/tests/pending/pos/t5967.scala @@ -0,0 +1,6 @@ +object Test { + def f(a: Int*) = a match { + case 0 :: Nil => "List(0)! My favorite Seq!" + case _ => a.toString + } +} diff --git a/tests/pending/pos/t6014.scala b/tests/pending/pos/t6014.scala new file mode 100644 index 000000000..26e258a27 --- /dev/null +++ b/tests/pending/pos/t6014.scala @@ -0,0 +1,13 @@ +object Test { + case class CC[T](key: T) + type Alias[T] = Seq[CC[T]] + + def f(xs: Seq[CC[_]]) = xs map { case CC(x) => CC(x) } // ok + def g(xs: Alias[_]) = xs map { case CC(x) => CC(x) } // fails + // ./a.scala:11: error: missing parameter type for expanded function + // The argument types of an anonymous function must be fully known. (SLS 8.5) + // Expected type was: ? + // def g(xs: Alias[_]) = xs map { case CC(x) => CC(x) } // fails + // ^ + // one error found +} diff --git a/tests/pending/pos/t602.scala b/tests/pending/pos/t602.scala new file mode 100644 index 000000000..18dd40564 --- /dev/null +++ b/tests/pending/pos/t602.scala @@ -0,0 +1,14 @@ +package com.mosol.sl + +case class Span[K <: Ordered[K]](low: Option[K], high: Option[K]) extends Function1[K, Boolean] { + override def equals(x$1: Any): Boolean = x$1 match { + case Span((low$0 @ _), (high$0 @ _)) if low$0.equals(low).$amp$amp(high$0.equals(high)) => true + case _ => false + } + def apply(k: K): Boolean = this match { + case Span(Some(low), Some(high)) => (k >= low && k <= high) + case Span(Some(low), None) => (k >= low) + case Span(None, Some(high)) => (k <= high) + case _ => false + } +} diff --git a/tests/pending/pos/t604.scala b/tests/pending/pos/t604.scala new file mode 100644 index 000000000..fb90d5ae3 --- /dev/null +++ b/tests/pending/pos/t604.scala @@ -0,0 +1,8 @@ +object Test +{ + type T = Foo.type + object Foo + + def main(argv : Array[String]) : Unit = { + } +} diff --git a/tests/pending/pos/t6047.flags b/tests/pending/pos/t6047.flags new file mode 100644 index 000000000..cd66464f2 --- /dev/null +++ b/tests/pending/pos/t6047.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/tests/pending/pos/t6047.scala b/tests/pending/pos/t6047.scala new file mode 100644 index 000000000..e7d0c38c6 --- /dev/null +++ b/tests/pending/pos/t6047.scala @@ -0,0 +1,20 @@ +import scala.reflect.macros.blackbox.Context +import java.io.InputStream + +object Macros { + def unpack[A](input: InputStream): A = macro unpack_impl[A] + + def unpack_impl[A: c.WeakTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = { + import c.universe._ + + def unpackcode(tpe: c.Type): c.Expr[_] = { + if (tpe <:< implicitly[c.WeakTypeTag[Traversable[_]]].tpe) { + + } + ??? + } + + unpackcode(implicitly[c.WeakTypeTag[A]].tpe) + ??? + } + } diff --git a/tests/pending/pos/t6084.scala b/tests/pending/pos/t6084.scala new file mode 100644 index 000000000..1aa1fed39 --- /dev/null +++ b/tests/pending/pos/t6084.scala @@ -0,0 +1,15 @@ +package object foo { type X[T, U] = (T => U) } + +package foo { + abstract class Foo[T, U](val d: T => U) extends (T => U) { + def f1(r: X[T, U]) = r match { case x: Foo[_,_] => x.d } // inferred ok + def f2(r: X[T, U]): (T => U) = r match { case x: Foo[_,_] => x.d } // dealiased ok + def f3(r: X[T, U]): X[T, U] = r match { case x: Foo[_,_] => x.d } // alias not ok + + // x.d : foo.this.package.type.X[?scala.reflect.internal.Types$NoPrefix$?.T, ?scala.reflect.internal.Types$NoPrefix$?.U] ~>scala.this.Function1[?scala.reflect.internal.Types$NoPrefix$?.T, ?scala.reflect.internal.Types$NoPrefix$?.U] + // at scala.Predef$.assert(Predef.scala:170) + // at scala.tools.nsc.Global.assert(Global.scala:235) + // at scala.tools.nsc.ast.TreeGen.mkCast(TreeGen.scala:252) + // at scala.tools.nsc.typechecker.Typers$Typer.typedCase(Typers.scala:2263) + } +} diff --git a/tests/pending/pos/t6089b.scala b/tests/pending/pos/t6089b.scala new file mode 100644 index 000000000..9378a74a0 --- /dev/null +++ b/tests/pending/pos/t6089b.scala @@ -0,0 +1,18 @@ +// this crazy code simply tries to nest pattern matches so that the last call is in a tricky-to-determine +// tail position (my initial tightenign of tailpos detection for SI-6089 ruled this out) +class BKTree { + @annotation.tailrec + final def -?-[AA](a: AA): Boolean = this match { + case BKTreeEmpty => false + case BKTreeNode(v) => { + val d = 1 + d == 0 || ( Map(1 -> this,2 -> this,3 -> this) get d match { + case None => false + case Some(w) => w -?- a // can tail call here (since || is shortcutting) + }) + } + } +} + +object BKTreeEmpty extends BKTree +case class BKTreeNode[A](v: A) extends BKTree diff --git a/tests/pending/pos/t6117.scala b/tests/pending/pos/t6117.scala new file mode 100644 index 000000000..6aca84f72 --- /dev/null +++ b/tests/pending/pos/t6117.scala @@ -0,0 +1,19 @@ +package test + +trait ImportMe { + def foo(i: Int) = 1 + def foo(s: String) = 2 +} + +class Test(val importMe: ImportMe) { + import importMe._ + import importMe._ + + // A.scala:12: error: reference to foo is ambiguous; + // it is imported twice in the same scope by + // import importMe._ + // and import importMe._ + // println(foo(1)) + // ^ + println(foo(1)) +} diff --git a/tests/pending/pos/t6123-explaintypes-implicits.flags b/tests/pending/pos/t6123-explaintypes-implicits.flags new file mode 100644 index 000000000..b36707c7c --- /dev/null +++ b/tests/pending/pos/t6123-explaintypes-implicits.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/tests/pending/pos/t6123-explaintypes-implicits.scala b/tests/pending/pos/t6123-explaintypes-implicits.scala new file mode 100644 index 000000000..86f522728 --- /dev/null +++ b/tests/pending/pos/t6123-explaintypes-implicits.scala @@ -0,0 +1,13 @@ +object ImplicitBugReport { + trait Exp[+T] + trait CanBuildExp[-Elem, +To] extends (Exp[Elem] => To) + trait TraversableExp[T, ExpT <: Exp[T]] extends Exp[Traversable[T]] + + implicit def canBuildExp[T]: CanBuildExp[T, Exp[T]] = ??? + implicit def canBuildExpTrav[T, ExpT <: Exp[T]](implicit c: CanBuildExp[T, ExpT]): CanBuildExp[Traversable[T], TraversableExp[T, ExpT]] = ??? + def toExpTempl[T, That](t: T)(implicit c: CanBuildExp[T, That]): That = ??? + + def testBug(): Unit = { + val a1 = toExpTempl(Seq(1, 2, 3, 5)) + } +} diff --git a/tests/pending/pos/t6145.scala b/tests/pending/pos/t6145.scala new file mode 100644 index 000000000..4161a24b5 --- /dev/null +++ b/tests/pending/pos/t6145.scala @@ -0,0 +1,11 @@ +object Test { + // the existential causes a cast and the cast makes searchClass not be in tail position + // can we get rid of the useless cast? + @annotation.tailrec + final def searchClass: Class[_] = { + "packageName" match { + case _ => + searchClass + } + } +} diff --git a/tests/pending/pos/t6169/Exist.java b/tests/pending/pos/t6169/Exist.java new file mode 100644 index 000000000..dfc6b36b3 --- /dev/null +++ b/tests/pending/pos/t6169/Exist.java @@ -0,0 +1,4 @@ +public class Exist<T extends String> { + // java helpfully re-interprets Exist<?> as Exist<? extends String> + public Exist<?> foo() { throw new RuntimeException(); } +}
\ No newline at end of file diff --git a/tests/pending/pos/t6169/ExistF.java b/tests/pending/pos/t6169/ExistF.java new file mode 100644 index 000000000..70fabd74c --- /dev/null +++ b/tests/pending/pos/t6169/ExistF.java @@ -0,0 +1,4 @@ +public class ExistF<T extends ExistF<T>> { + // java helpfully re-interprets ExistF<?> as ExistF<?0 extends ExistF<?0>> + public ExistF<?> foo() { throw new RuntimeException(); } +}
\ No newline at end of file diff --git a/tests/pending/pos/t6169/ExistIndir.java b/tests/pending/pos/t6169/ExistIndir.java new file mode 100644 index 000000000..e66d1698c --- /dev/null +++ b/tests/pending/pos/t6169/ExistIndir.java @@ -0,0 +1,4 @@ +public class ExistIndir<T extends String, U extends T> { + // java helpfully re-interprets ExistIndir<?> as ExistIndir<? extends String> + public ExistIndir<?, ?> foo() { throw new RuntimeException(); } +} diff --git a/tests/pending/pos/t6169/OP.java b/tests/pending/pos/t6169/OP.java new file mode 100644 index 000000000..15e4c5640 --- /dev/null +++ b/tests/pending/pos/t6169/OP.java @@ -0,0 +1 @@ +public abstract class OP<T> { } diff --git a/tests/pending/pos/t6169/Skin.java b/tests/pending/pos/t6169/Skin.java new file mode 100644 index 000000000..780de1ee0 --- /dev/null +++ b/tests/pending/pos/t6169/Skin.java @@ -0,0 +1 @@ +public interface Skin<C extends Skinnable> { } diff --git a/tests/pending/pos/t6169/Skinnable.java b/tests/pending/pos/t6169/Skinnable.java new file mode 100644 index 000000000..f91eaa30d --- /dev/null +++ b/tests/pending/pos/t6169/Skinnable.java @@ -0,0 +1,3 @@ +public interface Skinnable { + OP<Skin<?>> skinProperty(); +} diff --git a/tests/pending/pos/t6169/skinnable.scala b/tests/pending/pos/t6169/skinnable.scala new file mode 100644 index 000000000..08204f29d --- /dev/null +++ b/tests/pending/pos/t6169/skinnable.scala @@ -0,0 +1,14 @@ +object ObjectProperty { + implicit def jfxObjectProperty2sfx[T](p: OP[T]) = new ObjectProperty[T](p) +} + +class ObjectProperty[T](val delegate: OP[T]) + +trait TestWildcardBoundInference { + def delegate: Skinnable + def skin: ObjectProperty[Skin[_ /* inferred: <: Skinnable */]] = ObjectProperty.jfxObjectProperty2sfx(delegate.skinProperty) + skin: ObjectProperty[Skin[_ <: Skinnable]] + + def skinCheckInference = delegate.skinProperty + skinCheckInference: ObjectProperty[Skin[_ <: Skinnable]] +} diff --git a/tests/pending/pos/t6169/t6169.scala b/tests/pending/pos/t6169/t6169.scala new file mode 100644 index 000000000..84b2d2dad --- /dev/null +++ b/tests/pending/pos/t6169/t6169.scala @@ -0,0 +1,7 @@ +class Test { + class MyExist extends ExistF[MyExist] + // SI-8197, SI-6169: java infers the bounds of existentials, so we have to as well now that SI-1786 is fixed... + def stringy: Exist[_ <: String] = (new Exist[String]).foo + def fbounded: (ExistF[t] forSome {type t <: ExistF[t] }) = (new MyExist).foo + def indir: ExistIndir[_ <: String, _ <: String] = (new ExistIndir[String, String]).foo +} diff --git a/tests/pending/pos/t6184.scala b/tests/pending/pos/t6184.scala new file mode 100644 index 000000000..386399963 --- /dev/null +++ b/tests/pending/pos/t6184.scala @@ -0,0 +1,7 @@ +trait Foo[TroubleSome] { + type T <: Foo[TroubleSome] + + this match { + case e: Foo[_]#T => ??? + } +} diff --git a/tests/pending/pos/t6204-a.scala b/tests/pending/pos/t6204-a.scala new file mode 100644 index 000000000..dbc1144b4 --- /dev/null +++ b/tests/pending/pos/t6204-a.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ + +object Bish { + def m: Unit = { + object Bash { + typeOf[Option[_]] + } + } +} diff --git a/tests/pending/pos/t6204-b.scala b/tests/pending/pos/t6204-b.scala new file mode 100644 index 000000000..62f2b5d5c --- /dev/null +++ b/tests/pending/pos/t6204-b.scala @@ -0,0 +1,10 @@ +import scala.reflect.runtime.universe._ + +object Bosh { + def Besh: Unit = { + new { + val t = typeOf[Option[_]] + val x = t + } + } +} diff --git a/tests/pending/pos/t6208.scala b/tests/pending/pos/t6208.scala new file mode 100644 index 000000000..dac571346 --- /dev/null +++ b/tests/pending/pos/t6208.scala @@ -0,0 +1,4 @@ +object Test { + val col = collection.mutable.Queue(1,2,3) + val WORK: collection.mutable.Queue[Int] = col filterNot (_ % 2 == 0) +} diff --git a/tests/pending/pos/t6221.scala b/tests/pending/pos/t6221.scala new file mode 100644 index 000000000..bb2f1dde7 --- /dev/null +++ b/tests/pending/pos/t6221.scala @@ -0,0 +1,33 @@ +class MyFunc[-A, +B] extends (A => B) { def apply(x: A): B = ??? } + +class MyCollection[A] { + def map[B](f: MyFunc[A, B]): MyCollection[B] = new MyCollection[B] +} + +class OtherFunc[-A, +B] {} + +object Test { + implicit def functionToMyFunc[A, B](f: A => B): MyFunc[A, B] = new MyFunc // = new MyFunc[A,Nothing](); + + implicit def otherFuncToMyFunc[A, B](f: OtherFunc[A, B]): MyFunc[A, B] = new MyFunc // = new MyFunc[A,Nothing](); + + def main(args: Array[String]): Unit = { + val col = new MyCollection[Int] + + // Doesn't compile: error: missing parameter type for expanded function ((x$1) => x$1.toString) + println(col.map(_.toString)) + // scala.this.Predef.println(col.map[String](Test.this.functionToMyFunc[Int, String](((x$1: Int) => x$1.toString())))); + + // Doesn't compile: error: missing parameter type + println(col.map(x => x.toString)) + // scala.this.Predef.println(col.map[String](Test.this.functionToMyFunc[Int, String](((x: Int) => x.toString())))); + + // Does compile + println(col.map((x: Int) => x.toString)) + // scala.this.Predef.println(col.map[String](Test.this.functionToMyFunc[Int, String](((x: Int) => x.toString())))); + + // Does compile (even though type params of OtherFunc not given) + println(col.map(new OtherFunc)) + // scala.this.Predef.println(col.map[Nothing](Test.this.otherFuncToMyFunc[Any, Nothing](new OtherFunc[Any,Nothing]()))) + } +} diff --git a/tests/pending/pos/t6225.scala b/tests/pending/pos/t6225.scala new file mode 100644 index 000000000..d3d30d9e1 --- /dev/null +++ b/tests/pending/pos/t6225.scala @@ -0,0 +1,20 @@ + +package library.x { + class X { + class Foo + implicit val foo: Foo = new Foo + } +} +package library { + package object y extends library.x.X +} + +object ko { + import library.y.{Foo, foo} + implicitly[Foo] +} + +object ko2 { + import library.y._ + implicitly[Foo] +} diff --git a/tests/pending/pos/t6231.scala b/tests/pending/pos/t6231.scala new file mode 100644 index 000000000..1e5b4e0e1 --- /dev/null +++ b/tests/pending/pos/t6231.scala @@ -0,0 +1,15 @@ +object Bug { + def bar(ev: Any) = { + trait X { + def qux = { () => ev } + } + new X {}.qux() + + // workaround + trait Y { + val ev2 = ev // manually capture `ev` so that `ev2` is added to the trait interface. + def qux = { () => ev2 } + } + } +} + diff --git a/tests/pending/pos/t6231b.scala b/tests/pending/pos/t6231b.scala new file mode 100644 index 000000000..b4ddfe785 --- /dev/null +++ b/tests/pending/pos/t6231b.scala @@ -0,0 +1,8 @@ +class Test { + def f1(t: String) = { + trait T { + def xs = Nil map (_ => t) + } + () + } +} diff --git a/tests/pending/pos/t6260a.scala b/tests/pending/pos/t6260a.scala new file mode 100644 index 000000000..194294e98 --- /dev/null +++ b/tests/pending/pos/t6260a.scala @@ -0,0 +1,15 @@ +final class Option[+A](val value: A) extends AnyVal + +// Was: sandbox/test.scala:21: error: bridge generated for member method f: ()Option[A] in class Bar +// which overrides method f: ()Option[A] in class Foo" +abstract class Foo[A] { def f(): Option[A] } + class Bar[A] extends Foo[A] { def f(): Option[A] = ??? } + +// User reported this as erroneous but I couldn't reproduce with 2.10.{0,1,2,3} +// https://issues.scala-lang.org/browse/SI-6260?focusedCommentId=64764&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-64764 +// I suspect he whittled down the example too far. +class Wrapper(val value: Int) extends AnyVal +abstract class Test { def check(the: Wrapper): Boolean } +object T { + new Test { def check(the: Wrapper) = true } +} diff --git a/tests/pending/pos/t6335.scala b/tests/pending/pos/t6335.scala new file mode 100644 index 000000000..50e34092d --- /dev/null +++ b/tests/pending/pos/t6335.scala @@ -0,0 +1,25 @@ +object E extends Z { + def X = 3 + implicit class X(val i: Int) { + def xx = i + } + + def Y(a: Any) = 0 + object Y + implicit class Y(val i: String) { def yy = i } + + implicit class Z(val i: Boolean) { def zz = i } +} + +trait Z { + def Z = 0 +} + +object Test { + import E._ + 0.xx + + "".yy + + true.zz +} diff --git a/tests/pending/pos/t6355pos.scala b/tests/pending/pos/t6355pos.scala new file mode 100644 index 000000000..c0e740dd6 --- /dev/null +++ b/tests/pending/pos/t6355pos.scala @@ -0,0 +1,16 @@ +import scala.language.dynamics + +class A extends Dynamic { + def applyDynamic[T1](method: String)(x1: T1): Any = 1 + def applyDynamic[T1, T2](method: String)(x: T1, y: T2): Any = 2 + def applyDynamic[T1, T2, T3](method: String)(x: T1, y: T2, z: T3): Any = 3 +} + +object Test { + def main(args: Array[String]): Unit = { + val x = new A + println(x[Int](5)) + println(x[Int, String](5, "a")) + println(x[Int, String, Int](5, "a", 5)) + } +} diff --git a/tests/pending/pos/t6367.scala b/tests/pending/pos/t6367.scala new file mode 100644 index 000000000..1214be741 --- /dev/null +++ b/tests/pending/pos/t6367.scala @@ -0,0 +1,34 @@ +package play.api.libs.json.util + +trait FunctionalCanBuild[M[_]]{ + def apply[A,B](ma:M[A], mb:M[B]):M[A ~ B] +} + +trait Variant[M[_]] + +trait Functor[M[_]] extends Variant[M]{ + def fmap[A,B](m:M[A], f: A => B): M[B] +} + +case class ~[A,B](_1:A,_2:B) + +class FunctionalBuilder[M[_]](canBuild:FunctionalCanBuild[M]){ + class CanBuild20[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20]( + m1:M[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19], + m2:M[A20] + ) { + + def ~[A21](m3:M[A21]) = new CanBuild21(canBuild(m1,m2),m3) + + def apply[B](f: (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) => B)(implicit fu:Functor[M]): M[B] = + fu.fmap[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19 ~ A20, B]( + canBuild(m1, m2), + { case a1 ~ a2 ~ a3 ~ a4 ~ a5 ~ a6 ~ a7 ~ a8 ~ a9 ~ a10 ~ a11 ~ a12 ~ a13 ~ a14 ~ a15 ~ a16 ~ a17 ~ a18 ~ a19 ~ a20 => + f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) } + ) + } + + class CanBuild21[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21](m1:M[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19 ~ A20], m2:M[A21]){ + } + +} diff --git a/tests/pending/pos/t6386.scala b/tests/pending/pos/t6386.scala new file mode 100644 index 000000000..4031ae267 --- /dev/null +++ b/tests/pending/pos/t6386.scala @@ -0,0 +1,5 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + reify(manifest[Some[_]]) +} diff --git a/tests/pending/pos/t6447.scala b/tests/pending/pos/t6447.scala new file mode 100644 index 000000000..6ef69d485 --- /dev/null +++ b/tests/pending/pos/t6447.scala @@ -0,0 +1,18 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +class X { type T } + +object X { + // this works + def foo(x: X): x.T = macro fooImpl + def fooImpl(c: Context)(x: c.Expr[X]): c.Expr[x.value.T] = ??? + + // this doesn't + def bar(x: X, y: X): (x.T, y.T) = macro barImpl + def barImpl(c: Context)(x: c.Expr[X], y: c.Expr[X]): c.Expr[(x.value.T, y.value.T)] = ??? + + // neither does this + def baz(x: X)(xs: List[x.T]): Unit = macro bazImpl + def bazImpl(c: Context)(x: c.Expr[X])(xs: c.Expr[List[x.value.T]]): c.Expr[Unit] = ??? +} diff --git a/tests/pending/pos/t6482.scala b/tests/pending/pos/t6482.scala new file mode 100644 index 000000000..24ea38e51 --- /dev/null +++ b/tests/pending/pos/t6482.scala @@ -0,0 +1,11 @@ +final class TraversableOnceOps[+A](val collection: TraversableOnce[A]) extends AnyVal { + def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] = + if (collection.isEmpty) None else Some(collection.reduceLeft[B](op)) +} +// error: type arguments [B] do not conform to method reduceLeft's type parameter bounds [B >: A] +// if (collection.isEmpty) None else Some(collection.reduceLeft[B](op)) +// ^ + +class Foo[+A <: AnyRef](val xs: List[A]) extends AnyVal { + def baz[B >: A](x: B): List[B] = x :: xs +} diff --git a/tests/pending/pos/t6485a/Macros_1.scala b/tests/pending/pos/t6485a/Macros_1.scala new file mode 100644 index 000000000..cc7dc3d3e --- /dev/null +++ b/tests/pending/pos/t6485a/Macros_1.scala @@ -0,0 +1,5 @@ +import scala.reflect.macros.blackbox.Context + +object Macros { + def crash(c: Context): c.Expr[Unit] = c.universe.reify(()) +} diff --git a/tests/pending/pos/t6485a/Test_2.scala b/tests/pending/pos/t6485a/Test_2.scala new file mode 100644 index 000000000..54e260ac7 --- /dev/null +++ b/tests/pending/pos/t6485a/Test_2.scala @@ -0,0 +1,5 @@ +import scala.language.experimental.macros + +final class Ops[T](val x: T) extends AnyVal { + def f = macro Macros.crash +} diff --git a/tests/pending/pos/t6485b/Test.scala b/tests/pending/pos/t6485b/Test.scala new file mode 100644 index 000000000..46d707073 --- /dev/null +++ b/tests/pending/pos/t6485b/Test.scala @@ -0,0 +1,10 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +final class Ops[T](val x: T) extends AnyVal { + def f = macro Macros.crash +} + +object Macros { + def crash(c: Context): c.Expr[Unit] = c.universe.reify(()) +} diff --git a/tests/pending/pos/t6516.scala b/tests/pending/pos/t6516.scala new file mode 100644 index 000000000..2980d83eb --- /dev/null +++ b/tests/pending/pos/t6516.scala @@ -0,0 +1,19 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context +import scala.collection.TraversableLike + +// This one compiles +object Test { + type Alias[T, CC[_]] = Context { type PrefixType = TraversableLike[T, CC[T]] } + def f() = macro f_impl + def f_impl(c: Alias[Int, List])() = ??? +} + +// This one doesn't +object Test2 { + type Ctx = scala.reflect.macros.blackbox.Context + type Alias[T, CC[_]] = Ctx { type PrefixType = TraversableLike[T, CC[T]] } + + def f() = macro f_impl + def f_impl(c: Alias[Int, List])() = ??? +} diff --git a/tests/pending/pos/t6575a.scala b/tests/pending/pos/t6575a.scala new file mode 100644 index 000000000..f128714da --- /dev/null +++ b/tests/pending/pos/t6575a.scala @@ -0,0 +1,15 @@ +trait X { def foo: PartialFunction[Int, Int] } + +trait Y extends X { + // Inferred type was AbstractPartialFunction[Int, Int] with Serializable + abstract override def foo = { case i => super.foo(i) * 2 } +} +trait Z extends X { + // ditto + abstract override def foo = { case i => super.foo(i) + 3 } +} + +trait Comb extends Y with Z { + // ... which led to a type error here. + abstract override def foo: PartialFunction[Int, Int] = { case i => super.foo(i) - 2 } +} diff --git a/tests/pending/pos/t6600.scala b/tests/pending/pos/t6600.scala new file mode 100644 index 000000000..1e8137894 --- /dev/null +++ b/tests/pending/pos/t6600.scala @@ -0,0 +1,8 @@ +final class Natural extends scala.math.ScalaNumber with scala.math.ScalaNumericConversions { + def intValue(): Int = 0 + def longValue(): Long = 0L + def floatValue(): Float = 0.0F + def doubleValue(): Double = 0.0D + def isWhole(): Boolean = false + def underlying() = this +} diff --git a/tests/pending/pos/t661.scala b/tests/pending/pos/t661.scala new file mode 100644 index 000000000..3a447241f --- /dev/null +++ b/tests/pending/pos/t661.scala @@ -0,0 +1,17 @@ +package test; + +object test { + abstract class A { + abstract class C { + type M; + def foo(n : M) : Unit = {} + } + } + trait B extends A { + type N; + trait C extends super.C { + type M = N; + override def foo(n : M) : Unit = super.foo(n); + } + } +} diff --git a/tests/pending/pos/t6664b.scala b/tests/pending/pos/t6664b.scala new file mode 100644 index 000000000..a62286683 --- /dev/null +++ b/tests/pending/pos/t6664b.scala @@ -0,0 +1,5 @@ +object T { + def A(s: String): A = new A(3, s) + def A(i: Int): A = A(i, "abc") + case class A(i: Int, s: String) +} diff --git a/tests/pending/pos/t6722.scala b/tests/pending/pos/t6722.scala new file mode 100644 index 000000000..576746c91 --- /dev/null +++ b/tests/pending/pos/t6722.scala @@ -0,0 +1,11 @@ +import scala.language.dynamics + +class Dyn extends Dynamic { + def selectDynamic(s: String): Dyn = new Dyn + def get[T]: T = null.asInstanceOf[T] +} + +object Foo { + val dyn = new Dyn + dyn.foo.bar.baz.get[String] +} diff --git a/tests/pending/pos/t6815_import.scala b/tests/pending/pos/t6815_import.scala new file mode 100644 index 000000000..56f4358d5 --- /dev/null +++ b/tests/pending/pos/t6815_import.scala @@ -0,0 +1,16 @@ +trait U { + trait ValOrDefDefApi { + def name: Any + } + type ValOrDefDef <: ValOrDefDefApi + type ValDef <: ValOrDefDef with ValDefApi + trait ValDefApi extends ValOrDefDefApi { this: ValDef => } + val emptyValDef: ValDef // the result type is volatile +} + +object Test { + val u: U = ??? + + // but we shouldn't let that stop us from treating it as a stable identifier for import + import u.emptyValDef.name +} diff --git a/tests/pending/pos/t6846.scala b/tests/pending/pos/t6846.scala new file mode 100644 index 000000000..2536e725c --- /dev/null +++ b/tests/pending/pos/t6846.scala @@ -0,0 +1,28 @@ +object Test { + class Arb[X_909538798] + implicit def foo[M[_], A]: Arb[M[A]] = null + foo: Arb[List[Int]] + type ListInt = List[Int] + foo: Arb[ListInt] +} + +object Test2 { + import scala.collection.immutable.List + + class Carb[X_1647473379] + implicit def narrow[N, M[_], A](x: Carb[M[A]])(implicit ev: N <:< M[A]): Carb[N] = null + implicit def bar[M[_], A]: Carb[M[A]] = null + + type ListInt = List[Int] + + val x: List[Int] = List(1) + val y: ListInt = List(1) + + type ListSingletonX = x.type + type ListSingletonY = y.type + + bar: Carb[List[Int]] + bar: Carb[ListInt] + bar: Carb[ListSingletonX] + bar: Carb[ListSingletonY] +} diff --git a/tests/pending/pos/t6925.scala b/tests/pending/pos/t6925.scala new file mode 100644 index 000000000..c6f418519 --- /dev/null +++ b/tests/pending/pos/t6925.scala @@ -0,0 +1,9 @@ +class Test { + def f[T](xs: Set[T]) /* no expected type to trigger inference */ = + xs collect { case x => x } + + def g[T](xs: Set[T]): Set[T] = f[T](xs) // check that f's inferred type is Set[T] + + // check that this type checks: + List(1).flatMap(n => Set(1).collect { case w => w }) +} diff --git a/tests/pending/pos/t694.scala b/tests/pending/pos/t694.scala new file mode 100644 index 000000000..ebabc658c --- /dev/null +++ b/tests/pending/pos/t694.scala @@ -0,0 +1,10 @@ +object test3 { + trait Type[T]; + case object IntType extends Type[Int]; + case object StringType extends Type[String]; + + def f[T](t : Type[T]) : T = t match { + case IntType => 10; + case StringType => "hello"; + } +} diff --git a/tests/pending/pos/t6948.scala b/tests/pending/pos/t6948.scala new file mode 100644 index 000000000..12a1d7eaf --- /dev/null +++ b/tests/pending/pos/t6948.scala @@ -0,0 +1,10 @@ +object t6948 { + val rand = new scala.util.Random() + def a1 = rand.shuffle(0 to 5) + // Tis not to be + // def a2 = rand.shuffle(0 until 5) + def a3 = rand.shuffle(Vector(1, 2, 3)) + def a4 = rand.shuffle(scala.collection.Seq(1, 2, 3)) + def a5 = rand.shuffle(scala.collection.immutable.Seq(1, 2, 3)) + def a6 = rand.shuffle(scala.collection.mutable.Seq(1, 2, 3)) +} diff --git a/tests/pending/pos/t6966.scala b/tests/pending/pos/t6966.scala new file mode 100644 index 000000000..a43d7c501 --- /dev/null +++ b/tests/pending/pos/t6966.scala @@ -0,0 +1,17 @@ +import Ordering.{Byte, comparatorToOrdering} +trait Format[T] +trait InputCache[T] +object CacheIvy { + implicit def basicInputCache[I](implicit fmt: Format[I], eqv: Equiv[I]): InputCache[I] = null + implicit def arrEquiv[T](implicit t: Equiv[T]): Equiv[Array[T]] = null + implicit def hNilCache: InputCache[HNil] = null + implicit def ByteArrayFormat: Format[Array[Byte]] = null + type :+:[H, T <: HList] = HCons[H,T] + implicit def hConsCache[H, T <: HList](implicit head: InputCache[H], tail: InputCache[T]): InputCache[H :+: T] = null + hConsCache[Array[Byte], HNil] +} + +sealed trait HList +sealed trait HNil extends HList +object HNil extends HNil +final class HCons[H, T <: HList](head : H, tail : T) extends HList diff --git a/tests/pending/pos/t697.scala b/tests/pending/pos/t697.scala new file mode 100644 index 000000000..6caea418d --- /dev/null +++ b/tests/pending/pos/t697.scala @@ -0,0 +1,3 @@ +object test { + val x = 10 == 20 == 30 < 10; +} diff --git a/tests/pending/pos/t6976/Exts_1.scala b/tests/pending/pos/t6976/Exts_1.scala new file mode 100644 index 000000000..9b3a69edd --- /dev/null +++ b/tests/pending/pos/t6976/Exts_1.scala @@ -0,0 +1,10 @@ +object Exts { + implicit class AnyExts[T](val o: T) extends AnyVal { + def moo = "moo!" + } +} + +trait Exts { + import language.implicitConversions + implicit def AnyExts[T](o: T) = Exts.AnyExts(o) +} diff --git a/tests/pending/pos/t6976/ImplicitBug_1.scala b/tests/pending/pos/t6976/ImplicitBug_1.scala new file mode 100644 index 000000000..50bc247ac --- /dev/null +++ b/tests/pending/pos/t6976/ImplicitBug_1.scala @@ -0,0 +1,27 @@ +// This one is weird and nasty. Not sure if this is scalac or sbt +// (tried with 0.12 & 0.12.2-RC2) bug. +// +// A level of indirection is required to trigger this bug. +// Exts seems to need to be defined in separate file. +// +// Steps to reproduce: +// 1. sbt clean +// 2. sbt run (it works) +// 3. Comment A & uncomment B. +// 4. sbt run (it fails) +// 5. Switch it back & sbt run. It still fails. +// +// In this project sbt clean helps. However in a large project where this +// bug was found compiler crashed even after doing sbt clean. The only +// way to work around this was to reference Exts object explicitly (C) in +// the source file using its implicit classes. + +// Lets suppose this is a mega-trait combining all sorts of helper +// functionality. +trait Support extends Exts + +object ImplicitsBug extends App with Support { // A +// object ImplicitsBug extends App with Exts { // B + //Exts // C) this reference helped in the large project. + println(3.moo) +} diff --git a/tests/pending/pos/t6976/ImplicitBug_2.scala b/tests/pending/pos/t6976/ImplicitBug_2.scala new file mode 100644 index 000000000..2fea5e299 --- /dev/null +++ b/tests/pending/pos/t6976/ImplicitBug_2.scala @@ -0,0 +1,7 @@ +trait Support extends Exts + +// object ImplicitsBug extends App with Support { // A +object ImplicitsBug extends App with Exts { // B + //Exts // C) this reference helped in the large project. + println(3.moo) +} diff --git a/tests/pending/pos/t6994.flags b/tests/pending/pos/t6994.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/pending/pos/t6994.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/t6994.scala b/tests/pending/pos/t6994.scala new file mode 100644 index 000000000..d70719642 --- /dev/null +++ b/tests/pending/pos/t6994.scala @@ -0,0 +1,8 @@ +object Test { + object NF { + def unapply(t: Throwable): Option[Throwable] = None + } + val x = (try { None } catch { case NF(ex) => None }) getOrElse 0 + // Was emitting a spurious warning post typer: + // "This catches all Throwables. If this is really intended, use `case ex6 : Throwable` to clear this warning." +} diff --git a/tests/pending/pos/t7011.flags b/tests/pending/pos/t7011.flags new file mode 100644 index 000000000..a4c161553 --- /dev/null +++ b/tests/pending/pos/t7011.flags @@ -0,0 +1 @@ +-Ydebug -Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/t7011.scala b/tests/pending/pos/t7011.scala new file mode 100644 index 000000000..18d7aeee7 --- /dev/null +++ b/tests/pending/pos/t7011.scala @@ -0,0 +1,7 @@ +object bar { + def foo: Unit = { + lazy val x = 42 + + {()=>x} + } +} diff --git a/tests/pending/pos/t7022.scala b/tests/pending/pos/t7022.scala new file mode 100644 index 000000000..0609e2d25 --- /dev/null +++ b/tests/pending/pos/t7022.scala @@ -0,0 +1,9 @@ +class Catch[+T] { + def either[U >: T](body: => U): Either[Throwable, U] = ??? +} + +object Test { + implicit class RichCatch[T](val c: Catch[T]) extends AnyVal { + def validation[U >: T](u: => U): Either[Throwable, U] = c.either(u) + } +} diff --git a/tests/pending/pos/t703.scala b/tests/pending/pos/t703.scala new file mode 100644 index 000000000..b24d70c92 --- /dev/null +++ b/tests/pending/pos/t703.scala @@ -0,0 +1,29 @@ +object Go { + trait A { + def f : Unit; // = Console.println("A"); + } + trait B extends A { + abstract override def f = { + super.f; + Console.println("B"); + } + } + trait C extends A { + abstract override def f = { + super.f; + Console.println("C"); + } + } + trait D extends B with C { + abstract override def f = { + super.f; + } + } + class Super extends A { + def f: Unit = Console.println("A") + } + def main(args : Array[String]) : Unit = { + object d extends Super with D + d.f; + } +} diff --git a/tests/pending/pos/t7035.scala b/tests/pending/pos/t7035.scala new file mode 100644 index 000000000..f45bd0a87 --- /dev/null +++ b/tests/pending/pos/t7035.scala @@ -0,0 +1,15 @@ +case class Y(final var x: Int, final private var y: String, final val z1: Boolean, final private val z2: Any) { + + import Test.{y => someY} + List(someY.x: Int, someY.y: String, someY.z1: Boolean, someY.z2: Any) + someY.y = "" +} + +object Test { + val y = Y(0, "", true, new {}) + val unapp: Option[(Int, String, Boolean, Any)] = // was (Int, Boolean, String, Any) !! + Y.unapply(y) + + val Y(a, b, c, d) = y + List(a: Int, b: String, c: Boolean, d: Any) +} diff --git a/tests/pending/pos/t704.scala b/tests/pending/pos/t704.scala new file mode 100644 index 000000000..aedd8c03a --- /dev/null +++ b/tests/pending/pos/t704.scala @@ -0,0 +1,23 @@ +trait D { + private val x = "xxxx should appear twice" + private object xxxx { Console.println(x) } + def get_xxxx: AnyRef = xxxx +} + +trait E extends D { + def f(): Unit = { + val y = "yyyy should appear twice" + object yyyy { + val x1 = get_xxxx + Console.println(y) + } + yyyy + } +} +class C extends E {} +object Go extends D { + def main(args : Array[String]): Unit = { + new C().f() + new C().f() + } +} diff --git a/tests/pending/pos/t711.scala b/tests/pending/pos/t711.scala new file mode 100644 index 000000000..4dd604096 --- /dev/null +++ b/tests/pending/pos/t711.scala @@ -0,0 +1,14 @@ +abstract class Component + +class Button extends Component { + def sayHey: Unit = Console.println("Hey, I'm a button") } + +abstract class Origin { + val delegate: Component } + +object main extends Origin with App { + val delegate: Component { + def sayHey: Unit + } = new Button + delegate.sayHey +} diff --git a/tests/pending/pos/t7126.scala b/tests/pending/pos/t7126.scala new file mode 100644 index 000000000..edac56d28 --- /dev/null +++ b/tests/pending/pos/t7126.scala @@ -0,0 +1,11 @@ +import language._ + +object Test { + type T = Any + boom(???): Option[T] // SOE + def boom[CC[U]](t : CC[T]): Option[CC[T]] = None + + // okay + foo(???): Option[Any] + def foo[CC[U]](t : CC[Any]): Option[CC[Any]] = None +} diff --git a/tests/pending/pos/t7190.scala b/tests/pending/pos/t7190.scala new file mode 100644 index 000000000..449e5c83f --- /dev/null +++ b/tests/pending/pos/t7190.scala @@ -0,0 +1,26 @@ +import scala.language.experimental.macros +import scala.reflect.macros._ + +trait A[T] { + def min[U >: T](implicit ord: Numeric[U]): T = macro A.min[T, U] +} + +object A { + def min[T: c.WeakTypeTag, U >: T: c.WeakTypeTag](c: Context)(ord: c.Expr[Numeric[U]]): c.Expr[T] = { + c.universe.reify { + ord.splice.zero.asInstanceOf[T] + } + } +} + +class B extends A[Int] { + override def min[U >: Int](implicit ord: Numeric[U]): Int = macro B.min[U] +} + +object B { + def min[U >: Int: c.WeakTypeTag](c: Context)(ord: c.Expr[Numeric[U]]): c.Expr[Int] = { + c.universe.reify { + ord.splice.zero.asInstanceOf[Int] + } + } +} diff --git a/tests/pending/pos/t7226.scala b/tests/pending/pos/t7226.scala new file mode 100644 index 000000000..1b7e2549c --- /dev/null +++ b/tests/pending/pos/t7226.scala @@ -0,0 +1,26 @@ +trait HK { + type Rep[X] + + // okay + def unzip2[A, B](ps: Rep[List[(A, B)]]): Unit + unzip2(null.asInstanceOf[Rep[List[(Int, String)]]]) + + // okay + def unzipHK[A, B, C[_]](ps: Rep[C[(A, B)]]): Unit + unzipHK(null.asInstanceOf[Rep[List[(Int, String)]]]) + + def unzipHKRet0[A, C[_]](ps: C[A]): C[Int] + def ls: List[String] + unzipHKRet0(ls) + + // fail + def unzipHKRet[A, C[_]](ps: Rep[C[A]]): Rep[C[Int]] + def rls: Rep[List[String]] + unzipHKRet(rls) +} + +trait HK1 { + type Rep[A] + def unzip1[A, B, C[_]](ps: Rep[C[(A, B)]]): (Rep[C[A]], Rep[C[B]]) + def doUnzip1[A, B](ps: Rep[List[(A, B)]]) = unzip1(ps) +} diff --git a/tests/pending/pos/t7228.scala b/tests/pending/pos/t7228.scala new file mode 100644 index 000000000..5d936f652 --- /dev/null +++ b/tests/pending/pos/t7228.scala @@ -0,0 +1,75 @@ +object AdaptWithWeaklyConformantType { + implicit class D(d: Double) { def double = d*2 } + + val x1: Int = 1 + var x2: Int = 2 + val x3 = 3 + var x4 = 4 + final val x5 = 5 + final var x6 = 6 + + def f1 = x1.double + def f2 = x2.double + def f3 = x3.double + def f4 = x4.double + def f5 = x5.double + def f6 = x6.double +} + +object AdaptAliasWithWeaklyConformantType { + implicit class D(d: Double) { def double = d*2 } + type T = Int + + val x1: T = 1 + var x2: T = 2 + val x3 = (3: T) + var x4 = (4: T) + final val x5 = (5: T) + final var x6 = (6: T) + + def f1 = x1.double + def f2 = x2.double + def f3 = x3.double + def f4 = x4.double + def f5 = x5.double + def f6 = x6.double +} + +object AdaptToAliasWithWeaklyConformantType { + type U = Double + implicit class D(d: U) { def double = d*2 } + + val x1: Int = 1 + var x2: Int = 2 + val x3 = (3: Int) + var x4 = (4: Int) + final val x5 = (5: Int) + final var x6 = (6: Int) + + def f1 = x1.double + def f2 = x2.double + def f3 = x3.double + def f4 = x4.double + def f5 = x5.double + def f6 = x6.double +} + +object AdaptAliasToAliasWithWeaklyConformantType { + type U = Double + type T = Int + implicit class D(d: U) { def double = d*2 } + + val x1: T = 1 + var x2: T = 2 + val x3 = (3: T) + var x4 = (4: T) + final val x5 = (5: T) + final var x6 = (6: T) + + def f1 = x1.double + def f2 = x2.double + def f3 = x3.double + def f4 = x4.double + def f5 = x5.double + def f6 = x6.double +} diff --git a/tests/pending/pos/t7232b/Foo.java b/tests/pending/pos/t7232b/Foo.java new file mode 100644 index 000000000..94f08d545 --- /dev/null +++ b/tests/pending/pos/t7232b/Foo.java @@ -0,0 +1,8 @@ +package pack; + +import java.util.*; + +public class Foo { + // should be pack.List. + public static List list() { throw new Error(); } +} diff --git a/tests/pending/pos/t7232b/List.java b/tests/pending/pos/t7232b/List.java new file mode 100644 index 000000000..ce977152b --- /dev/null +++ b/tests/pending/pos/t7232b/List.java @@ -0,0 +1,5 @@ +package pack; + +public class List { + public void packList() {} +} diff --git a/tests/pending/pos/t7232b/Test.scala b/tests/pending/pos/t7232b/Test.scala new file mode 100644 index 000000000..6377e26be --- /dev/null +++ b/tests/pending/pos/t7232b/Test.scala @@ -0,0 +1,5 @@ +object Test { + import pack._ + + Foo.list().packList() +} diff --git a/tests/pending/pos/t7239.scala b/tests/pending/pos/t7239.scala new file mode 100644 index 000000000..16e9d00f1 --- /dev/null +++ b/tests/pending/pos/t7239.scala @@ -0,0 +1,38 @@ +object Test { + def BrokenMethod(): HasFilter[(Int, String)] = ??? + + trait HasFilter[B] { + def filter(p: B => Boolean) = ??? + } + + trait HasWithFilter { + def withFilter = ??? + } + + object addWithFilter { + trait NoImplicit + implicit def enrich(v: Any) + (implicit F0: NoImplicit): HasWithFilter = ??? + } + + BrokenMethod().withFilter(_ => true) // okay + BrokenMethod().filter(_ => true) // okay + + locally { + import addWithFilter._ + BrokenMethod().withFilter((_: (Int, String)) => true) // okay + } + + locally { + import addWithFilter._ + // adaptToMemberWithArgs sets the type of the tree `x` + // to ErrorType (while in silent mode, so the error is not + // reported. Later, when the fallback from `withFilter` + // to `filter` is attempted, the closure is taken to have + // have the type `<error> => Boolean`, which conforms to + // `(B => Boolean)`. Only later during pickling does the + // defensive check for erroneous types in the tree pick up + // the problem. + BrokenMethod().withFilter(x => true) // erroneous or inaccessible type. + } +} diff --git a/tests/pending/pos/t7285a.flags b/tests/pending/pos/t7285a.flags new file mode 100644 index 000000000..e8fb65d50 --- /dev/null +++ b/tests/pending/pos/t7285a.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/t7285a.scala b/tests/pending/pos/t7285a.scala new file mode 100644 index 000000000..34e79c741 --- /dev/null +++ b/tests/pending/pos/t7285a.scala @@ -0,0 +1,83 @@ +sealed abstract class Base + +object Test { + case object Up extends Base + + def foo(d1: Base) = + d1 match { + case Up => + } + + // Sealed subtype: ModuleTypeRef <empty>.this.Test.Up.type + // Pattern: UniqueThisType Test.this.type +} + + +object Test1 { + sealed abstract class Base + + object Base { + case object Down extends Base { + } + + case object Up extends Base { + } + + (d1: Base, d2: Base) => + (d1, d2) match { + case (Up, Up) | (Down, Down) => false + case (Down, Up) => true + case (Up, Down) => false + } + } +} + +object Test2 { + sealed abstract class Base + + object Base { + case object Down extends Base { + } + + case object Up extends Base { + } + + (d1: Base, d2: Base) => + (d1) match { + case Up | Down => false + } + } +} + +object Test3 { + sealed abstract class Base + + object Base { + case object Down extends Base + + (d1: Base, d2: Base) => + (d1, d2) match { + case (Down, Down) => false + } + } +} + +object Test4 { + sealed abstract class Base + + object Base { + case object Down extends Base { + } + + case object Up extends Base { + } + + } + import Test4.Base._ + (d1: Base, d2: Base) => + (d1, d2) match { + case (Up, Up) | (Down, Down) => false + case (Down, Test4.Base.Up) => true + case (Up, Down) => false + } +} diff --git a/tests/pending/pos/t7294.scala b/tests/pending/pos/t7294.scala new file mode 100644 index 000000000..ccac2b140 --- /dev/null +++ b/tests/pending/pos/t7294.scala @@ -0,0 +1,6 @@ +object Test { + // no fruitless warning as Tuple2 isn't (yet) final. + // The corresponding `neg` test will treat it as final + // for the purposes of these tests under -Xfuture. + (1, 2) match { case Seq() => 0; case _ => 1 } +} diff --git a/tests/pending/pos/t7296.scala b/tests/pending/pos/t7296.scala new file mode 100644 index 000000000..0c078d365 --- /dev/null +++ b/tests/pending/pos/t7296.scala @@ -0,0 +1,6 @@ +object Test { + type A = Int + // Emits the implementation restriction but then proceeds to crash + // when creating the Foo.unapply. + case class Foo(a: A, b: A, c: A, d: A, e: A, f: A, g: A, h: A, i: A, j: A, k: A, l: A, m: A, n: A, o: A, p: A, q: A, r: A, s: A, t: A, u: A, v: A, w: A, x: A, y: A, Z: A) +} diff --git a/tests/pending/pos/t7377/Client_2.scala b/tests/pending/pos/t7377/Client_2.scala new file mode 100644 index 000000000..5728956cc --- /dev/null +++ b/tests/pending/pos/t7377/Client_2.scala @@ -0,0 +1,11 @@ +object Test { + M.noop(List(1) match { case Nil => 0; case (x::xs) => x }) + + case class Foo(a: Int) + val FooAlias: Foo.type = Foo + M.noop(Foo(0) match { case FooAlias(_) => 0 }) + + case class Bar() + val BarAlias: Bar.type = Bar + M.noop(Bar() match { case BarAlias() => 0 }) +} diff --git a/tests/pending/pos/t7377/Macro_1.scala b/tests/pending/pos/t7377/Macro_1.scala new file mode 100644 index 000000000..b38687c8b --- /dev/null +++ b/tests/pending/pos/t7377/Macro_1.scala @@ -0,0 +1,7 @@ +import language.experimental._ +import scala.reflect.macros.blackbox.Context + +object M { + def noopImpl[A](c: Context)(expr: c.Expr[A]): c.Expr[A] = c.Expr(c.typecheck(c.untypecheck(expr.tree))) + def noop[A](expr: A): A = macro noopImpl[A] +} diff --git a/tests/pending/pos/t7426.scala b/tests/pending/pos/t7426.scala new file mode 100644 index 000000000..8e42ad181 --- /dev/null +++ b/tests/pending/pos/t7426.scala @@ -0,0 +1,3 @@ +class foo(x: Any) extends annotation.StaticAnnotation + +@foo(new AnyRef { }) trait A diff --git a/tests/pending/pos/t7461/Macros_1.scala b/tests/pending/pos/t7461/Macros_1.scala new file mode 100644 index 000000000..74ebf5af9 --- /dev/null +++ b/tests/pending/pos/t7461/Macros_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.macros.blackbox.Context +import language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val wut = c.typecheck(Select(Literal(Constant(10)), newTermName("$minus")), silent = true) + // println(showRaw(wut, printIds = true, printTypes = true)) + c.Expr[Unit](q"()") + } + + def foo = macro impl +} diff --git a/tests/pending/pos/t7461/Test_2.scala b/tests/pending/pos/t7461/Test_2.scala new file mode 100644 index 000000000..866e3dc6f --- /dev/null +++ b/tests/pending/pos/t7461/Test_2.scala @@ -0,0 +1,3 @@ +class C { + def foo = Macros.foo +} diff --git a/tests/pending/pos/t7475a.scala b/tests/pending/pos/t7475a.scala new file mode 100644 index 000000000..810ce9a05 --- /dev/null +++ b/tests/pending/pos/t7475a.scala @@ -0,0 +1,11 @@ +trait AbstractPublic { + def queue: Any +} +trait ConcretePrivate { + private val queue: Any = () +} + +abstract class Mix + extends ConcretePrivate with AbstractPublic { + final def queue: Any = () +} diff --git a/tests/pending/pos/t7475b.scala b/tests/pending/pos/t7475b.scala new file mode 100644 index 000000000..a34743b8b --- /dev/null +++ b/tests/pending/pos/t7475b.scala @@ -0,0 +1,8 @@ +trait U { +} + +trait T { + type TT = Any with T with U + private val priv = 0 + (??? : TT).priv +} diff --git a/tests/pending/pos/t7505.scala b/tests/pending/pos/t7505.scala new file mode 100644 index 000000000..bc8c7fad6 --- /dev/null +++ b/tests/pending/pos/t7505.scala @@ -0,0 +1,16 @@ +import scala.language.reflectiveCalls + +case class ContextProperty(value: Any) { + type HasToInt = { def toInt:Int } + + def toInt: Int = value match { + case n: HasToInt => n.toInt + } +} + +// was: +// error:7: error during expansion of this match (this is a scalac bug). +// The underlying error was: type mismatch; +// found : Boolean(true) +// required: AnyRef +// def toInt: Int = value match { diff --git a/tests/pending/pos/t7516/A_1.scala b/tests/pending/pos/t7516/A_1.scala new file mode 100644 index 000000000..3bd477dcd --- /dev/null +++ b/tests/pending/pos/t7516/A_1.scala @@ -0,0 +1,9 @@ +import scala.reflect._,macros._, scala.language.experimental.macros + +object A { + def impl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = { + val r = c.universe.reify { List(t.splice) } + c.Expr[List[T]]( c.untypecheck(r.tree) ) + } + def demo[T](t: T): List[T] = macro impl[T] +} diff --git a/tests/pending/pos/t7516/B_2.scala b/tests/pending/pos/t7516/B_2.scala new file mode 100644 index 000000000..1b8531bc8 --- /dev/null +++ b/tests/pending/pos/t7516/B_2.scala @@ -0,0 +1,4 @@ +object B { + final case class CV(p: Int = 3, g: Int = 2) + A.demo { val d = 4; CV(g = d); "a" } +} diff --git a/tests/pending/pos/t7517.scala b/tests/pending/pos/t7517.scala new file mode 100644 index 000000000..df4f40130 --- /dev/null +++ b/tests/pending/pos/t7517.scala @@ -0,0 +1,22 @@ +trait Box[ K[A[x]] ] + +object Box { + // type constructor composition + sealed trait ∙[A[_], B[_]] { type l[T] = A[B[T]] } + + // composes type constructors inside K + type SplitBox[K[A[x]], B[x]] = Box[ ({ type l[A[x]] = K[ (A ∙ B)#l] })#l ] + + def split[ K[A[x]], B[x] ](base: Box[K]): SplitBox[K,B] = ??? + + class Composed[B[_], L[A[x]] ] { + val box: Box[L] = ??? + + type Split[ A[x] ] = L[ (A ∙ B)#l ] + val a: Box[Split] = Box.split(box) + + //Either of these work: + val a1: Box[Split] = Box.split[L,B](box) + val a2: Box[ ({ type l[A[x]] = L[ (A ∙ B)#l ] })#l ] = Box.split(box) + } +} diff --git a/tests/pending/pos/t7520.scala b/tests/pending/pos/t7520.scala new file mode 100644 index 000000000..747f5278e --- /dev/null +++ b/tests/pending/pos/t7520.scala @@ -0,0 +1,10 @@ +class A { + val x: Singleton with this.type = this + val y: this.type = x +} + +class B { + val x = "" + val xs: x.type with Singleton = x + val y: x.type = xs +} diff --git a/tests/pending/pos/t758.scala b/tests/pending/pos/t758.scala new file mode 100644 index 000000000..160bf3717 --- /dev/null +++ b/tests/pending/pos/t758.scala @@ -0,0 +1,7 @@ +trait A { type T; type M >: T } +trait B extends A { + val x : String; + val u : A { type T = B.this.T } ; + type T = x.type; + type M = u.M +} diff --git a/tests/pending/pos/t7591/Demo.scala b/tests/pending/pos/t7591/Demo.scala new file mode 100644 index 000000000..dd127b881 --- /dev/null +++ b/tests/pending/pos/t7591/Demo.scala @@ -0,0 +1,86 @@ +/* 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/pending/pos/t762.scala b/tests/pending/pos/t762.scala new file mode 100644 index 000000000..76860272e --- /dev/null +++ b/tests/pending/pos/t762.scala @@ -0,0 +1,2 @@ +trait Foo { type T } +trait Bar extends Foo { val x : Foo { type T <: Bar.this.T } = this : this.type } diff --git a/tests/pending/pos/t7649.flags b/tests/pending/pos/t7649.flags new file mode 100644 index 000000000..fcf951d90 --- /dev/null +++ b/tests/pending/pos/t7649.flags @@ -0,0 +1 @@ +-Yrangepos
\ No newline at end of file diff --git a/tests/pending/pos/t7649.scala b/tests/pending/pos/t7649.scala new file mode 100644 index 000000000..d70dc05ea --- /dev/null +++ b/tests/pending/pos/t7649.scala @@ -0,0 +1,20 @@ +object Test { + val c: scala.reflect.macros.blackbox.Context = ??? + import c.universe._ + reify { + // The lookup of the implicit WeakTypeTag[Any] + // was triggering an unpositioned tree. + c.Expr[Any](q"0").splice + } + + import scala.reflect.ClassTag + def ct[A: ClassTag]: Expr[A] = ??? + def tt[A: TypeTag]: Expr[A] = ??? + def wtt[A: WeakTypeTag]: Expr[A] = ??? + + reify { + ct[String].splice + tt[String].splice + wtt[String].splice + } +} diff --git a/tests/pending/pos/t7668.scala b/tests/pending/pos/t7668.scala new file mode 100644 index 000000000..222a13d03 --- /dev/null +++ b/tests/pending/pos/t7668.scala @@ -0,0 +1,12 @@ +trait Space { + type T + val x: T +} + +trait Extractor { + def extract(s: Space): s.T +} + +class Sub extends Extractor { + def extract(s: Space) = s.x +} diff --git a/tests/pending/pos/t767.scala b/tests/pending/pos/t767.scala new file mode 100644 index 000000000..c3da64f1e --- /dev/null +++ b/tests/pending/pos/t767.scala @@ -0,0 +1,18 @@ +abstract class AbsCell { + type T = Node + val init: T + private var value: T = init + def get: T = value + def set (x: T): Unit = { value = x } + + class Node { + val foo = 1 + } +} + +object inner { + def main(args: Array[String]): Unit = { + val cell = new AbsCell { val init = new Node() } + cell.set(new cell.type#T()) // nullpointer exception + } +} diff --git a/tests/pending/pos/t7688.scala b/tests/pending/pos/t7688.scala new file mode 100644 index 000000000..5a846b97e --- /dev/null +++ b/tests/pending/pos/t7688.scala @@ -0,0 +1,7 @@ +import scala.reflect.macros._ + +class A[C <: Context with Singleton](position: C#Position) + +object A { + def apply(c: Context)(in: c.Tree): A[c.type] = new A(in.pos) +} diff --git a/tests/pending/pos/t7776.check b/tests/pending/pos/t7776.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/t7776.check diff --git a/tests/pending/pos/t7776.scala b/tests/pending/pos/t7776.scala new file mode 100644 index 000000000..627d20dd6 --- /dev/null +++ b/tests/pending/pos/t7776.scala @@ -0,0 +1,20 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +class MacroErasure { + def app(f: Any => Any, x: Any): Any = macro MacroErasure.appMacro + def app[A](f: A => Any, x: Any): Any = macro MacroErasure.appMacroA[A] +} + +object MacroErasure { + def appMacro(c: Context)( + f: c.Expr[Any => Any], x: c.Expr[Any]): c.Expr[Any] = { + import c.universe._ + c.Expr(q"$f($x)") + } + def appMacroA[A](c: Context)(f: c.Expr[A => Any], x: c.Expr[Any])( + implicit tt: c.WeakTypeTag[A]): c.Expr[Any] = { + import c.universe._ + c.Expr(q"$f[${tt.tpe}]($x)") + } +} diff --git a/tests/pending/pos/t7782.scala b/tests/pending/pos/t7782.scala new file mode 100644 index 000000000..9b98f6ac6 --- /dev/null +++ b/tests/pending/pos/t7782.scala @@ -0,0 +1,25 @@ +package pack + +object Test { + import O.empty + empty // this will trigger completion of `test` + // with skolemizationLevel = 1 +} + +object O { + // order matters (!!!) + + // this order breaks under 2.10.x + def empty[E]: C[E] = ??? + def empty(implicit a: Any): Any = ??? +} + +abstract class C[E] { + def foo[BB](f: BB): Unit + def test[B](f: B): Any = foo(f) + // error: no type parameters for method foo: (<param> f: BB)scala.this.Unit exist so that it can be applied to arguments (B&1) + // --- because --- + // argument expression's type is not compatible with formal parameter type; + // found : B&1 + // required: ?BB +} diff --git a/tests/pending/pos/t7782b.scala b/tests/pending/pos/t7782b.scala new file mode 100644 index 000000000..5b1979ec1 --- /dev/null +++ b/tests/pending/pos/t7782b.scala @@ -0,0 +1,25 @@ +package pack + +object Test { + import O.empty + empty // this will trigger completion of `test` + // with skolemizationLevel = 1 +} + +object O { + // order matters (!!!) + + // this order breaks under 2.11.x + def empty(implicit a: Any): Any = ??? + def empty[E]: C[E] = ??? +} + +abstract class C[E] { + def foo[BB](f: BB): Unit + def test[B](f: B): Any = foo(f) + // error: no type parameters for method foo: (<param> f: BB)scala.this.Unit exist so that it can be applied to arguments (B&1) + // --- because --- + // argument expression's type is not compatible with formal parameter type; + // found : B&1 + // required: ?BB +} diff --git a/tests/pending/pos/t7785.scala b/tests/pending/pos/t7785.scala new file mode 100644 index 000000000..1de693d13 --- /dev/null +++ b/tests/pending/pos/t7785.scala @@ -0,0 +1,34 @@ +import scala.language._ + +trait R[+Repr] + +trait TraversableOps { + implicit val R: R[Nothing] = ??? + + // Removing the implicit parameter in both fixes the crash + // removing it into one only gives a valid compiler error. + trait OpsDup1[Repr] { + def force(implicit bf: R[Repr]): Any + } + + trait Ops[Repr] extends OpsDup1[Repr] { + def force(implicit bf: R[Repr], dummy: DummyImplicit): Any + } + + implicit def ct2ops[T, C[+X]](t: C[T]): + Ops[C[T]] + + def force[T](t: Option[T]) = + // ct2ops(t).force + t.force //Fails compilation on 2.10.2. + + + /* To get a closer look at the crash: + :power + val foo = typeOf[C].member(TermName("foo")) + val pt = analyzer.HasMember(TermName("force")) + val instantiated = foo.info.finalResultType.instantiateTypeParams(foo.typeParams, foo.typeParams.map(TypeVar(_))) + instantiated <:< pt + */ + def foo[T, C[+X]]: Ops[C[T]] +} diff --git a/tests/pending/pos/t7834.scala b/tests/pending/pos/t7834.scala new file mode 100644 index 000000000..fc9a0aa09 --- /dev/null +++ b/tests/pending/pos/t7834.scala @@ -0,0 +1,6 @@ +class S { val q = "" } + +class B extends S { + val x1: B.super.q.type = q + val x2: B.this.q.type = q +} diff --git a/tests/pending/pos/t7853.scala b/tests/pending/pos/t7853.scala new file mode 100644 index 000000000..b0e9221e2 --- /dev/null +++ b/tests/pending/pos/t7853.scala @@ -0,0 +1,11 @@ +trait S { + trait T { + this: Any => + + trait U { + trait V { + S.this + } + } + } +} diff --git a/tests/pending/pos/t788.scala b/tests/pending/pos/t788.scala new file mode 100644 index 000000000..19638dd17 --- /dev/null +++ b/tests/pending/pos/t788.scala @@ -0,0 +1,19 @@ +package test; + +trait Test { + type Node <: NodeImpl; + trait NodeImpl; + type Expression <: Node with ExpressionImpl; + trait ExpressionImpl extends NodeImpl { + def self : Expression; + } + type Named <: Node with NamedImpl; + trait NamedImpl extends NodeImpl { + def self : Named; + } + def asExpression(e : ExpressionImpl) : Named = { + e match { + case f : NamedImpl => f.self; + } + } +} diff --git a/tests/pending/pos/t7902.scala b/tests/pending/pos/t7902.scala new file mode 100644 index 000000000..47c525c17 --- /dev/null +++ b/tests/pending/pos/t7902.scala @@ -0,0 +1,17 @@ +import scala.language.higherKinds + +object Bug { + class Tag[W[M1[X1]]] + + def ofType[W[M2[X2]]]: Tag[W] = ??? + type InSeq [M3[X3]] = Some[M3[Any]] + + // fail + val x = ofType[InSeq] + + // okay + val y: Any = ofType[InSeq] + object T { + val z = ofType[InSeq] + } +} diff --git a/tests/pending/pos/t7919.scala b/tests/pending/pos/t7919.scala new file mode 100644 index 000000000..64f261ec1 --- /dev/null +++ b/tests/pending/pos/t7919.scala @@ -0,0 +1,6 @@ + +object X { + val x = s"" + val y = true +} + diff --git a/tests/pending/pos/t7928.scala b/tests/pending/pos/t7928.scala new file mode 100644 index 000000000..d9e29935b --- /dev/null +++ b/tests/pending/pos/t7928.scala @@ -0,0 +1,16 @@ +trait OuterTrait { + trait InnerTrait { + type Element + type Collection <: Iterable[Inner.Element] + } + + val Inner: InnerTrait + +} + +object OuterObject extends OuterTrait { + object Inner extends InnerTrait { + type Element = String + override type Collection = Seq[Inner.Element] + } +} diff --git a/tests/pending/pos/t796.scala b/tests/pending/pos/t796.scala new file mode 100644 index 000000000..066625179 --- /dev/null +++ b/tests/pending/pos/t796.scala @@ -0,0 +1,26 @@ +/** I know what I am doing is wrong -- since I am about to look into + * this bug, I add a test in pending/pos... however, I am afraid that + * once this bug is fixed, this test case might go into test/pos + * there it adds to the huge number of tiny little test cases. + * + * Ideally, an option in the bugtracking system would automatically + * handle "pos" bugs. + */ +object Test extends App { + + object Twice { + def apply(x: Int) = x * 2 + def unapply(x: Int): Option[Tuple1[Int]] = + if (x % 2 == 0) Some(Tuple1(x / 2)) + else None + } + + def test(x: Int) = x match { + case Twice(y) => "x is two times "+y + case _ => "x is odd" + } + + Console.println(test(3)) + Console.println(test(4)) + +} diff --git a/tests/pending/pos/t7983.scala b/tests/pending/pos/t7983.scala new file mode 100644 index 000000000..bae9f3333 --- /dev/null +++ b/tests/pending/pos/t7983.scala @@ -0,0 +1,31 @@ +package foo.bar.baz // the package nesting level material to this bug + +class DivergenceTest { + + trait ColumnBase[T] + + trait ShapeLevel + trait Flat extends ShapeLevel + trait Lower extends Flat + + class Shape2[Level <: ShapeLevel, -M, U] + + implicit final def columnBaseShape[Level >: Flat <: ShapeLevel, T, C <: ColumnBase[_]] + (implicit ev: C <:< ColumnBase[T] + ): Shape2[Level, C, T] = ??? + + implicit final def intShape[Level <: ShapeLevel, T]: Shape2[Level, Int, Int] = ??? + implicit final def tuple2Shape[Level <: ShapeLevel, M1,M2, U1,U2] + (implicit u1: Shape2[_ <: Level, M1, U1], + u2: Shape2[_ <: Level, M2, U2] + ): Shape2[Level, (M1,M2), (U1,U2)] = ??? + + def foo: Unit = { + class Coffees extends ColumnBase[Int] + + def map1[F, T](f: F)(implicit shape: Shape2[_ <: Flat, F, T]) = ??? + + map1(((1, null: Coffees), 1)) + map1(((null: Coffees, 1), 1)) // fails with implicit divergence error in 2.11.0-M6, works under 2.10.3 + } +} diff --git a/tests/pending/pos/t7987/Macro_1.scala b/tests/pending/pos/t7987/Macro_1.scala new file mode 100644 index 000000000..81f717b9c --- /dev/null +++ b/tests/pending/pos/t7987/Macro_1.scala @@ -0,0 +1,6 @@ +import scala.language.experimental._ + +object Macro { + def apply[A](a: A): A = macro impl[A] + def impl[A](c: reflect.macros.Context)(a: c.Expr[A]): c.Expr[A] = a +} diff --git a/tests/pending/pos/t7987/Test_2.scala b/tests/pending/pos/t7987/Test_2.scala new file mode 100644 index 000000000..5896fdb51 --- /dev/null +++ b/tests/pending/pos/t7987/Test_2.scala @@ -0,0 +1,12 @@ +class C[T] { + def foo = 0 +} + +object Test { + implicit def AnyToC[T](a: Any): C[T] = new C[T] + // was: "macro not expanded" + Macro { + "".foo + () + } +} diff --git a/tests/pending/pos/t8001/Macros_1.scala b/tests/pending/pos/t8001/Macros_1.scala new file mode 100644 index 000000000..077082a9c --- /dev/null +++ b/tests/pending/pos/t8001/Macros_1.scala @@ -0,0 +1,10 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def foo: Unit = macro impl + def impl(c: Context) = { + import c.universe._ + q"()" + } +} diff --git a/tests/pending/pos/t8001/Test_2.scala b/tests/pending/pos/t8001/Test_2.scala new file mode 100644 index 000000000..55024506e --- /dev/null +++ b/tests/pending/pos/t8001/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo + (): Unit +} diff --git a/tests/pending/pos/t8002-nested-scope.scala b/tests/pending/pos/t8002-nested-scope.scala new file mode 100644 index 000000000..a2088bce7 --- /dev/null +++ b/tests/pending/pos/t8002-nested-scope.scala @@ -0,0 +1,20 @@ +// This test serves to capture the status quo, but should really +// emit an accessibiltiy error. + +// `Namers#companionSymbolOf` seems too lenient, and currently doesn't +// implement the same-scope checks mentioned: +// +// https://github.com/scala/scala/pull/2816#issuecomment-22555206 +// +class C { + def foo = { + class C { private def x = 0 } + + { + val a = 0 + object C { + new C().x + } + } + } +} diff --git a/tests/pending/pos/t8011.scala b/tests/pending/pos/t8011.scala new file mode 100644 index 000000000..451590d77 --- /dev/null +++ b/tests/pending/pos/t8011.scala @@ -0,0 +1,8 @@ +class ThingOps1(val x: String) extends AnyVal { + def fn[A]: Any = { + new X[A] { def foo(a: A) = a } + 0 + } +} + +trait X[B] { def foo(a: B): Any } diff --git a/tests/pending/pos/t8013/inpervolated_2.scala b/tests/pending/pos/t8013/inpervolated_2.scala new file mode 100644 index 000000000..90e571b42 --- /dev/null +++ b/tests/pending/pos/t8013/inpervolated_2.scala @@ -0,0 +1,11 @@ +/* + * scalac: -Xfatal-warnings -Xlint + */ +package t8013 + +// unsuspecting user of perverse macro +trait User { + import Perverse.Impervolator + val foo = "bar" + Console println p"Hello, $foo" +} diff --git a/tests/pending/pos/t8013/inpervolator_1.scala b/tests/pending/pos/t8013/inpervolator_1.scala new file mode 100644 index 000000000..612e1d727 --- /dev/null +++ b/tests/pending/pos/t8013/inpervolator_1.scala @@ -0,0 +1,33 @@ + +package t8013 + +// perverse macro to confuse Xlint + +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Perverse { + + implicit class Impervolator(sc: StringContext) { + def p(args: Any*): String = macro pImpl + } + + // turn a nice interpolation into something that looks + // nothing like an interpolation or anything we might + // recognize, but which includes a "$id" in an apply. + def pImpl(c: Context)(args: c.Expr[Any]*): c.Expr[String] = { + import c.universe._ + val macroPos = c.macroApplication.pos + val text = macroPos.source.lineToString(macroPos.line - 1) substring macroPos.column + val tt = Literal(Constant(text)) + val tree = q"t8013.Perverse.pervert($tt)" + c.Expr[String](tree) + } + + // identity doesn't seem very perverse in this context + //def pervert(text: String): String = text + def pervert(text: String): String = { + Console println s"Perverting [$text]" + text + } +} diff --git a/tests/pending/pos/t802.scala b/tests/pending/pos/t802.scala new file mode 100644 index 000000000..2dea7036d --- /dev/null +++ b/tests/pending/pos/t802.scala @@ -0,0 +1,27 @@ +package test; +trait Test { + abstract class BracesImpl { + type Singleton; + type Brace <: Singleton with BraceImpl; + trait BraceImpl; + trait ForFile; + } + abstract class ParensImpl extends BracesImpl { + type Brace <: Singleton with BraceImpl; + trait BraceImpl extends super.BraceImpl; + } + val parens : ParensImpl; + abstract class BracksImpl extends BracesImpl { + type Brace <: Singleton with BraceImpl; + trait BraceImpl extends super.BraceImpl; + } + val bracks : BracksImpl; + trait File { + def parens0 : parens.BraceImpl; + def bracks0 : bracks.BraceImpl; + def braces(b : BracesImpl) = b match { + case b if b == parens => parens0; + case b if b == bracks => bracks0; + } + } +} diff --git a/tests/pending/pos/t8023.scala b/tests/pending/pos/t8023.scala new file mode 100644 index 000000000..86824084e --- /dev/null +++ b/tests/pending/pos/t8023.scala @@ -0,0 +1,22 @@ +import language._ + + +object Test { + def foo = (null: Any) match { + case a: A[k] => + // error: kinds of the type arguments (k) do not conform to the + // expected kinds of the type parameters (type K) in class B. + new B[k]() + } +} + +class A[K[L[_]]] + +class B[K[M[_]]] + + +object Test2 { + def foo = (null: Any) match { + case a: A[k] => new B[k]() // this one worked before as the info of `A` was complete + } +} diff --git a/tests/pending/pos/t8023b.scala b/tests/pending/pos/t8023b.scala new file mode 100644 index 000000000..94c9b2f8d --- /dev/null +++ b/tests/pending/pos/t8023b.scala @@ -0,0 +1,2 @@ +// this fails with naive attempts to fix SI-8023 +trait T[A <: T[A]] diff --git a/tests/pending/pos/t8045.scala b/tests/pending/pos/t8045.scala new file mode 100644 index 000000000..21154e386 --- /dev/null +++ b/tests/pending/pos/t8045.scala @@ -0,0 +1,17 @@ +object Test extends App { + case class Number(i: Int) + + object UnliftNumber { + def unapply(t: Any): Option[Number] = t match { + case i: Int => Some(Number(i)) + case _ => None + } + } + + def eval(expr: Any): Option[Number] = expr match { + case UnliftNumber(n) => Some(n) + case _ => None + } + + println(eval(1)) +} diff --git a/tests/pending/pos/t8046c.scala b/tests/pending/pos/t8046c.scala new file mode 100644 index 000000000..f05b4c15b --- /dev/null +++ b/tests/pending/pos/t8046c.scala @@ -0,0 +1,19 @@ +trait One { + type Op[A] + type Alias[A] = Op[A] +} + +trait Three extends One { + trait Op[A] extends (A => A) + + def f1(f: Op[Int]) = f(5) + def f2(f: Alias[Int]) = f(5) + def f3[T <: Op[Int]](f: T) = f(5) + def f4[T <: Alias[Int]](f: T) = f(5) + // ./a.scala:12: error: type mismatch; + // found : Int(5) + // required: T1 + // def f4[T <: Alias[Int]](f: T) = f(5) + // ^ +} + diff --git a/tests/pending/pos/t805.scala b/tests/pending/pos/t805.scala new file mode 100644 index 000000000..37bf6b5ef --- /dev/null +++ b/tests/pending/pos/t805.scala @@ -0,0 +1,19 @@ +trait MatcherYYY { + trait NodeImpl; + trait Matchable extends NodeImpl { + protected def doMatch : Unit = {} + } +} +trait BraceMatcherXXX extends MatcherYYY { + trait NodeImpl extends super.NodeImpl { + def doMatch (braces : BracePair) : Unit + } + trait BracePair { + trait BraceImpl extends NodeImpl with Matchable { + override def doMatch : Unit = { + super.doMatch; + (); + } + } + } +} diff --git a/tests/pending/pos/t8064/Client_2.scala b/tests/pending/pos/t8064/Client_2.scala new file mode 100644 index 000000000..42c9b21ce --- /dev/null +++ b/tests/pending/pos/t8064/Client_2.scala @@ -0,0 +1,8 @@ +object Test { + Macro { + def s = "" + Macro(s): @unchecked + ??? + } +} +// Was: a range position validation error (unpositioned tree) diff --git a/tests/pending/pos/t8064/Macro_1.scala b/tests/pending/pos/t8064/Macro_1.scala new file mode 100644 index 000000000..9f1e6955b --- /dev/null +++ b/tests/pending/pos/t8064/Macro_1.scala @@ -0,0 +1,10 @@ +import language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macro { + def apply(a: Any): Any = macro impl + + def impl(c: Context)(a: c.Tree): c.Tree = { + c.untypecheck(a) + } +} diff --git a/tests/pending/pos/t8064b/Client_2.scala b/tests/pending/pos/t8064b/Client_2.scala new file mode 100644 index 000000000..055b7a606 --- /dev/null +++ b/tests/pending/pos/t8064b/Client_2.scala @@ -0,0 +1,6 @@ +object Test { + Macro { + "".reverse + } +} +// Was: a range position validation error (tree with offset position enclosing tree with range position) diff --git a/tests/pending/pos/t8064b/Macro_1.scala b/tests/pending/pos/t8064b/Macro_1.scala new file mode 100644 index 000000000..60996bfec --- /dev/null +++ b/tests/pending/pos/t8064b/Macro_1.scala @@ -0,0 +1,11 @@ +import language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macro { + def apply(a: Any): Any = macro impl + def impl(c: Context)(a: c.Tree): c.Tree = { + import c.universe._ + + q"{$a; true}" + } +} diff --git a/tests/pending/pos/t807.scala b/tests/pending/pos/t807.scala new file mode 100644 index 000000000..0eeb92ea2 --- /dev/null +++ b/tests/pending/pos/t807.scala @@ -0,0 +1,45 @@ +trait Matcher { + trait Link { + type Self <: Link; + type Match <: Link { type Match = Link.this.Self; } + } + trait HasLinks { + def link(b : Boolean) : Link = null; + } + +} +trait BraceMatcher extends Matcher { + trait BracePair { + trait BraceLink extends Link; + trait OpenLink extends BraceLink { + type Self = OpenLink; + type Match = CloseLink; + } + trait CloseLink extends BraceLink { + type Self = CloseLink; + type Match = OpenLink; + } + } +} +trait IfElseMatcher extends BraceMatcher { + trait IfElseLink extends Link; + trait IfLink extends IfElseLink { + type Self = IfLink; + type Match = ElseImpl; + } + trait ElseImpl extends IfElseLink with HasLinks { + type Self = ElseImpl; + type Match = IfLink; + override def link(b : Boolean) = this; + } + val parenPair : BracePair; + trait IfWithParenImpl extends HasLinks { + object ifLink extends IfLink; + object openParen extends parenPair.OpenLink; + override def link(b : Boolean): Link = b match { + case true => ifLink; + case false => openParen; + } + } +} + diff --git a/tests/pending/pos/t8111.scala b/tests/pending/pos/t8111.scala new file mode 100644 index 000000000..7ec002c9b --- /dev/null +++ b/tests/pending/pos/t8111.scala @@ -0,0 +1,24 @@ +trait T { + + def crashy(ma: Any): Unit = { + // okay + val f1 = (u: Unit) => ma + foo(f1)() + foo((u: Unit) => ma) + foo(0, (u: Any) => ma) apply () + + // crash due to side effects on the onwer of the symbol in the + // qualifier or arguments of the application during an abandoned + // names/defaults transform. The code type checkes because of + // autp-tupling which promotes and empty parmater list to `(): Unit` + foo((u: Any) => ma)() + + {{(u: Any) => ma}; this}.foo(0)() + + foo({def foo = ma; 0})() + + {def foo = ma; this}.foo(0)() + } + + def foo(f: Any): Any => Any +} diff --git a/tests/pending/pos/t8128.scala b/tests/pending/pos/t8128.scala new file mode 100644 index 000000000..b6f76691b --- /dev/null +++ b/tests/pending/pos/t8128.scala @@ -0,0 +1,15 @@ +object G { + def unapply(m: Any): Option[_] = Some("") +} + +object H { + def unapplySeq(m: Any): Option[Seq[_]] = None +} + +object Test { + (0: Any) match { + case G(v) => v + case H(v) => v + case _ => + } +} diff --git a/tests/pending/pos/t8134/A_1.scala b/tests/pending/pos/t8134/A_1.scala new file mode 100644 index 000000000..32bce003f --- /dev/null +++ b/tests/pending/pos/t8134/A_1.scala @@ -0,0 +1,4 @@ +// a.scala +package object pkg { + class AnyOps(val x: Any) extends AnyVal +} diff --git a/tests/pending/pos/t8134/B_2.scala b/tests/pending/pos/t8134/B_2.scala new file mode 100644 index 000000000..32bce003f --- /dev/null +++ b/tests/pending/pos/t8134/B_2.scala @@ -0,0 +1,4 @@ +// a.scala +package object pkg { + class AnyOps(val x: Any) extends AnyVal +} diff --git a/tests/pending/pos/t8146a.scala b/tests/pending/pos/t8146a.scala new file mode 100644 index 000000000..e4eb8d3fd --- /dev/null +++ b/tests/pending/pos/t8146a.scala @@ -0,0 +1,9 @@ +trait M[+A] + +object Test { + type Inty = Int + def t1( + x: M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[Int @unchecked]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] + ): M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[Inty @unchecked]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] + = x +} diff --git a/tests/pending/pos/t8146b.scala b/tests/pending/pos/t8146b.scala new file mode 100644 index 000000000..1a65ed518 --- /dev/null +++ b/tests/pending/pos/t8146b.scala @@ -0,0 +1,77 @@ +// non-deterministic type errors, non-termination. +// seems to be due to inconsistent hashing/equality in SubTypePair + +import scala.language.{existentials, implicitConversions} +import scala.annotation.unchecked.uncheckedVariance + +trait Column[T] + +// Turning this into a trait reduces (eliminates?) the likelihood of type errors (but not of non-termination) +abstract class Shape[Level <: ShapeLevel, -Mixed_, Unpacked_, Packed_] + +trait ShapeLevel +trait NestedShapeLevel extends ShapeLevel +trait FlatShapeLevel extends NestedShapeLevel +trait ColumnsShapeLevel extends FlatShapeLevel + +trait ProvenShape[U] + +object ProvenShape { + implicit def proveShapeOf[T, U](v: T)(implicit sh: Shape[_ <: FlatShapeLevel, T, U, _]): ProvenShape[U] = ??? +} + +sealed abstract class HList { + type Self <: HList + type :: [E] = HCons[E, Self] + final def :: [E](elem: E): :: [E] = ??? +} + +final class HCons[+H, +T <: HList](val head: H, val tail: T) extends HList { + type Self = HCons[H @uncheckedVariance, T @uncheckedVariance] +} + +final object HNil extends HList { + type Self = HNil.type +} + +// Success is more likely when not using these aliases +object syntax { + type :: [+H, +T <: HList] = HCons[H, T] + type HNil = HNil.type +} + +class HListBench { + + import syntax._ + + implicit def columnShape[T, Level <: ShapeLevel]: Shape[Level, Column[T], T, Column[T]] = ??? + implicit def provenShape[T, P](implicit shape: Shape[_ <: FlatShapeLevel, T, _, P]): Shape[FlatShapeLevel, ProvenShape[T], T, P] = ??? + final class HListShape[Level <: ShapeLevel, M <: HList, U <: HList, P <: HList](val shapes: Seq[Shape[_ <: ShapeLevel, _, _, _]]) extends Shape[Level, M, U, P] + implicit def hnilShape[Level <: ShapeLevel]: HListBench.this.HListShape[Level,HNil.type,HNil.type,HNil.type] = new HListShape[Level, HNil.type, HNil.type, HNil.type](Nil) + implicit def hconsShape[Level <: ShapeLevel, M1, M2 <: HList, U1, U2 <: HList, P1, P2 <: HList] + (implicit s1: Shape[_ <: Level, M1, U1, P1], s2: HListShape[_ <: Level, M2, U2, P2]): HListBench.this.HListShape[Level,syntax.::[M1,M2],syntax.::[U1,U2],syntax.::[P1,P2]] = + new HListShape[Level, M1 :: M2, U1 :: U2, P1 :: P2](s1 +: s2.shapes) + + trait A[T] { + def * : ProvenShape[T] + } + + trait B extends A[ + Int :: Int :: Int :: Int :: Int :: + Int :: Int :: Int :: Int :: Int :: + Int :: Int :: Int :: Int :: Int :: + Int :: Int :: Int :: Int :: Int :: + Int :: Int :: Int :: Int :: Int :: + Int :: Int :: HNil ] { + + def c: Column[Int] + + def * = c :: c :: c :: c :: c :: + c :: c :: c :: c :: c :: + c :: c :: c :: c :: c :: + c :: c :: c :: c :: c :: + c :: c :: c :: c :: c :: + c :: c :: HNil + + } +} diff --git a/tests/pending/pos/t8177a.scala b/tests/pending/pos/t8177a.scala new file mode 100644 index 000000000..7e2cfb386 --- /dev/null +++ b/tests/pending/pos/t8177a.scala @@ -0,0 +1,9 @@ +// exercise coevolveSym +trait Thing { type A; var p: A = _ } +class AA[T](final val x: Thing { type A = T }) { + def foo: x.A = ??? +} + +class B extends AA[Int](null) { + override def foo: B.this.x.A = super.foo +} diff --git a/tests/pending/pos/t8187.check b/tests/pending/pos/t8187.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/t8187.check diff --git a/tests/pending/pos/t8187.scala b/tests/pending/pos/t8187.scala new file mode 100644 index 000000000..84b8cd0f4 --- /dev/null +++ b/tests/pending/pos/t8187.scala @@ -0,0 +1,6 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + val tyn: TypeName = (??? : TypeSymbol).name + val ten: TermName = (??? : TermSymbol).name +} diff --git a/tests/pending/pos/t8209a/Macros_1.scala b/tests/pending/pos/t8209a/Macros_1.scala new file mode 100644 index 000000000..5d7852cb7 --- /dev/null +++ b/tests/pending/pos/t8209a/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.language.experimental.macros +import scala.language.implicitConversions +import scala.reflect.macros.blackbox.Context + +class A +object A { implicit def a2b(a: A): B = ??? } +class B +class C extends A + +object Macros { + def impl(c: Context) = { + import c.universe._ + q"new C" + } + + def foo: A = macro impl +} diff --git a/tests/pending/pos/t8209a/Test_2.scala b/tests/pending/pos/t8209a/Test_2.scala new file mode 100644 index 000000000..bedef776f --- /dev/null +++ b/tests/pending/pos/t8209a/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val a: A = Macros.foo + val b: B = Macros.foo +} diff --git a/tests/pending/pos/t8209b/Macros_1.scala b/tests/pending/pos/t8209b/Macros_1.scala new file mode 100644 index 000000000..fa521d38d --- /dev/null +++ b/tests/pending/pos/t8209b/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.language.experimental.macros +import scala.language.implicitConversions +import scala.reflect.macros.whitebox.Context + +class A +object A { implicit def a2b(a: A): B = ??? } +class B +class C extends A + +object Macros { + def impl(c: Context) = { + import c.universe._ + q"new C" + } + + def foo: A = macro impl +} diff --git a/tests/pending/pos/t8209b/Test_2.scala b/tests/pending/pos/t8209b/Test_2.scala new file mode 100644 index 000000000..bedef776f --- /dev/null +++ b/tests/pending/pos/t8209b/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val a: A = Macros.foo + val b: B = Macros.foo +} diff --git a/tests/pending/pos/t8219.scala b/tests/pending/pos/t8219.scala new file mode 100644 index 000000000..e1653b623 --- /dev/null +++ b/tests/pending/pos/t8219.scala @@ -0,0 +1,15 @@ +trait Equalizer[T] +trait Gen[A] + +class Broken { + implicit def const[T](x: T): Gen[T] = ??? + implicit def convertToEqualizer[T](left: T): Equalizer[T] = ??? + + def in(a: Any) = () + in { + import scala.None // any import will do.. + "" == "" // this no longer triggers the bug, as Object#== now overrides Any#== + } + + // We can still trigger the bug with a structural type, see pending/neg/t8219.scala +} diff --git a/tests/pending/pos/t8219b.scala b/tests/pending/pos/t8219b.scala new file mode 100644 index 000000000..b820447ce --- /dev/null +++ b/tests/pending/pos/t8219b.scala @@ -0,0 +1,49 @@ +trait Equalizer[T] +trait Gen[A] + +class Broken { + implicit def const[T](x: T): Gen[T] = ??? + implicit def convertToEqualizer[T](left: T): Equalizer[T] = ??? + + def in(a: Any) = () + in { + import scala.None // any import will do.. + "" == "" // no longer a problem, see pos/t8129.scala + } + + // We used to fall into the errant code path above when `Any#==` and `AnyRef#==` + // were overloaded. + // + // Real classes couldn't get away with that overloading; it would result in + // a compiler error because the variants would collapse into an overriding + // relationship after erasure. + // + // + // But, a structural type can! This triggers the same error, and served as + // a backstop for this test if we change the signatures of `AnyRef#==` to + // override `Any#==`. + type T = { + def a(a: AnyRef): Boolean + def a(a: Any): Boolean + } + + def t: T = ??? + + in { + import scala.None // any import will do.. + t.a("") + } + + // Or, we can get here with ambiguous implicits from the formal parameter + // type of the less specific overload to that of the more specific. + object T { + def foo(a: Any) = true + def foo(a: String) = true + } + in { + import scala.None + implicit def any2str1(a: Any): String = "" + implicit def any2str2(a: Any): String = "" + T.foo("") + } +} diff --git a/tests/pending/pos/t8224.scala b/tests/pending/pos/t8224.scala new file mode 100644 index 000000000..2fae925df --- /dev/null +++ b/tests/pending/pos/t8224.scala @@ -0,0 +1,12 @@ +import language.higherKinds + +trait P [N1, +E1[X <: N1]] +trait PIn[N2, +E2[X <: N2]] extends P[Int,Any] + +trait EI extends PIn[Int, Nothing] +trait NI extends PIn[Int, Nothing] + +object Test { + val lub = if (true) ??? : EI else ??? : NI + val pin: PIn[Int,Nothing] = lub +} diff --git a/tests/pending/pos/t8237b.scala b/tests/pending/pos/t8237b.scala new file mode 100644 index 000000000..52bb310e8 --- /dev/null +++ b/tests/pending/pos/t8237b.scala @@ -0,0 +1,10 @@ +import scala.language.higherKinds +import scala.reflect.runtime.universe._ +object Test { + + def fTt[A,E[X]<:List[X]](a: A)(implicit tt: TypeTag[E[A]]) = a + + trait TC[A] + implicit def TCListInt[A]: TC[A] = ??? + fTt(1) +} diff --git a/tests/pending/pos/t8300-patmat-a.scala b/tests/pending/pos/t8300-patmat-a.scala new file mode 100644 index 000000000..ab3a3c960 --- /dev/null +++ b/tests/pending/pos/t8300-patmat-a.scala @@ -0,0 +1,20 @@ +// cf. pos/t8300-patmat-b.scala +trait Universe { + type Name >: Null <: AnyRef with NameApi + trait NameApi + + type TermName >: Null <: Name with TermNameApi + trait TermNameApi extends NameApi +} + +object Test extends App { + val u: Universe = ??? + import u._ + + locally { + val ScalaName: TermName = ??? + ??? match { + case ScalaName => ??? + } + } +} diff --git a/tests/pending/pos/t8300-patmat-b.scala b/tests/pending/pos/t8300-patmat-b.scala new file mode 100644 index 000000000..0acad4406 --- /dev/null +++ b/tests/pending/pos/t8300-patmat-b.scala @@ -0,0 +1,20 @@ +// cf. pos/t8300-patmat-a.scala +trait Universe { + type Name >: Null <: AnyRef with NameApi + trait NameApi + + type TermName >: Null <: TermNameApi with Name + trait TermNameApi extends NameApi +} + +object Test extends App { + val u: Universe = ??? + import u._ + + locally { + val ScalaName: TermName = ??? + ??? match { + case ScalaName => ??? + } + } +} diff --git a/tests/pending/pos/t8301b.scala b/tests/pending/pos/t8301b.scala new file mode 100644 index 000000000..5641547c1 --- /dev/null +++ b/tests/pending/pos/t8301b.scala @@ -0,0 +1,36 @@ +// cf. pos/t8300-patmat.scala +trait Universe { + type Name >: Null <: AnyRef with NameApi + trait NameApi + + type TermName >: Null <: TermNameApi with Name + trait TermNameApi extends NameApi +} + +object Test extends App { + val u: Universe = ??? + import u._ + + val ScalaName: TermName = ??? + locally { + + ??? match { + case Test.ScalaName => ??? + } + import Test.ScalaName._ + + ??? match { + case ScalaName => ??? + } + import ScalaName._ + + // both the pattern and import led to + // stable identifier required, but SN found. Note that value SN + // is not stable because its type, Test.u.TermName, is volatile. + val SN = ScalaName + ??? match { + case SN => ??? + } + import SN._ + } +} diff --git a/tests/pending/pos/t8352/Macros_1.scala b/tests/pending/pos/t8352/Macros_1.scala new file mode 100644 index 000000000..c1c63e57b --- /dev/null +++ b/tests/pending/pos/t8352/Macros_1.scala @@ -0,0 +1,7 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +object Macros { + def impl(c: Context)(x: c.Expr[Boolean]): c.Expr[Boolean] = x + def foo(x: Boolean): Boolean = macro impl +} diff --git a/tests/pending/pos/t8352/Test_2.scala b/tests/pending/pos/t8352/Test_2.scala new file mode 100644 index 000000000..1f84c3ca1 --- /dev/null +++ b/tests/pending/pos/t8352/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + def expectUnit(): Unit = { + Macros.foo(true) + } +} diff --git a/tests/pending/pos/t8364.check b/tests/pending/pos/t8364.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/t8364.check diff --git a/tests/pending/pos/t8364.scala b/tests/pending/pos/t8364.scala new file mode 100644 index 000000000..7a7ea1ff1 --- /dev/null +++ b/tests/pending/pos/t8364.scala @@ -0,0 +1,12 @@ +import scala.language.dynamics + +object MyDynamic extends Dynamic { + def selectDynamic(name: String): Any = ??? +} + +object Test extends App { + locally { + import java.lang.String + MyDynamic.id + } +} diff --git a/tests/pending/pos/t8367.scala b/tests/pending/pos/t8367.scala new file mode 100644 index 000000000..9ac2ce7c2 --- /dev/null +++ b/tests/pending/pos/t8367.scala @@ -0,0 +1,11 @@ +package java.lang + +// SI-8367 shows something is wrong with primaryConstructor and it was made worse with the fix for SI-8192 +// perhaps primaryConstructor should not return NoSymbol when isJavaDefined +// or, perhaps isJavaDefined should be refined (the package definition above is pretty sneaky) +// also, why does this only happen for a (scala-defined!) class with this special name? +// (there are a couple of others: CloneNotSupportedException,InterruptedException) +class Throwable + +// class CloneNotSupportedException +// class InterruptedException diff --git a/tests/pending/pos/t8369a.check b/tests/pending/pos/t8369a.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/pending/pos/t8369a.check diff --git a/tests/pending/pos/t8369a.scala b/tests/pending/pos/t8369a.scala new file mode 100644 index 000000000..13046007f --- /dev/null +++ b/tests/pending/pos/t8369a.scala @@ -0,0 +1,5 @@ +object Bug { + trait Sys[S] + def test[S <: Sys[S]] = read[S]() + def read[S <: Sys[S]](baz: Any = 0): Some[S] = ??? +} diff --git a/tests/pending/pos/t873.scala b/tests/pending/pos/t873.scala new file mode 100644 index 000000000..b8c50afd3 --- /dev/null +++ b/tests/pending/pos/t873.scala @@ -0,0 +1,10 @@ +abstract class Foo { + + val x:Option[List[String]] + val y:List[Int] + + val z = (0:Any) match { + case 1 => x + case 2 => y + } +} diff --git a/tests/pending/pos/t911.scala b/tests/pending/pos/t911.scala new file mode 100644 index 000000000..cfa4f49dc --- /dev/null +++ b/tests/pending/pos/t911.scala @@ -0,0 +1,6 @@ +object Test { + def foo: Any = { + case class Foo() {} + Foo; + } +} diff --git a/tests/pending/pos/tcpoly_bounds1.scala b/tests/pending/pos/tcpoly_bounds1.scala new file mode 100644 index 000000000..63263cb15 --- /dev/null +++ b/tests/pending/pos/tcpoly_bounds1.scala @@ -0,0 +1,14 @@ +class Foo[t[x]<: Tuple2[Int, x]] + +// +class MyPair[z](a: Int, b: z) extends Tuple2[Int, z](a,b) + +object foo extends Foo[MyPair] + + +trait Monad[m[x <: Bound[x]], Bound[x], a] // TODO: variances! +trait ListMonad[a] extends Monad[List, Any, a] + +trait MyOrdered[a] +trait MySet[x <: MyOrdered[x]] +trait SetMonad[a <: MyOrdered[a]] extends Monad[MySet, MyOrdered, a] diff --git a/tests/pending/pos/tcpoly_infer_ticket1864.scala b/tests/pending/pos/tcpoly_infer_ticket1864.scala new file mode 100644 index 000000000..4b7c7a223 --- /dev/null +++ b/tests/pending/pos/tcpoly_infer_ticket1864.scala @@ -0,0 +1,51 @@ +import scala.collection.mutable.{Buffer, ArrayBuffer} + +class RichBuffer[T, B[U] <: Buffer[U]](buffer: Buffer[T]) { + def mymap[S](f: T => S)(implicit rv: B[S]): B[S] = { + buffer.foreach{ e => + rv += f(e) + } + rv + } +} + +object App { + def mymap2[T, B[U] <: Buffer[U], S](buffer: B[T], f: T => S)(implicit rv: B[S]): B[S] = { + buffer.foreach{ e => + rv += f(e) + } + rv + } + + def mymap3[T, B <: Buffer[T], S](buffer: B, f: T => T)(implicit rv: B): B = { + buffer.foreach{ e => + rv += f(e) + } + rv + } + + def mymap4[T, B[U] <: Buffer[U], S](buffer: B[T])(f: T => S) (implicit rv: B[S]): B[S] = { + buffer.foreach{ e => + rv += f(e) + } + rv + } + + + def main(args: Array[String]): Unit = { + implicit def richBuffer[T, B[U] <: Buffer[U]](buffer: B[T]): RichBuffer[T, B] = + new RichBuffer[T, B](buffer) + + implicit val rv: scala.collection.mutable.ArrayBuffer[Int] = new ArrayBuffer[Int] + val buf = new ArrayBuffer[Int] + (1 to 5).foreach(buf += _) + buf.mymap(x => x*x) + richBuffer(buf).mymap[Int](x => x*x) + richBuffer[Int, ArrayBuffer](buf).mymap[Int](x => x*x) + mymap2(buf, (x: Int) => x*x) + mymap2[Int, ArrayBuffer, Int](buf, (x: Int) => x*x) + // mymap3(buf, x => x*x) // compiler error + mymap3(buf, (x: Int) => x*x) + mymap4(buf)(x => x*x) + } +} diff --git a/tests/pending/pos/tcpoly_infer_ticket474.scala b/tests/pending/pos/tcpoly_infer_ticket474.scala new file mode 100644 index 000000000..9012deb2b --- /dev/null +++ b/tests/pending/pos/tcpoly_infer_ticket474.scala @@ -0,0 +1,27 @@ +trait Builder[C[_], T] { + def +=(x: T): Unit + def finalise: C[T] +} + +trait Buildable[C[_]] { + def builder[T]: Builder[C,T] +} + +object Test { + + implicit object buildableList extends Buildable[List] { + def builder[T] = new Builder[List,T] { + val buf = new scala.collection.mutable.ListBuffer[T] + def +=(x: T) = buf += x + def finalise = buf.toList + } + } + + def foo[C[_],T](x: T)(implicit b: Buildable[C]): C[T] = { + val builder = b.builder[T] + builder += x + builder.finalise + } + + val l: List[Int] = foo(8) +} diff --git a/tests/pending/pos/tcpoly_overloaded.scala b/tests/pending/pos/tcpoly_overloaded.scala new file mode 100644 index 000000000..4f6334685 --- /dev/null +++ b/tests/pending/pos/tcpoly_overloaded.scala @@ -0,0 +1,25 @@ +trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] + (f: T => Result[S]): Result[S] + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] + (f: T => Result[S], foo: String): Result[S] + def flatMap[S <: Bound[S]] + (f: T => MyType[S], foo: Int): MyType[S] +} + +trait Test { + def moo: MList[Int] + class MList[T](el: T) extends Monad[T, List, Any] { + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] + (f: T => Result[S]): Result[S] = sys.error("foo") + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] + (f: T => Result[S], foo: String): Result[S] = sys.error("foo") + def flatMap[S] + (f: T => List[S], foo: Int): List[S] = sys.error("foo") + } + val l: MList[String] = moo.flatMap[String, List, Any, MList]((x: Int) => new MList("String")) +} diff --git a/tests/pending/pos/tcpoly_seq.scala b/tests/pending/pos/tcpoly_seq.scala new file mode 100644 index 000000000..731fe048a --- /dev/null +++ b/tests/pending/pos/tcpoly_seq.scala @@ -0,0 +1,175 @@ +package examples.tcpoly.collection; + +trait HOSeq { + // an internal interface that encapsulates the accumulation of elements (of type elT) to produce + // a structure of type coll[elT] -- different kinds of collections should provide different implicit + // values implementing this interface, in order to provide more performant ways of building that structure + trait Accumulator[+coll[x], elT] { + def += (el: elT): Unit + def result: coll[elT] + } + + + // Iterable abstracts over the type of its structure as well as its elements (see PolyP's Bifunctor) + // m[x] is intentionally unbounded: fold can then be defined nicely + // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type + // is an invariant position -- should probably rule that out? + trait Iterable[+m[+x], +t] { + //def unit[a](orig: a): m[a] + def iterator: Iterator[t] + + // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t + def accumulator[t]: Accumulator[m, t] + + def filter(p: t => Boolean): m[t] = { + val buf = accumulator[t] + val elems = iterator + while (elems.hasNext) { val x = elems.next; if (p(x)) buf += x } + buf.result + } + + def map[s](f: t => s): m[s] = { + val buf = accumulator[s] + val elems = iterator + while (elems.hasNext) buf += f(elems.next) + buf.result + } + + // flatMap is a more specialized map, it only works if the mapped function produces Iterable values, + // which are then added to the result one by one + // the compiler should be able to find the right accumulator (implicit buf) to build the result + // to get concat, resColl = SingletonIterable, f = unit for SingletonIterable + def flatMap[resColl[+x] <: Iterable[resColl, x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { + // TODO: would a viewbound for resColl[x] be better? + // -- 2nd-order type params are not yet in scope in view bound + val elems = iterator + while (elems.hasNext) { + val elemss: Iterator[s] = f(elems.next).iterator + while (elemss.hasNext) buf += elemss.next + } + buf.result + } + } + + final class ListBuffer[A] { + private var start: List[A] = Nil + private var last: ::[A] = _ + private var exported: Boolean = false + + /** Appends a single element to this buffer. + * + * @param x the element to append. + */ + def += (x: A): Unit = { + if (exported) copy + if (start.isEmpty) { + last = new HOSeq.this.:: (x, Nil) + start = last + } else { + val last1 = last + last = new HOSeq.this.:: (x, null) // hack: ::'s tail will actually be last + //last1.tl = last + } + } + + /** Converts this buffer to a list + */ + def toList: List[A] = { + exported = !start.isEmpty + start + } + + /** Clears the buffer contents. + */ + def clear: Unit = { + start = Nil + exported = false + } + + /** Copy contents of this buffer */ + private def copy: Unit = { + var cursor = start + val limit = last.tail + clear + while (cursor ne limit) { + this += cursor.head + cursor = cursor.tail + } + } + } + + implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] { + private[this] val buff = new ListBuffer[elT] + def += (el: elT): Unit = buff += el + def result: List[elT] = buff.toList + } + + trait List[+t] extends Iterable[List, t] { + def head: t + def tail: List[t] + def isEmpty: Boolean + def iterator: Iterator[t] = new Iterator[t] { + var these = List.this + def hasNext: Boolean = !these.isEmpty + def next: t = + if (!hasNext) + throw new NoSuchElementException("next on empty Iterator") + else { + val result = these.head; these = these.tail; result + } + } + // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t + def accumulator[t]: Accumulator[List, t] = listAccumulator[t] + } + + // TODO: the var tl approach does not seem to work because subtyping isn't fully working yet + final case class ::[+b](hd: b, private val tl: List[b]) extends List[b] { + def head = hd + def tail = if(tl==null) this else tl // hack + override def isEmpty: Boolean = false + } + + case object Nil extends List[Nothing] { + def isEmpty = true + def head: Nothing = + throw new NoSuchElementException("head of empty list") + def tail: List[Nothing] = + throw new NoSuchElementException("tail of empty list") + } +} + + + +// misc signatures collected from mailing list / library code: + /*override def flatMap[B](f: A => Iterable[B]): Set[B] + final override def flatMap[b](f: Any => Iterable[b]): Array[b] + def flatMap[b](f: a => Parser[b]) = new Parser[b] + override def flatMap[b](f: a => Iterable[b]): List[b] + + + MapResult[K] <: Seq[K] + FilterResult <: Seq[T] + Concat <: Seq[T] + Subseq <: Seq[T] + + + def map[K](f: T=>K): MapResult[K] + def filter(f: T=>Boolean): FilterResult + def subseq(from: Int, to: Int): Subseq + def flatMap[S <: Seq[K], K](f: T => S): S#Concat // legal? + def concat(others: Seq[T]): Concat + */ + +/*trait Iterator[t] { + // @post hasAdvanced implies hasNext + // model def hasAdvanced: Boolean + + def hasNext: Boolean // pure + + // @pre hasAdvanced + def current: t // pure + + // @pre hasNext + // @post hasAdvanced + def advance: Unit +}*/ diff --git a/tests/pending/pos/tcpoly_seq_typealias.scala b/tests/pending/pos/tcpoly_seq_typealias.scala new file mode 100644 index 000000000..8d2f6e7c3 --- /dev/null +++ b/tests/pending/pos/tcpoly_seq_typealias.scala @@ -0,0 +1,143 @@ +package examples.tcpoly.collection + +trait HOSeq { + // an internal interface that encapsulates the accumulation of elements (of type elT) to produce + // a structure of type coll[elT] -- different kinds of collections should provide different implicit + // values implementing this interface, in order to provide more performant ways of building that structure + trait Accumulator[+coll[x], elT] { + def += (el: elT): Unit + def result: coll[elT] + } + + + // Iterable abstracts over the type of its structure as well as its elements (see PolyP's Bifunctor) + // m[x] is intentionally unbounded: fold can then be defined nicely + // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type + // is an invariant position -- should probably rule that out? + trait Iterable[+t] { + type m[+x] + + //def unit[a](orig: a): m[a] + def iterator: Iterator[t] + + // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t + def accumulator[t]: Accumulator[m, t] + + def filter(p: t => Boolean): m[t] = { + val buf = accumulator[t] + val elems = iterator + while (elems.hasNext) { val x = elems.next; if (p(x)) buf += x } + buf.result + } + + def map[s](f: t => s): m[s] = { + val buf = accumulator[s] + val elems = iterator + while (elems.hasNext) buf += f(elems.next) + buf.result + } + + // flatMap is a more specialized map, it only works if the mapped function produces Iterable values, + // which are then added to the result one by one + // the compiler should be able to find the right accumulator (implicit buf) to build the result + // to get concat, resColl = SingletonIterable, f = unit for SingletonIterable + def flatMap[resColl[+x] <: Iterable[x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { + // TODO: would a viewbound for resColl[x] be better? + // -- 2nd-order type params are not yet in scope in view bound + val elems = iterator + while (elems.hasNext) { + val elemss: Iterator[s] = f(elems.next).iterator + while (elemss.hasNext) buf += elemss.next + } + buf.result + } + } + + final class ListBuffer[A] { + private var start: List[A] = Nil + private var last: ::[A] = _ + private var exported: Boolean = false + + /** Appends a single element to this buffer. + * + * @param x the element to append. + */ + def += (x: A): Unit = { + if (exported) copy + if (start.isEmpty) { + last = new HOSeq.this.:: (x, Nil) + start = last + } else { + val last1 = last + last = new HOSeq.this.:: (x, null) // hack: ::'s tail will actually be last + //last1.tl = last + } + } + + /** Converts this buffer to a list + */ + def toList: List[A] = { + exported = !start.isEmpty + start + } + + /** Clears the buffer contents. + */ + def clear: Unit = { + start = Nil + exported = false + } + + /** Copy contents of this buffer */ + private def copy: Unit = { + var cursor = start + val limit = last.tail + clear + while (cursor ne limit) { + this += cursor.head + cursor = cursor.tail + } + } + } + + implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] { + private[this] val buff = new ListBuffer[elT] + def += (el: elT): Unit = buff += el + def result: List[elT] = buff.toList + } + + trait List[+t] extends Iterable[t] { + type m[+x] = List[x] + + def head: t + def tail: List[t] + def isEmpty: Boolean + def iterator: Iterator[t] = new Iterator[t] { + var these = List.this + def hasNext: Boolean = !these.isEmpty + def next: t = + if (!hasNext) + throw new NoSuchElementException("next on empty Iterator") + else { + val result = these.head; these = these.tail; result + } + } + // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t + def accumulator[t]: Accumulator[List, t] = listAccumulator[t] + } + + // TODO: the var tl approach does not seem to work because subtyping isn't fully working yet + final case class ::[+b](hd: b, private val tl: List[b]) extends List[b] { + def head = hd + def tail = if(tl==null) this else tl // hack + override def isEmpty: Boolean = false + } + + case object Nil extends List[Nothing] { + def isEmpty = true + def head: Nothing = + throw new NoSuchElementException("head of empty list") + def tail: List[Nothing] = + throw new NoSuchElementException("tail of empty list") + } +} diff --git a/tests/pending/pos/tcpoly_ticket2096.scala b/tests/pending/pos/tcpoly_ticket2096.scala new file mode 100644 index 000000000..d2387b36b --- /dev/null +++ b/tests/pending/pos/tcpoly_ticket2096.scala @@ -0,0 +1,30 @@ +// smallest expression of monad i can find +trait MBrace[C[X] <: MBrace[C,X],A] { + def nest( a : A ) : C[A] + def flatten[T <: C[C[A]]]( bsq : T ) : C[A] +} + +// a monad that is a Seq +trait MBraceSeq[C[X] <: MBrace[C,X] with Seq[X],A] extends MBrace[C,A] + +// one of the simplest witnesses of monad i can find +case class MSequitor[A]( a_ : A* ) extends Seq[A] with MBrace[MSequitor,A] +{ + override def nest( a : A ) = new MSequitor[A]( a ) + override def flatten[T <: MSequitor[MSequitor[A]]]( bsq : T ) : MSequitor[A] = { + (new MSequitor[A]( ) /: bsq)( { + ( acc : MSequitor[A], e : MSequitor[A] ) => ( acc ++ e ).asInstanceOf[MSequitor[A]] + } ) + } + override def length = a_.length + override def iterator = a_.iterator + override def apply( n : Int ) = a_.apply( n ) +} + +// type arguments [MSequitor,A] do not conform to trait MBraceSeq's type parameter bounds [C[_] <: MBrace[C,A] with Seq[A],A] +// a statement of the instance relation +class MBraceSequitor[A] extends MBraceSeq[MSequitor,A] { + val empty : MSequitor[A] = new MSequitor[A]( ) + override def nest( a : A ) = empty.nest( a ) + override def flatten[T <: MSequitor[MSequitor[A]]]( bsq : T ): MSequitor[A] = empty.flatten( bsq ) +} diff --git a/tests/pending/pos/tcpoly_variance_pos.scala b/tests/pending/pos/tcpoly_variance_pos.scala new file mode 100644 index 000000000..b63abce20 --- /dev/null +++ b/tests/pending/pos/tcpoly_variance_pos.scala @@ -0,0 +1,7 @@ +class A[m[+x]] { + def str: m[Object] = sys.error("foo") +} + +class B[m[+x]] extends A[m] { + override def str: m[String] = sys.error("foo") +} diff --git a/tests/pending/pos/ted.scala b/tests/pending/pos/ted.scala new file mode 100644 index 000000000..314f10932 --- /dev/null +++ b/tests/pending/pos/ted.scala @@ -0,0 +1,18 @@ +object App +{ + def exponentiate(base : Double, exponent : Double) : Double = + (base, exponent) match + { + case (0, 0) => 1.0 + case (b, 0) => 1.0 + case (b, 1) => b + case (b, e) => b * exponentiate(b, e - 1) + } + + + + def main(args : Array[String]) = + System.out.println(exponentiate(2, 2)) + +} + diff --git a/tests/pending/pos/test4.scala b/tests/pending/pos/test4.scala new file mode 100644 index 000000000..4fe65a8f1 --- /dev/null +++ b/tests/pending/pos/test4.scala @@ -0,0 +1,47 @@ +package test; + +trait C {} +trait D {} +trait E {} + +object test { + def c: C = c; + def d: D = d; + def e: E = e; +} + +import test._; + +trait S extends ooo.I[D] { + def bar: E = foo(c,d); +} + +class O[X]() { + trait I[Y] { + def foo(x: X, y: Y): E = e; + } + val i:I[E] = null; + val j:I[X] = null; +} + +object ooo extends O[C]() { + + def main = { + val s: S = null; + import s._; + foo(c,d); + ooo.i.foo(c,e); + ooo.j.foo(c,c); + bar + } +} + +class Main() { + val s: S = null; + import s._; + foo(c,d); + ooo.i.foo(c,e); + ooo.j.foo(c,c); + bar; +} + diff --git a/tests/pending/pos/test5.scala b/tests/pending/pos/test5.scala new file mode 100644 index 000000000..4dbafc9ac --- /dev/null +++ b/tests/pending/pos/test5.scala @@ -0,0 +1,68 @@ +import scala._; + +object test { + + trait F[If] {} + + def f[Jf](h: Jf):F[Jf] = f[Jf](h); + + trait G[Ig] {} + + def g[Jg](h: Jg):G[Jg] = g[Jg](h); + + class M[P]() { + abstract class I[X]() { + // Methods to check the type X and P as seen from instances of I + def chk_ix(x: X): Unit = (); + def chk_ip(p: P): Unit; + + // Value with type X as seen from instances of I + def val_ix: X = val_ix; + } + + val i:I[G[P]] = null; + + // Values with types P and i.X as seen from instances of M + def val_mp: P = val_mp; + def val_mix: G[P] = g[P](val_mp); + } + + class N[Q]() extends M[F[Q]]() { + val j:J[G[Q]] = null; + + abstract class J[Y]() extends I[G[Y]]() { + // Values with types Y and X as seen from instances of J + def val_jy: Y = val_jy; + def val_jx: G[Y] = g[Y](val_jy); + + // Check type P + chk_ip(val_mp); + chk_ip(val_np); + } + + // Values with types Q, X.P, i.X, j.Y and j.X as seen from instances of N + def val_nq: Q = val_nq; + def val_np: F[Q] = f[Q](val_nq); + def val_nix: G[F[Q]] = g[F[Q]](val_np); + def val_njy: G[Q] = g[Q](val_nq); + def val_njx: G[G[Q]] = g[G[Q]](val_njy); + + // Check type i.P + i.chk_ip(val_mp); + i.chk_ip(val_np); + + // Check type j.P + j.chk_ip(val_mp); + j.chk_ip(val_np); + + // Check type i.X + i.chk_ix(i.val_ix); + i.chk_ix(val_mix); + i.chk_ix(val_nix); + + // Check j.X + j.chk_ix(j.val_ix); + j.chk_ix(j.val_jx); + j.chk_ix(val_njx); + } +} diff --git a/tests/pending/pos/test5refine.scala b/tests/pending/pos/test5refine.scala new file mode 100644 index 000000000..5459b3b97 --- /dev/null +++ b/tests/pending/pos/test5refine.scala @@ -0,0 +1,75 @@ +import scala._; + +object test { + + abstract trait F { type If; } + + def f[Jf](h: Jf):F { type If = Jf } = f[Jf](h); + + abstract trait G { type Ig; } + + def g[Jg](h: Jg):G { type Ig = Jg } = g[Jg](h); + + abstract class M() { + type P; + abstract class I() { + type X; + + // Methods to check the type X and P as seen from instances of I + def chk_ix(x: X): Unit = {} + def chk_ip(p: P): Unit = {} + + // Value with type X as seen from instances of I + def val_ix: X = val_ix; + } + + val i: I { type X = G { type Ig = P } } = null; + + // Values with types P and i.X as seen from instances of M + def val_mp: P = val_mp; + def val_mix: G { type Ig = P } = g[P](val_mp); + } + + abstract class N() extends M() { + type Q; + type P = F { type If = Q }; + val j:J { type Y = G { type Ig = Q } } = null; + + abstract class J() extends I() { + type Y; + type X = G { type Ig = Y; }; + // Values with types Y and X as seen from instances of J + def val_jy: Y = val_jy; + def val_jx: G { type Ig = Y; } = g[Y](val_jy); + + // Check type P + chk_ip(val_mp); + chk_ip(val_np); + } + + // Values with types Q, X.P, i.X, j.Y and j.X as seen from instances of N + def val_nq: Q = val_nq; + def val_np: F { type If = Q } = f[Q](val_nq); + def val_nix: G { type Ig = F { type If = Q } } = g[F { type If = Q }](val_np); + def val_njy: G { type Ig = Q; } = g[Q](val_nq); + def val_njx: G { type Ig = G { type Ig = Q }} = g[G { type Ig = Q; }](val_njy); + + // Check type i.P + i.chk_ip(val_mp); + i.chk_ip(val_np); + + // Check type j.P + j.chk_ip(val_mp); + j.chk_ip(val_np); + + // Check type i.X + i.chk_ix(i.val_ix); + i.chk_ix(val_mix); + i.chk_ix(val_nix); + + // Check j.X + j.chk_ix(j.val_ix); + j.chk_ix(j.val_jx); + j.chk_ix(val_njx); + } +} diff --git a/tests/pending/pos/ticket2251.scala b/tests/pending/pos/ticket2251.scala new file mode 100644 index 000000000..006407247 --- /dev/null +++ b/tests/pending/pos/ticket2251.scala @@ -0,0 +1,39 @@ + +// Martin: I am not sure this is a solvable problem right now. I'll leave it in pending. +// derived from pos/t1001 +class A +trait B[T <: B[T]] extends A +class C extends B[C] +class D extends B[D] + +class Data { + // force computing lub of C and D (printLubs enabled:) + +/* +lub of List(D, C) at depth 2 + lub of List(D, C) at depth 1 + lub of List(D, C) at depth 0 + lub of List(D, C) is A + lub of List(D, C) is B[_1] forSome { type _1 >: D with C <: A } +lub of List(D, C) is B[_2] forSome { type _2 >: D with C{} <: B[_1] forSome { type _1 >: D with C{} <: A } } +*/ +// --> result = WRONG + + // should be: B[X] forSome {type X <: B[X]} -- can this be done automatically? for now, just detect f-bounded polymorphism and fall back to more coarse approximation + + val data: List[A] = List(new C, new D) + + val data2 = List(new C, new D) + + val data3: List[B[_ <: B[_ <: A]]] = List(new C, new D) + + // Not yet -- + // val data4: List[B[X] forSome { type X <: B[X] }] = List(new C, new D) + // <console>:7: error: type mismatch; + // found : List[B[_ >: D with C <: B[_ >: D with C <: A]]] + // required: List[B[X] forSome { type X <: B[X] }] + // val data4: List[B[X] forSome { type X <: B[X] }] = List(new C, new D) + + // works + val data5 = List[B[X] forSome { type X <: B[X] }](new C, new D) +} diff --git a/tests/pending/pos/trait-force-info.flags b/tests/pending/pos/trait-force-info.flags new file mode 100644 index 000000000..eb4d19bcb --- /dev/null +++ b/tests/pending/pos/trait-force-info.flags @@ -0,0 +1 @@ +-optimise
\ No newline at end of file diff --git a/tests/pending/pos/trait-force-info.scala b/tests/pending/pos/trait-force-info.scala new file mode 100644 index 000000000..c2b33869c --- /dev/null +++ b/tests/pending/pos/trait-force-info.scala @@ -0,0 +1,18 @@ +/** 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) diff --git a/tests/pending/pos/tryexpr.scala b/tests/pending/pos/tryexpr.scala new file mode 100644 index 000000000..c6c2febf7 --- /dev/null +++ b/tests/pending/pos/tryexpr.scala @@ -0,0 +1,10 @@ +// stretching more flexible try/catch's legs a bit +object o { + try Integer.parseInt("xxxx") catch { case e => 5 } + try 5 + try try try 10 + try try try 10 catch { case e => 20 } finally 30 + try try try 10 catch { case e => 20 } finally 30 finally 40 + try try try 10 catch { case e => 20 } finally 30 finally 40 finally 50 + try try try 10 finally 50 +} diff --git a/tests/pending/pos/typealiases.scala b/tests/pending/pos/typealiases.scala new file mode 100644 index 000000000..93d1dce4d --- /dev/null +++ b/tests/pending/pos/typealiases.scala @@ -0,0 +1,20 @@ +package foo + +trait Test[T] { + type Check[T] = Array[T] => Unit; + type MyPair[S] = (T, S) + + val pair1: (T, Int) + val pair: MyPair[Int] = pair1 + + def check(xs: Array[T], c: Check[T]) = c(xs) + def check2[S](xs: Array[S], c: Check[S]) = c(xs) +} + +object main extends Test[Int] { + val pair1 = (1,1) + + implicit def topair(x: Int): Tuple2[Int, Int] = (x,x) + val pair2: MyPair[Int] = 1 + val x: Short = 1 +} diff --git a/tests/pending/pos/typerep-stephane.scala b/tests/pending/pos/typerep-stephane.scala new file mode 100644 index 000000000..2cb899591 --- /dev/null +++ b/tests/pending/pos/typerep-stephane.scala @@ -0,0 +1,48 @@ +object typerep { + + class TypeRep[T] { + def getType: TypeRep[T] = this + } + + object BooleanRep extends TypeRep[Boolean] { + override def toString = "Boolean" + } + object CharRep extends TypeRep[Char] { + override def toString = "Char" + } + object IntRep extends TypeRep[Int] { + override def toString = "Int" + } + object LongRep extends TypeRep[Long] { + override def toString = "Long" + } + object FloatRep extends TypeRep[Float] { + override def toString = "Float" + } + object DoubleRep extends TypeRep[Double] { + override def toString = "Double" + } + class ListRep[U, T <: List[U]](val elemRep: TypeRep[U]) extends TypeRep[T] { + override def toString = "List[" + elemRep + "]" + } + + implicit def typeRep(x: Boolean): TypeRep[Boolean] = BooleanRep + implicit def typeRep(x: Char ): TypeRep[Char ] = CharRep + implicit def typeRep(x: Long ): TypeRep[Long ] = LongRep + implicit def typeRep(x: Float ): TypeRep[Float ] = FloatRep + implicit def typeRep(x: Double ): TypeRep[Double ] = DoubleRep + implicit def typeRep(x: Int ): TypeRep[Int ] = IntRep +/* + implicit def typeRep[T](xs: List[T])(implicit rep: T => TypeRep[T]): TypeRep[List[T]] = + new ListRep(rep(xs.head)) +*/ + implicit def typeRep[T <% TypeRep[T]](xs: List[T]): TypeRep[List[T]] = + new ListRep(xs.head) + +} + +object test extends App { + import typerep._ + println(3.getType) + println(List(3).getType) +} diff --git a/tests/pending/pos/typesafecons.scala b/tests/pending/pos/typesafecons.scala new file mode 100644 index 000000000..524328016 --- /dev/null +++ b/tests/pending/pos/typesafecons.scala @@ -0,0 +1,30 @@ +object Pair { + sealed trait Pair { + type First + type Second <: Pair + } + + class End extends Pair { + type First = Nothing + type Second = End + + def ::[T](v : T) : Cons[T, End] = Cons(v, this) + } + + case object End extends End + + final case class Cons[T1, T2 <: Pair](_1 : T1, _2 : T2) extends Pair { + type First = T1 + type Second = T2 + + def ::[T](v : T) : Cons[T, Cons[T1, T2]] = Cons(v, this) + def find[T](implicit finder : Cons[T1, T2] => T) = finder(this) + } + + implicit def findFirst[T1, T2 <: Pair] : Cons[T1, T2] => T1 = (p : Cons[T1, T2]) => p._1 + implicit def findSecond[T, T1, T2 <: Pair](implicit finder : T2 => T) : Cons[T1, T2] => T = (p : Cons[T1, T2]) => finder(p._2) + + val p : Cons[Int, Cons[Boolean, End]] = 10 :: false :: End +// val x : Boolean = p.find[Boolean](findSecond(findFirst)) + val x2 : Boolean = p.find[Boolean] // Doesn't compile +} diff --git a/tests/pending/pos/unapplySeq.scala b/tests/pending/pos/unapplySeq.scala new file mode 100644 index 000000000..6d13cc8b5 --- /dev/null +++ b/tests/pending/pos/unapplySeq.scala @@ -0,0 +1,26 @@ +object FooSeq { + def unapplySeq(x:Any): Option[Product2[Int,Seq[String]]] = { + if(x.isInstanceOf[Bar]) { + val y = x.asInstanceOf[Bar] + Some(y.size, y.name) + } else None + } + + def main(args:Array[String]) = { + val b = new Bar + b match { + case FooSeq(s:Int,_,n:String) => Console.println("size "+s+" name "+n) + } + b.size = 54 + b.name = List("large","L") + b match { + case FooSeq(s:Int,_,n:String) => Console.println("size "+s+" name "+n) + } + } +} + +class Bar { + var size: Int = 50 + var name: Seq[String] = List("medium","M") +} + diff --git a/tests/pending/pos/unchecked-a.flags b/tests/pending/pos/unchecked-a.flags new file mode 100644 index 000000000..779916d58 --- /dev/null +++ b/tests/pending/pos/unchecked-a.flags @@ -0,0 +1 @@ +-unchecked -Xfatal-warnings
\ No newline at end of file diff --git a/tests/pending/pos/unchecked-a.scala b/tests/pending/pos/unchecked-a.scala new file mode 100644 index 000000000..deceb91c3 --- /dev/null +++ b/tests/pending/pos/unchecked-a.scala @@ -0,0 +1,15 @@ +trait Y +trait Z extends Y +class X[+A <: Y] + +object Test { + def f1(x: X[_ <: Y]) = x match { + case _: X[Any] => // looks a little funny; `Any` is outside the bounds for `A` + } + def f2(x: X[_ <: Y]) = x match { + case _: X[Y] => // looks better, let's allow this (too) + } + + // NonLocalReturnControl[_] warnings + def foo: Int = List(0).foldLeft(0){case _ => return 0} +} diff --git a/tests/pending/pos/variances-local.scala b/tests/pending/pos/variances-local.scala new file mode 100644 index 000000000..35e395095 --- /dev/null +++ b/tests/pending/pos/variances-local.scala @@ -0,0 +1,7 @@ +class Foo1[+T] { + private[this] type MyType = T +} + +class Foo2[+T] { + protected[this] type MyType = T +} diff --git a/tests/pending/pos/viewtest1.scala b/tests/pending/pos/viewtest1.scala new file mode 100644 index 000000000..38945ad2f --- /dev/null +++ b/tests/pending/pos/viewtest1.scala @@ -0,0 +1,42 @@ +package test + +trait Ordered[a] { + def < (x: a): Boolean +} + +object O { + implicit def view (x: String): Ordered[String] = new Ordered[String] { + def < (y: String) = x.compareTo(y) < 0 + } +} + +object Empty extends Tree[Nothing] +case class Node[c <% Ordered[c]](elem: c, l: Tree[c], r: Tree[c]) extends Tree[c] + +abstract class Tree[+a <% Ordered[a]] { + def insert[b >: a <% Ordered[b]](x: b): Tree[b] = this match { + case Empty => + new Node(x, Empty, Empty) + case Node(elem, l, r) => + if (x == elem) this + else if (x < elem) Node(elem, l insert x, r) + else Node(elem, l, r insert x) + } + def elements: List[a] = this match { + case Empty => List() + case Node(elem, l, r) => + l.elements ::: List(elem) ::: r.elements + } +} + +object Test { + import O.view + + def main(args: Array[String]): Unit = { + var t: Tree[String] = Empty + for (s <- args) { + t = t insert s + } + println(t.elements) + } +} diff --git a/tests/pending/pos/virtpatmat_alts_subst.flags b/tests/pending/pos/virtpatmat_alts_subst.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/pending/pos/virtpatmat_alts_subst.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/pending/pos/virtpatmat_alts_subst.scala b/tests/pending/pos/virtpatmat_alts_subst.scala new file mode 100644 index 000000000..e27c52f9c --- /dev/null +++ b/tests/pending/pos/virtpatmat_alts_subst.scala @@ -0,0 +1,6 @@ +case class Foo(s: String) { + def appliedType(tycon: Any) = + tycon match { + case Foo(sym @ ("NothingClass" | "AnyClass")) => println(sym) + } +} diff --git a/tests/pending/pos/virtpatmat_exist1.flags b/tests/pending/pos/virtpatmat_exist1.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/pending/pos/virtpatmat_exist1.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/pending/pos/virtpatmat_exist1.scala b/tests/pending/pos/virtpatmat_exist1.scala new file mode 100644 index 000000000..6cad017b0 --- /dev/null +++ b/tests/pending/pos/virtpatmat_exist1.scala @@ -0,0 +1,24 @@ +import annotation.unchecked.{ uncheckedVariance=> uV } +import scala.collection.immutable.{ListMap, HashMap, ListSet, HashSet} + +object Test { + class HashMapCollision1[A, +B](var hash: Int, var kvs: ListMap[A, B @uV]) extends HashMap[A, B @uV] + class HashSetCollision1[A](var hash: Int, var ks: ListSet[A]) extends HashSet[A] + + def splitArray[T](ad: Array[Iterable[T]]): Any = + ad(0) match { + case _: HashMapCollision1[_, _] | _: HashSetCollision1[_] => null + } + + // without type ascription for the one in the body of the last flatmap of each alternative, type inference borks on the existentials + // def splitArray[T >: Nothing <: Any](ad: Array[Iterable[T]]): Any = { import OptionMatching._ + // runOrElse(ad.apply(0))(((x1: Iterable[T]) => ( + // or(((x4: Iterable[T]) => one(null)), + // guard(x1.isInstanceOf[Iterable[T] with Test.HashMapCollision1[_,_]], x1.asInstanceOf[Iterable[T] with Test.HashMapCollision1[_,_]]).flatMap(((x2: Iterable[T] with Test.HashMapCollision1[_,_]) => one(x2))), + // guard(x1.isInstanceOf[Test.HashSetCollision1[_]], x1.asInstanceOf[Iterable[T] with Test.HashSetCollision1[_]]).flatMap(((x3: Iterable[T] with Test.HashSetCollision1[_]) => one(x3)))): Option[Any]).orElse( + // (zero: Option[Any]))) + // ) + // } + +} + diff --git a/tests/pending/pos/virtpatmat_exist3.flags b/tests/pending/pos/virtpatmat_exist3.flags new file mode 100644 index 000000000..3f5a3100e --- /dev/null +++ b/tests/pending/pos/virtpatmat_exist3.flags @@ -0,0 +1 @@ + -Xexperimental diff --git a/tests/pending/pos/virtpatmat_exist3.scala b/tests/pending/pos/virtpatmat_exist3.scala new file mode 100644 index 000000000..6a6d428b1 --- /dev/null +++ b/tests/pending/pos/virtpatmat_exist3.scala @@ -0,0 +1,12 @@ +class ReferenceQueue[T] { + def wrapper(jref: ReferenceQueue[_]): ReferenceQueue[T] = + jref match { + case null => null + } + + // def wrapper(jref: ReferenceQueue[_]): ReferenceQueue[T] = OptionMatching.runOrElse(jref)(((x1: ReferenceQueue[_]) => + // (OptionMatching.guard(null.==(x1), x1.asInstanceOf[ReferenceQueue[_]]).flatMap(((x2: ReferenceQueue[_]) => + // OptionMatching.one(null))): Option[ReferenceQueue[T]]).orElse( + // (OptionMatching.zero: Option[ReferenceQueue[T]]))) + // ) +} diff --git a/tests/pending/pos/virtpatmat_exist_uncurry.scala b/tests/pending/pos/virtpatmat_exist_uncurry.scala new file mode 100644 index 000000000..727922b31 --- /dev/null +++ b/tests/pending/pos/virtpatmat_exist_uncurry.scala @@ -0,0 +1,6 @@ +object Test { + trait Leaf[T] { + def collect[U](f: PartialFunction[Leaf[_], U]): List[U] + def leaves: List[Leaf[T]] = collect { case l: Leaf[T] => l } + } +} diff --git a/tests/pending/pos/z1720.scala b/tests/pending/pos/z1720.scala new file mode 100644 index 000000000..7394d428c --- /dev/null +++ b/tests/pending/pos/z1720.scala @@ -0,0 +1,16 @@ +package test + +class Thing { + def info: Info[this.type] = InfoRepository.getInfo(this) + def info2: Info[this.type] = { + def self: this.type = this + InfoRepository.getInfo(self) + } +} + +trait Info[T] +case class InfoImpl[T](thing: T) extends Info[T] + +object InfoRepository { + def getInfo(t: Thing): Info[t.type] = InfoImpl(t) +} |