summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/pos')
-rw-r--r--test/files/pos/delambdafy_t6260_method.check13
-rw-r--r--test/files/pos/delambdafy_t6260_method.flags1
-rw-r--r--test/files/pos/delambdafy_t6260_method.scala17
-rw-r--r--test/files/pos/t6169/Exist.java4
-rw-r--r--test/files/pos/t6169/ExistF.java4
-rw-r--r--test/files/pos/t6169/ExistIndir.java4
-rw-r--r--test/files/pos/t6169/OP.java1
-rw-r--r--test/files/pos/t6169/Skin.java1
-rw-r--r--test/files/pos/t6169/Skinnable.java3
-rw-r--r--test/files/pos/t6169/skinnable.scala14
-rw-r--r--test/files/pos/t6169/t6169.scala7
-rw-r--r--test/files/pos/t6260.flags1
-rw-r--r--test/files/pos/t6260.scala17
-rw-r--r--test/files/pos/t6260b.scala3
-rw-r--r--test/files/pos/t6948.scala10
-rw-r--r--test/files/pos/t8207.scala6
-rw-r--r--test/files/pos/t8219.scala15
-rw-r--r--test/files/pos/t8219b.scala49
-rw-r--r--test/files/pos/t8237.scala29
-rw-r--r--test/files/pos/t8237b.scala10
20 files changed, 209 insertions, 0 deletions
diff --git a/test/files/pos/delambdafy_t6260_method.check b/test/files/pos/delambdafy_t6260_method.check
new file mode 100644
index 0000000000..f5cd6947d1
--- /dev/null
+++ b/test/files/pos/delambdafy_t6260_method.check
@@ -0,0 +1,13 @@
+delambdafy_t6260_method.scala:3: error: bridge generated for member method apply: (bx: Object)Object in class map$extension1
+which overrides method apply: (v1: Object)Object in trait Function1
+clashes with definition of the member itself;
+both have erased type (bx: Object)Object
+ ((bx: Box[X]) => new Box(f(bx.x)))(this)
+ ^
+delambdafy_t6260_method.scala:8: error: bridge generated for member method apply: (bx: Object)Object in class map21
+which overrides method apply: (v1: Object)Object in trait Function1
+clashes with definition of the member itself;
+both have erased type (bx: Object)Object
+ ((bx: Box[X]) => new Box(f(bx.x)))(self)
+ ^
+two errors found
diff --git a/test/files/pos/delambdafy_t6260_method.flags b/test/files/pos/delambdafy_t6260_method.flags
new file mode 100644
index 0000000000..48b438ddf8
--- /dev/null
+++ b/test/files/pos/delambdafy_t6260_method.flags
@@ -0,0 +1 @@
+-Ydelambdafy:method
diff --git a/test/files/pos/delambdafy_t6260_method.scala b/test/files/pos/delambdafy_t6260_method.scala
new file mode 100644
index 0000000000..93b5448227
--- /dev/null
+++ b/test/files/pos/delambdafy_t6260_method.scala
@@ -0,0 +1,17 @@
+class Box[X](val x: X) extends AnyVal {
+ def map[Y](f: X => Y): Box[Y] =
+ ((bx: Box[X]) => new Box(f(bx.x)))(this)
+}
+
+object Test {
+ def map2[X, Y](self: Box[X], f: X => Y): Box[Y] =
+ ((bx: Box[X]) => new Box(f(bx.x)))(self)
+
+ def main(args: Array[String]) {
+ val f = (x: Int) => x + 1
+ val g = (x: String) => x + x
+
+ map2(new Box(42), f)
+ new Box("abc") map g
+ }
+}
diff --git a/test/files/pos/t6169/Exist.java b/test/files/pos/t6169/Exist.java
new file mode 100644
index 0000000000..dfc6b36b33
--- /dev/null
+++ b/test/files/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/test/files/pos/t6169/ExistF.java b/test/files/pos/t6169/ExistF.java
new file mode 100644
index 0000000000..70fabd74cf
--- /dev/null
+++ b/test/files/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/test/files/pos/t6169/ExistIndir.java b/test/files/pos/t6169/ExistIndir.java
new file mode 100644
index 0000000000..e66d1698c4
--- /dev/null
+++ b/test/files/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/test/files/pos/t6169/OP.java b/test/files/pos/t6169/OP.java
new file mode 100644
index 0000000000..15e4c5640f
--- /dev/null
+++ b/test/files/pos/t6169/OP.java
@@ -0,0 +1 @@
+public abstract class OP<T> { }
diff --git a/test/files/pos/t6169/Skin.java b/test/files/pos/t6169/Skin.java
new file mode 100644
index 0000000000..780de1ee09
--- /dev/null
+++ b/test/files/pos/t6169/Skin.java
@@ -0,0 +1 @@
+public interface Skin<C extends Skinnable> { }
diff --git a/test/files/pos/t6169/Skinnable.java b/test/files/pos/t6169/Skinnable.java
new file mode 100644
index 0000000000..f91eaa30d8
--- /dev/null
+++ b/test/files/pos/t6169/Skinnable.java
@@ -0,0 +1,3 @@
+public interface Skinnable {
+ OP<Skin<?>> skinProperty();
+}
diff --git a/test/files/pos/t6169/skinnable.scala b/test/files/pos/t6169/skinnable.scala
new file mode 100644
index 0000000000..3ba2734526
--- /dev/null
+++ b/test/files/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]]
+} \ No newline at end of file
diff --git a/test/files/pos/t6169/t6169.scala b/test/files/pos/t6169/t6169.scala
new file mode 100644
index 0000000000..37f42619ca
--- /dev/null
+++ b/test/files/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
+} \ No newline at end of file
diff --git a/test/files/pos/t6260.flags b/test/files/pos/t6260.flags
new file mode 100644
index 0000000000..2349d8294d
--- /dev/null
+++ b/test/files/pos/t6260.flags
@@ -0,0 +1 @@
+-Ydelambdafy:inline
diff --git a/test/files/pos/t6260.scala b/test/files/pos/t6260.scala
new file mode 100644
index 0000000000..93b5448227
--- /dev/null
+++ b/test/files/pos/t6260.scala
@@ -0,0 +1,17 @@
+class Box[X](val x: X) extends AnyVal {
+ def map[Y](f: X => Y): Box[Y] =
+ ((bx: Box[X]) => new Box(f(bx.x)))(this)
+}
+
+object Test {
+ def map2[X, Y](self: Box[X], f: X => Y): Box[Y] =
+ ((bx: Box[X]) => new Box(f(bx.x)))(self)
+
+ def main(args: Array[String]) {
+ val f = (x: Int) => x + 1
+ val g = (x: String) => x + x
+
+ map2(new Box(42), f)
+ new Box("abc") map g
+ }
+}
diff --git a/test/files/pos/t6260b.scala b/test/files/pos/t6260b.scala
new file mode 100644
index 0000000000..73e2e58f73
--- /dev/null
+++ b/test/files/pos/t6260b.scala
@@ -0,0 +1,3 @@
+
+class X(val value: Object) extends AnyVal { def or(alt: => X): X = this }
+class Y { def f = new X("") or new X("") }
diff --git a/test/files/pos/t6948.scala b/test/files/pos/t6948.scala
new file mode 100644
index 0000000000..12a1d7eaf2
--- /dev/null
+++ b/test/files/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/test/files/pos/t8207.scala b/test/files/pos/t8207.scala
new file mode 100644
index 0000000000..680b40f379
--- /dev/null
+++ b/test/files/pos/t8207.scala
@@ -0,0 +1,6 @@
+class C { me =>
+ import me.{toString => ts}
+ locally(this: me.type)
+ trait T
+ type X = me.T
+}
diff --git a/test/files/pos/t8219.scala b/test/files/pos/t8219.scala
new file mode 100644
index 0000000000..e1653b6238
--- /dev/null
+++ b/test/files/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/test/files/pos/t8219b.scala b/test/files/pos/t8219b.scala
new file mode 100644
index 0000000000..d55d3139e1
--- /dev/null
+++ b/test/files/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) = ""
+ implicit def any2str2(a: Any) = ""
+ T.foo("")
+ }
+}
diff --git a/test/files/pos/t8237.scala b/test/files/pos/t8237.scala
new file mode 100644
index 0000000000..005089079e
--- /dev/null
+++ b/test/files/pos/t8237.scala
@@ -0,0 +1,29 @@
+import scala.language.higherKinds
+
+object TestExplicit {
+ trait TC[A]
+ def fTt[A,E[X] <: List[X]](a: A)(implicit tt: TC[E[A]]) = a
+ implicit def tc[T]: TC[T] = ???
+
+ // Typechecking results in SOE in TypeVar.isGround
+ fTt(1)(tc)
+ // fun = TestExplicit.this.fTt[Int, E](1)
+ // args = TestExplicit.this.tc[E[Int]]
+ // argTpes.head.instantiateTypeParams = TC[?E#1[Int]]
+ // formals.head.instantiateTypeParams = TC[?E#2[Int]]
+ // (where ?E#1 and ?E#2 as distinct AppliedTypeVars that resulted
+ // from separate applications of type args to the same HKTypeVar, ?E)
+ //
+ // As we check if the argument conforms to the formal, we would have
+ // AppliedTypeVars sharing the same TypeConstraints on the LHS and RHS,
+ // which leads to a cyclic constraint.
+}
+
+object TestImplicit {
+ trait TC[A]
+ def fTt[A,E[X] <: List[X]](a: A)(implicit tt: TC[E[A]]) = a
+ implicit def tc[T]: TC[T] = ???
+
+ // Oddly enough, this one works.
+ fTt(1)
+}
diff --git a/test/files/pos/t8237b.scala b/test/files/pos/t8237b.scala
new file mode 100644
index 0000000000..52bb310e8b
--- /dev/null
+++ b/test/files/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)
+}