-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3480 from paulp/pr/publicize-abstract-star
Make the Abstract* classes public.
- Loading branch information
Showing
15 changed files
with
205 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
warning: there were 2 feature warning(s); re-run with -feature for details | ||
p.Iterable[Int] | ||
p.Set[Int] | ||
p.Seq[Int] | ||
p.m.Set[Int] | ||
p.m.Seq[Int] | ||
private[m] p.m.ASet[Int] | ||
p.i.Seq[Int] | ||
private[i] p.i.ASet[Int] | ||
private[i] p.i.ASeq[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Set[Int] | ||
p.Iterable[Int] | ||
p.Set[Int] | ||
p.Iterable[Int] | ||
p.Set[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Seq[Int] | ||
p.Iterable[Int] | ||
p.Seq[Int] | ||
p.Iterable[Int] | ||
p.Seq[Int] | ||
p.Iterable[Int] | ||
p.m.Set[Int] | ||
p.Iterable[Int] | ||
p.Set[Int] | ||
p.Iterable[Int] | ||
p.Iterable[Int] | ||
p.Seq[Int] | ||
p.Iterable[Int] | ||
p.Seq[Int] | ||
p.Iterable[Int] | ||
private[p] p.ASet[Int] | ||
private[p] p.AIterable[Int] | ||
p.Iterable[Int] | ||
p.i.Seq[Int] | ||
private[p] p.AIterable[Int] | ||
List[Nothing] | ||
scala.collection.immutable.Vector[Nothing] | ||
scala.collection.immutable.Iterable[(Int, Int)] | ||
scala.collection.immutable.Set[Int] | ||
Seq[Int] | ||
Array[Int] | ||
scala.collection.AbstractSet[Int] | ||
Comparable[java.lang.String] | ||
scala.collection.immutable.LinearSeq[Int] | ||
Iterable[Int] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package p { | ||
trait TCon[+CC[X]] { | ||
def fPublic: CC[Int] = ??? | ||
private[p] def fPackagePrivate: CC[Int] = ??? | ||
protected[p] def fPackageProtected: CC[Int] = ??? | ||
} | ||
trait Iterable[+A] extends TCon[Iterable] | ||
trait Set[A] extends Iterable[A] with TCon[Set] | ||
trait Seq[+A] extends Iterable[A] with TCon[Seq] | ||
|
||
private[p] abstract class AIterable[+A] extends Iterable[A] | ||
private[p] abstract class ASeq[+A] extends AIterable[A] with Seq[A] | ||
private[p] abstract class ASet[A] extends AIterable[A] with Set[A] | ||
|
||
package m { | ||
private[m] abstract class ASeq[A] extends p.ASeq[A] with Seq[A] | ||
private[m] abstract class ASet[A] extends p.ASet[A] with Set[A] | ||
trait Set[A] extends p.Set[A] with TCon[Set] | ||
trait Seq[A] extends p.Seq[A] with TCon[Seq] | ||
trait BitSet extends ASet[Int] | ||
trait IntSeq extends ASeq[Int] | ||
} | ||
|
||
package i { | ||
private[i] abstract class ASeq[+A] extends p.ASeq[A] with Seq[A] | ||
private[i] abstract class ASet[A] extends p.ASet[A] with Set[A] | ||
trait Set[A] extends p.Set[A] with TCon[Set] | ||
trait Seq[+A] extends p.Seq[A] with TCon[Seq] | ||
trait BitSet extends ASet[Int] | ||
trait IntSeq extends ASeq[Int] | ||
} | ||
} | ||
|
||
object Test { | ||
import scala.reflect.runtime.universe._ | ||
// Complicated by the absence of usable type constructor type tags. | ||
def extract[A, CC[X]](xs: CC[A]): CC[A] = xs | ||
def whatis[T: TypeTag](x: T): Unit = { | ||
val tpe = typeOf[T] | ||
val access = tpe.typeSymbol.asInstanceOf[scala.reflect.internal.HasFlags].accessString.replaceAllLiterally("package ", "") | ||
println(f"$access%15s $tpe") | ||
} | ||
|
||
trait IntIterable extends p.Iterable[Int] | ||
trait IntSet extends p.Set[Int] | ||
trait IntSeq extends p.Seq[Int] | ||
|
||
trait MutableIntSet extends p.m.Set[Int] | ||
trait MutableIntSeq extends p.m.Seq[Int] | ||
|
||
trait ImmutableIntSet extends p.i.Set[Int] | ||
trait ImmutableIntSeq extends p.i.Seq[Int] | ||
|
||
def f1: IntIterable = null | ||
def f2: IntSet = null | ||
def f3: IntSeq = null | ||
|
||
def g1: MutableIntSet = null | ||
def g2: MutableIntSeq = null | ||
def g3: p.m.BitSet = null | ||
|
||
def h1: ImmutableIntSeq = null | ||
def h2: p.i.BitSet = null | ||
def h3: p.i.IntSeq = null | ||
|
||
def main(args: Array[String]): Unit = { | ||
whatis(extract(f1)) | ||
whatis(extract(f2)) | ||
whatis(extract(f3)) | ||
whatis(extract(g1)) | ||
whatis(extract(g2)) | ||
whatis(extract(g3)) | ||
whatis(extract(h1)) | ||
whatis(extract(h2)) | ||
whatis(extract(h3)) | ||
|
||
whatis(extract(if (true) f1 else f2)) | ||
whatis(extract(if (true) f1 else f3)) | ||
whatis(extract(if (true) f1 else g1)) | ||
whatis(extract(if (true) f1 else g2)) | ||
whatis(extract(if (true) f1 else g3)) | ||
whatis(extract(if (true) f1 else h1)) | ||
whatis(extract(if (true) f1 else h2)) | ||
whatis(extract(if (true) f1 else h3)) | ||
whatis(extract(if (true) f2 else f3)) | ||
whatis(extract(if (true) f2 else g1)) | ||
whatis(extract(if (true) f2 else g2)) | ||
whatis(extract(if (true) f2 else g3)) | ||
whatis(extract(if (true) f2 else h1)) | ||
whatis(extract(if (true) f2 else h2)) | ||
whatis(extract(if (true) f2 else h3)) | ||
whatis(extract(if (true) f3 else g1)) | ||
whatis(extract(if (true) f3 else g2)) | ||
whatis(extract(if (true) f3 else g3)) | ||
whatis(extract(if (true) f3 else h1)) | ||
whatis(extract(if (true) f3 else h2)) | ||
whatis(extract(if (true) f3 else h3)) | ||
whatis(extract(if (true) g1 else g2)) | ||
whatis(extract(if (true) g1 else g3)) | ||
whatis(extract(if (true) g1 else h1)) | ||
whatis(extract(if (true) g1 else h2)) | ||
whatis(extract(if (true) g1 else h3)) | ||
whatis(extract(if (true) g2 else g3)) | ||
whatis(extract(if (true) g2 else h1)) | ||
whatis(extract(if (true) g2 else h2)) | ||
whatis(extract(if (true) g2 else h3)) | ||
whatis(extract(if (true) g3 else h1)) | ||
whatis(extract(if (true) g3 else h2)) | ||
whatis(extract(if (true) g3 else h3)) | ||
whatis(extract(if (true) h1 else h2)) | ||
whatis(extract(if (true) h1 else h3)) | ||
whatis(extract(if (true) h2 else h3)) | ||
|
||
whatis(extract(Nil)) | ||
whatis(extract(Vector())) | ||
whatis(extract(Map[Int,Int]())) | ||
whatis(extract(Set[Int]())) | ||
whatis(extract(Seq[Int]())) | ||
whatis(extract(Array[Int]())) | ||
whatis(extract(scala.collection.immutable.BitSet(1))) | ||
whatis(extract("abc")) | ||
whatis(extract(if (true) Stream(1) else List(1))) | ||
whatis(extract(if (true) Seq(1) else Set(1))) | ||
} | ||
} |