diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-02-16 14:42:27 +0100 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-02-16 14:42:27 +0100 |
commit | 23326def4bf5bcfb7f5286707eed2f57a5da731d (patch) | |
tree | fa23894ff7ef13b2da334c8dff008f37c5a37cc3 /test/files | |
parent | 00d19344b0c19a2999e48c6bd9326b94c7b54346 (diff) | |
parent | 653c404d7f1307251625a5569d53421d27f248cf (diff) | |
download | scala-23326def4bf5bcfb7f5286707eed2f57a5da731d.tar.gz scala-23326def4bf5bcfb7f5286707eed2f57a5da731d.tar.bz2 scala-23326def4bf5bcfb7f5286707eed2f57a5da731d.zip |
Merge pull request #3493 from retronym/ticket/3452-2
SI-3452 Correct Java generic signatures for mixins, static forwarders
Diffstat (limited to 'test/files')
35 files changed, 521 insertions, 1 deletions
diff --git a/test/files/neg/t4749.check b/test/files/neg/t4749.check index 63d5c21532..3539140954 100644 --- a/test/files/neg/t4749.check +++ b/test/files/neg/t4749.check @@ -25,6 +25,10 @@ t4749.scala:26: warning: Fail6 has a main method with parameter type Array[Strin object Fail6 { ^ +t4749.scala:42: warning: Win3 has a main method with parameter type Array[String], but bippy.Win3 will not be a runnable program. + Reason: main method must have exact signature (Array[String])Unit + object Win3 extends WinBippy[Unit] { } + ^ error: No warnings can be incurred under -Xfatal-warnings. -6 warnings found +7 warnings found one error found diff --git a/test/files/pos/t3452f.scala b/test/files/pos/t3452f.scala new file mode 100644 index 0000000000..efe25a62fc --- /dev/null +++ b/test/files/pos/t3452f.scala @@ -0,0 +1,10 @@ +class Base[Coll] { + trait Transformed[S] { + lazy val underlying: Coll = ??? + } +} + +class Derived extends Base[String] { + class C extends Transformed[Any] +} + diff --git a/test/files/run/mixin-signatures.check b/test/files/run/mixin-signatures.check new file mode 100644 index 0000000000..3031fe75af --- /dev/null +++ b/test/files/run/mixin-signatures.check @@ -0,0 +1,59 @@ +class Test$bar1$ { + public java.lang.String Test$bar1$.f(java.lang.Object) + public java.lang.Object Test$bar1$.f(java.lang.Object) <bridge> <synthetic> + public java.lang.String Test$bar1$.g(java.lang.String) + public java.lang.Object Test$bar1$.g(java.lang.Object) <bridge> <synthetic> + public java.lang.String Test$bar1$.g(java.lang.Object) <bridge> <synthetic> + public java.lang.Object Test$bar1$.h(java.lang.Object) +} + +class Test$bar2$ { + public java.lang.Object Test$bar2$.f(java.lang.String) + public java.lang.Object Test$bar2$.f(java.lang.Object) <bridge> <synthetic> + public java.lang.String Test$bar2$.g(java.lang.String) + public java.lang.Object Test$bar2$.g(java.lang.Object) <bridge> <synthetic> + public java.lang.Object Test$bar2$.g(java.lang.String) <bridge> <synthetic> + public java.lang.Object Test$bar2$.h(java.lang.Object) +} + +class Test$bar3$ { + public java.lang.String Foo3.f(java.lang.Object) + generic: public java.lang.String Foo3.f(T) + public java.lang.Object Foo3.f(java.lang.Object) <bridge> <synthetic> + public java.lang.String Test$bar3$.g(java.lang.String) + public java.lang.Object Test$bar3$.g(java.lang.Object) <bridge> <synthetic> + public java.lang.String Test$bar3$.g(java.lang.Object) <bridge> <synthetic> + public java.lang.Object Foo3.h(java.lang.Object) +} + +class Test$bar4$ { + public java.lang.Object Foo4.f(java.lang.String) + generic: public R Foo4.f(java.lang.String) + public java.lang.Object Foo4.f(java.lang.Object) <bridge> <synthetic> + public java.lang.String Test$bar4$.g(java.lang.String) + public java.lang.Object Test$bar4$.g(java.lang.Object) <bridge> <synthetic> + public java.lang.Object Test$bar4$.g(java.lang.String) <bridge> <synthetic> + public java.lang.Object Foo4.h(java.lang.Object) +} + +class Test$bar5$ { + public java.lang.String Test$bar5$.f(java.lang.String) + public java.lang.Object Test$bar5$.f(java.lang.Object) <bridge> <synthetic> + public java.lang.Object Test$bar5$.f(java.lang.String) <bridge> <synthetic> + public java.lang.String Test$bar5$.f(java.lang.Object) <bridge> <synthetic> + public java.lang.String Test$bar5$.g(java.lang.String) + public java.lang.Object Test$bar5$.g(java.lang.Object) <bridge> <synthetic> + public java.lang.Object Test$bar5$.g(java.lang.String) <bridge> <synthetic> + public java.lang.String Test$bar5$.g(java.lang.Object) <bridge> <synthetic> + public java.lang.Object Test$bar5$.h(java.lang.Object) +} + +class Foo1$class { + public static java.lang.String Foo1$class.f(Foo1,java.lang.Object) +} + +class Foo2$class { + public static java.lang.Object Foo2$class.f(Foo2,java.lang.String) +} + +000000000000000000000000000000000000 diff --git a/test/files/run/mixin-signatures.scala b/test/files/run/mixin-signatures.scala new file mode 100644 index 0000000000..afd3fad877 --- /dev/null +++ b/test/files/run/mixin-signatures.scala @@ -0,0 +1,105 @@ +trait Base[T, R] { + def f(x: T): R + def g(x: T): R + def h(x: T): R = null.asInstanceOf[R] +} + +trait Foo1[T] extends Base[T, String] { + def f(x: T): String = null + def g(x: T): String +} +trait Foo2[R] extends Base[String, R] { + def f(x: String): R = { print(x.length) ; null.asInstanceOf[R] } + def g(x: String): R +} +abstract class Foo3[T] extends Base[T, String] { + def f(x: T): String = "" + def g(x: T): String +} +abstract class Foo4[R] extends Base[String, R] { + def f(x: String): R = { print(x.length) ; null.asInstanceOf[R] } + def g(x: String): R +} + +object Test { + object bar1 extends Foo1[String] { def g(x: String): String = { print(x.length) ; "" } } + object bar2 extends Foo2[String] { def g(x: String): String = { print(x.length) ; "" } } + object bar3 extends Foo3[String] { def g(x: String): String = { print(x.length) ; "" } } + object bar4 extends Foo4[String] { def g(x: String): String = { print(x.length) ; "" } } + + // Notice that in bar5, f and g require THREE bridges, because the final + // implementation is (String)String, but: + // + // inherited abstract signatures: T(R), (T)String, and (String)R + // which erase to: (Object)Object, (Object)String, and (String)Object + // + // each of which must be bridged to the actual (String)String implementation. + // + // public java.lang.String Test$bar5$.g(java.lang.String) + // public java.lang.Object Test$bar5$.g(java.lang.String) <bridge> <synthetic> + // public java.lang.Object Test$bar5$.g(java.lang.Object) <bridge> <synthetic> + // public java.lang.String Test$bar5$.g(java.lang.Object) <bridge> <synthetic> + object bar5 extends Foo1[String] with Foo2[String] { + override def f(x: String): String = { print(x.length) ; x } + def g(x: String): String = { print(x.length) ; x } + } + + final def m1[T, R](x: Base[T, R], y: T) = { x.f(y) ; x.g(y) ; x.h(y) } + final def m2[T](x: Base[T, String], y: T) = { x.f(y) ; x.g(y) ; x.h(y) } + final def m3[R](x: Base[String, R]) = { x.f("") ; x.g("") ; x.h("") } + final def m4(x: Base[String, String]) = { x.f("") ; x.g("") ; x.h("") } + + final def m11[T](x: Foo1[T], y: T) = { x.f(y) ; x.g(y) ; x.h(y) } + final def m12(x: Foo1[String]) = { x.f("") ; x.g("") ; x.h("") } + final def m21[T](x: Foo2[T], y: T) = { x.f("") ; x.g("") ; x.h("") } + final def m22(x: Foo2[String]) = { x.f("") ; x.g("") ; x.h("") } + final def m31[T](x: Foo3[T], y: T) = { x.f(y) ; x.g(y) ; x.h(y) } + final def m32(x: Foo3[String]) = { x.f("") ; x.g("") ; x.h("") } + final def m41[T](x: Foo4[T], y: T) = { x.f("") ; x.g("") ; x.h("") } + final def m42(x: Foo4[String]) = { x.f("") ; x.g("") ; x.h("") } + + def go = { + m1(bar1, "") ; m2(bar1, "") ; m3(bar1) ; m4(bar1) + m1(bar2, "") ; m2(bar2, "") ; m3(bar2) ; m4(bar2) + m1(bar3, "") ; m2(bar3, "") ; m3(bar3) ; m4(bar3) + m1(bar4, "") ; m2(bar4, "") ; m3(bar4) ; m4(bar4) + + m11(bar1, "") ; m12(bar1) + m21(bar2, "") ; m22(bar2) + m31(bar3, "") ; m32(bar3) + m41(bar4, "") ; m42(bar4) + "" + } + + def flagsString(m: java.lang.reflect.Method) = { + val str = List( + if (m.isBridge) "<bridge>" else "", + if (m.isSynthetic) "<synthetic>" else "" + ) filterNot (_ == "") mkString " " + + if (str == "") "" else " " + str + // + // val flags = scala.reflect.internal.ClassfileConstants.toScalaMethodFlags(m.getModifiers()) + // scala.tools.nsc.symtab.Flags.flagsToString(flags) + } + + def show(clazz: Class[_]) { + print(clazz + " {") + clazz.getMethods.sortBy(x => (x.getName, x.isBridge, x.toString)) filter (_.getName.length == 1) foreach { m => + print("\n " + m + flagsString(m)) + if ("" + m != "" + m.toGenericString) { + print("\n generic: " + m.toGenericString) + } + } + println("\n}") + println("") + } + def show(x: AnyRef) { show(x.getClass) } + def show(x: String) { show(Class.forName(x)) } + + def main(args: Array[String]): Unit = { + List(bar1, bar2, bar3, bar4, bar5) foreach show + List("Foo1$class", "Foo2$class") foreach show + println(go) + } +}
\ No newline at end of file diff --git a/test/files/run/t3452.check b/test/files/run/t3452.check new file mode 100644 index 0000000000..b8626c4cff --- /dev/null +++ b/test/files/run/t3452.check @@ -0,0 +1 @@ +4 diff --git a/test/files/run/t3452.scala b/test/files/run/t3452.scala new file mode 100644 index 0000000000..253fc93cfa --- /dev/null +++ b/test/files/run/t3452.scala @@ -0,0 +1,21 @@ +trait IStringPair[T] { + def a : String + def b : String + def build(a : String, b : String) : T + def cat(that : IStringPair[T]) = build(this.a + that.a, this.b + that.b) + override def toString = a + b +} + +class StringPair(val a : String, val b : String) extends IStringPair[StringPair] { + def build(a : String, b : String) = new StringPair(a, b) + def len = a.length + b.length +} + +object Test { + def main(args: Array[String]): Unit = { + val a = new StringPair("A", "B") + val b = new StringPair("1", "2") + val c = a cat b + println(c.len) + } +} diff --git a/test/files/run/t3452a.check b/test/files/run/t3452a.check new file mode 100644 index 0000000000..9ff787eb86 --- /dev/null +++ b/test/files/run/t3452a.check @@ -0,0 +1 @@ +BulkSearch.searchFor called. diff --git a/test/files/run/t3452a/J_2.java b/test/files/run/t3452a/J_2.java new file mode 100644 index 0000000000..62057ffe61 --- /dev/null +++ b/test/files/run/t3452a/J_2.java @@ -0,0 +1,5 @@ +public class J_2 { + public static void main(String[] args) { + BulkSearchInstance.searchFor(new UpRelation()); + } +} diff --git a/test/files/run/t3452a/S_1.scala b/test/files/run/t3452a/S_1.scala new file mode 100644 index 0000000000..791faf42fa --- /dev/null +++ b/test/files/run/t3452a/S_1.scala @@ -0,0 +1,24 @@ +abstract class BulkSearch { + type R <: Row + type Rel <: Relation [R] + type Corr <: Correspondence[R] + + def searchFor(input: Rel): Mapping[Corr] = { println("BulkSearch.searchFor called.") ; null } +} + +object BulkSearchInstance extends BulkSearch { + type R = UpRow + type Rel = UpRelation + type Corr = UpCorrespondence +} + +class Row +class UpRow extends Row + +class Relation [R <: Row] +class UpRelation extends Relation [UpRow] + +class Correspondence [R <: Row] +class UpCorrespondence extends Correspondence [UpRow] + +class Mapping[MC <: Correspondence[_]] diff --git a/test/files/run/t3452a/S_3.scala b/test/files/run/t3452a/S_3.scala new file mode 100644 index 0000000000..aaa898dcde --- /dev/null +++ b/test/files/run/t3452a/S_3.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + J_2.main(args) + } +} diff --git a/test/files/run/t3452b-bcode.check b/test/files/run/t3452b-bcode.check new file mode 100644 index 0000000000..204c3d0437 --- /dev/null +++ b/test/files/run/t3452b-bcode.check @@ -0,0 +1,2 @@ +Search received: test +SearchC received: test diff --git a/test/files/run/t3452b-bcode.flags b/test/files/run/t3452b-bcode.flags new file mode 100644 index 0000000000..c30091d3de --- /dev/null +++ b/test/files/run/t3452b-bcode.flags @@ -0,0 +1 @@ +-Ybackend:GenBCode diff --git a/test/files/run/t3452b-bcode/J_2.java b/test/files/run/t3452b-bcode/J_2.java new file mode 100644 index 0000000000..839f334508 --- /dev/null +++ b/test/files/run/t3452b-bcode/J_2.java @@ -0,0 +1,6 @@ +public class J_2 { + public static void j() { + StringSearch.search("test"); + StringSearch.searchC("test"); + } +} diff --git a/test/files/run/t3452b-bcode/S_1.scala b/test/files/run/t3452b-bcode/S_1.scala new file mode 100644 index 0000000000..a209f12035 --- /dev/null +++ b/test/files/run/t3452b-bcode/S_1.scala @@ -0,0 +1,17 @@ +trait Search[M] { + def search(input: M): C[Int] = { + println("Search received: " + input) + null + } +} + +class SearchC[M] { + def searchC(input: M): C[Int] = { + println("SearchC received: " + input) + null + } +} + +object StringSearch extends SearchC[String] with Search[String] + +trait C[T] diff --git a/test/files/run/t3452b-bcode/S_3.scala b/test/files/run/t3452b-bcode/S_3.scala new file mode 100644 index 0000000000..102b433f47 --- /dev/null +++ b/test/files/run/t3452b-bcode/S_3.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + J_2.j() + } +} diff --git a/test/files/run/t3452b.check b/test/files/run/t3452b.check new file mode 100644 index 0000000000..204c3d0437 --- /dev/null +++ b/test/files/run/t3452b.check @@ -0,0 +1,2 @@ +Search received: test +SearchC received: test diff --git a/test/files/run/t3452b/J_2.java b/test/files/run/t3452b/J_2.java new file mode 100644 index 0000000000..839f334508 --- /dev/null +++ b/test/files/run/t3452b/J_2.java @@ -0,0 +1,6 @@ +public class J_2 { + public static void j() { + StringSearch.search("test"); + StringSearch.searchC("test"); + } +} diff --git a/test/files/run/t3452b/S_1.scala b/test/files/run/t3452b/S_1.scala new file mode 100644 index 0000000000..a209f12035 --- /dev/null +++ b/test/files/run/t3452b/S_1.scala @@ -0,0 +1,17 @@ +trait Search[M] { + def search(input: M): C[Int] = { + println("Search received: " + input) + null + } +} + +class SearchC[M] { + def searchC(input: M): C[Int] = { + println("SearchC received: " + input) + null + } +} + +object StringSearch extends SearchC[String] with Search[String] + +trait C[T] diff --git a/test/files/run/t3452b/S_3.scala b/test/files/run/t3452b/S_3.scala new file mode 100644 index 0000000000..102b433f47 --- /dev/null +++ b/test/files/run/t3452b/S_3.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + J_2.j() + } +} diff --git a/test/files/run/t3452c.check b/test/files/run/t3452c.check new file mode 100644 index 0000000000..ab47181198 --- /dev/null +++ b/test/files/run/t3452c.check @@ -0,0 +1,8 @@ +3 +3 +3 +3 +3 +3 +3 +3 diff --git a/test/files/run/t3452c.scala b/test/files/run/t3452c.scala new file mode 100644 index 0000000000..2c55767abc --- /dev/null +++ b/test/files/run/t3452c.scala @@ -0,0 +1,113 @@ +trait Base[A, B, C] { + def f(x: A, y: B, z: C): Unit + def g(x: A, y: B, z: C) = f(x, y, z) + def h(x: A, y: B, z: C) = g(x, y, z) +} + +trait D1[B, C] extends Base[String, B, C] +trait D2[A, B] extends Base[A, B, String] +trait D3[A, C] extends Base[A, String, C] +trait D4[A] extends Base[A, String, String] +trait D5[B] extends Base[String, B, String] +trait D6[C] extends Base[String, String, C] +trait D7 extends Base[String, String, String] + +trait E1[B, C] extends Base[String, B, C] { def f(x: String, y: B, z: C): Unit ; override def h(x: String, y: B, z: C) = g(x, y, z) } +trait E2[A, B] extends Base[A, B, String] { def f(x: A, y: B, z: String): Unit ; override def h(x: A, y: B, z: String) = g(x, y, z) } +trait E3[A, C] extends Base[A, String, C] { def f(x: A, y: String, z: C): Unit ; override def h(x: A, y: String, z: C) = g(x, y, z) } +trait E4[A] extends Base[A, String, String] { def f(x: A, y: String, z: String): Unit ; override def h(x: A, y: String, z: String) = g(x, y, z) } +trait E5[B] extends Base[String, B, String] { def f(x: String, y: B, z: String): Unit ; override def h(x: String, y: B, z: String) = g(x, y, z) } +trait E6[C] extends Base[String, String, C] { def f(x: String, y: String, z: C): Unit ; override def h(x: String, y: String, z: C) = g(x, y, z) } +trait E7 extends Base[String, String, String] { def f(x: String, y: String, z: String): Unit ; override def h(x: String, y: String, z: String) = g(x, y, z) } + +trait F1[B, C] extends Base[String, B, C] { def f(x: String, y: B, z: C): Unit = println(x.length) } +trait F2[A, B] extends Base[A, B, String] { def f(x: A, y: B, z: String): Unit = println(z.length) } +trait F3[A, C] extends Base[A, String, C] { def f(x: A, y: String, z: C): Unit = println(y.length) } +trait F4[A] extends Base[A, String, String] { def f(x: A, y: String, z: String): Unit = println(y.length) } +trait F5[B] extends Base[String, B, String] { def f(x: String, y: B, z: String): Unit = println(x.length) } +trait F6[C] extends Base[String, String, C] { def f(x: String, y: String, z: C): Unit = println(x.length) } +trait F7 extends Base[String, String, String] { def f(x: String, y: String, z: String): Unit = println(x.length) } + +abstract class DBag extends D1[String, String] with D2[String, String] with D3[String, String] with D4[String] with D5[String] with D6[String] with D7 { + def f(x: String, y: String, z: String) = println(x.length + y.length + z.length) +} +abstract class EBag extends E1[String, String] with E2[String, String] with E3[String, String] with E4[String] with E5[String] with E6[String] with E7 { + def f(x: String, y: String, z: String) = println(x.length + y.length + z.length) +} +abstract class FBag extends F1[String, String] with F2[String, String] with F3[String, String] with F4[String] with F5[String] with F6[String] with F7 { + override def f(x: String, y: String, z: String) = println(x.length + y.length + z.length) +} + +abstract class GBag1[A, B] extends Base[A, B, String] with D2[A, B] { + def f(x: A, y: B, z: String) = println(z.length) +} +abstract class GBag2[A] extends GBag1[A, String] with D4[A] { + override def f(x: A, y: String, z: String) = println(z.length) +} +abstract class GBag3 extends GBag2[String] with D7 { + override def f(x: String, y: String, z: String) = println(z.length) +} +class GBag extends GBag3 with D2[String, String] with D3[String, String] with D4[String] with D5[String] with D6[String] with D7 { +} + +object Test { + def f0(x: Base[String, String, String]) = x.f("a", "b", "c") + def f1(x: D1[String, String]) = x.f("a", "b", "c") + def f2(x: D2[String, String]) = x.f("a", "b", "c") + def f3(x: D3[String, String]) = x.f("a", "b", "c") + def f4(x: D4[String]) = x.f("a", "b", "c") + def f5(x: D5[String]) = x.f("a", "b", "c") + def f6(x: D6[String]) = x.f("a", "b", "c") + def f7(x: D7) = x.f("a", "b", "c") + + def main(args: Array[String]): Unit = { + val x = new DBag { } + f0(x) + f1(x) + f2(x) + f3(x) + f4(x) + f5(x) + f6(x) + f7(x) + } +} + +object TestE { + def f0(x: Base[String, String, String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f1(x: E1[String, String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f2(x: E2[String, String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f3(x: E3[String, String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f4(x: E4[String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f5(x: E5[String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f6(x: E6[String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f7(x: E7) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + + def main(args: Array[String]): Unit = { + val x = new EBag { } + f0(x) + f1(x) + f2(x) + f3(x) + f4(x) + f5(x) + f6(x) + f7(x) + } +} + + +object TestG { + def f0(x: Base[String, String, String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f1(x: GBag1[String, String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f2(x: GBag2[String]) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + def f3(x: GBag3) = { x.f("a", "b", "c") ; x.g("a", "b", "c") ; x.h("a", "b", "c") } + + def main(args: Array[String]): Unit = { + val x = new GBag { } + f0(x) + f1(x) + f2(x) + f3(x) + } +} diff --git a/test/files/run/t3452d/A.scala b/test/files/run/t3452d/A.scala new file mode 100644 index 0000000000..67a2080d27 --- /dev/null +++ b/test/files/run/t3452d/A.scala @@ -0,0 +1,7 @@ +trait TraversableLike[A, Repr] { + def tail: Repr = null.asInstanceOf[Repr] +} + +abstract class AbstractTrav[A] extends TraversableLike[A, Traversable[A]] + +class C[A] extends AbstractTrav[A] diff --git a/test/files/run/t3452d/Test.java b/test/files/run/t3452d/Test.java new file mode 100644 index 0000000000..875be6176c --- /dev/null +++ b/test/files/run/t3452d/Test.java @@ -0,0 +1,12 @@ +import scala.collection.immutable.Nil; +import scala.collection.immutable.List; +import scala.collection.Traversable; + +public class Test { + public static void main(String[] args) { + C<String> c = new C<String>(); + // TODO add a bridge during mixin so we can expose + // sharper generic signature for `tail`. + /*Traversable<String>*/ Object ls = c.tail(); + } +} diff --git a/test/files/run/t3452e/A.scala b/test/files/run/t3452e/A.scala new file mode 100644 index 0000000000..939172f401 --- /dev/null +++ b/test/files/run/t3452e/A.scala @@ -0,0 +1,4 @@ +trait F1[T, R] { + def andThen[A](g: R => A): Int = 0 +} +class C1[TT, RR] extends F1[TT, RR] diff --git a/test/files/run/t3452e/B.java b/test/files/run/t3452e/B.java new file mode 100644 index 0000000000..0268af9987 --- /dev/null +++ b/test/files/run/t3452e/B.java @@ -0,0 +1,2 @@ +class B extends C1<String, String> { +} diff --git a/test/files/run/t3452e/Test.scala b/test/files/run/t3452e/Test.scala new file mode 100644 index 0000000000..fc175bf94a --- /dev/null +++ b/test/files/run/t3452e/Test.scala @@ -0,0 +1,3 @@ +object Test extends App { + new B +} diff --git a/test/files/run/t3452f.scala b/test/files/run/t3452f.scala new file mode 100644 index 0000000000..af64f5c042 --- /dev/null +++ b/test/files/run/t3452f.scala @@ -0,0 +1,19 @@ +import language.higherKinds + +trait GenSet[A] + +trait GenSetTemplate[A, +CC[X] <: GenSet[X]] { + def empty: CC[A] = ??? +} + +trait SetLike[A, +This <: SetLike[A, This] with Set[A]] { + def empty: This +} + +abstract class Set[A] extends GenSet[A] with SetLike[A,Set[A]] with GenSetTemplate[A,Set] + +object Test { + def main(args: Array[String]): Unit = { + locally(classOf[Set[_]]) // trigger classloading to verify class + } +} diff --git a/test/files/run/t3452g/A.scala b/test/files/run/t3452g/A.scala new file mode 100644 index 0000000000..a3f74c1e1e --- /dev/null +++ b/test/files/run/t3452g/A.scala @@ -0,0 +1,9 @@ +trait TraversableLike[A, Repr] { + def tail: Repr = null.asInstanceOf[Repr] +} + +abstract class AbstractTrav[A] extends TraversableLike[A, AbstractTrav[A]] + +object O extends AbstractTrav[String] + +class C[A] extends AbstractTrav[A] diff --git a/test/files/run/t3452g/Test.java b/test/files/run/t3452g/Test.java new file mode 100644 index 0000000000..c3b4222d16 --- /dev/null +++ b/test/files/run/t3452g/Test.java @@ -0,0 +1,14 @@ + +public class Test { + public static void main(String[] args) { + // To get better types here, we would need to + // add bridge during mixin so we can expose + // a generic return type of Traversable<A>, because the erasure + // of this (Traversable) differs from the erasure of the mixed + // method (erasure(Repr) = Object) + + Object lsSharp = O.tail(); + + Object lsSharp2 = new C<String>().tail(); + } +} diff --git a/test/files/run/t3452h.scala b/test/files/run/t3452h.scala new file mode 100644 index 0000000000..6237d3ea64 --- /dev/null +++ b/test/files/run/t3452h.scala @@ -0,0 +1,8 @@ +class Mix___eFoo_I_wBar__f extends Foo_I_ with Bar__f { f; } +trait T +abstract class Foo_I_ { class I extends T ; def f: I ; f; } +trait Bar__f { type I>:Null<:T; def f: I = {null}; f; def gobble: I = {null}} + +object Test extends App { + new Mix___eFoo_I_wBar__f +} diff --git a/test/files/run/t6554.check b/test/files/run/t6554.check new file mode 100644 index 0000000000..6e0af7b474 --- /dev/null +++ b/test/files/run/t6554.check @@ -0,0 +1 @@ +public java.lang.Object Bar.minBy(java.lang.Object) / public java.lang.Object Bar.minBy(java.lang.Object) diff --git a/test/files/run/t6554.scala b/test/files/run/t6554.scala new file mode 100644 index 0000000000..5d29d16666 --- /dev/null +++ b/test/files/run/t6554.scala @@ -0,0 +1,11 @@ +trait Foo[A] { + def minBy[B](b: B): A = ??? +} + +class Bar extends Foo[Int] + +object Test extends App { + val sigs = classOf[Bar].getDeclaredMethods.map(m => s"${m.toString} / ${m.toGenericString}").sorted + println(sigs.mkString("\n")) +} +// Was public java.lang.Object Bar.minBy(java.lang.Object) / public <B> int Bar.minBy(B) diff --git a/test/files/run/t7374.check b/test/files/run/t7374.check new file mode 100644 index 0000000000..4efa6f7af3 --- /dev/null +++ b/test/files/run/t7374.check @@ -0,0 +1,3 @@ +List(2, 3) +ParVector(1, 2, 3) +List(1, 2) diff --git a/test/files/run/t7374/Some.scala b/test/files/run/t7374/Some.scala new file mode 100644 index 0000000000..3266a5642e --- /dev/null +++ b/test/files/run/t7374/Some.scala @@ -0,0 +1,3 @@ +object SomeScala { + def list = List(1, 2, 3) +} diff --git a/test/files/run/t7374/Test.java b/test/files/run/t7374/Test.java new file mode 100644 index 0000000000..02f86146ca --- /dev/null +++ b/test/files/run/t7374/Test.java @@ -0,0 +1,7 @@ +public class Test { + public static void main(String[] args) { + System.out.println(SomeScala.list().tail()); + System.out.println(SomeScala.list().par()); + System.out.println(SomeScala.list().init()); + } +} |