From a26dd939b89a5224a41ee27c3c51ac802b802f55 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 4 Mar 2012 16:44:16 -0800 Subject: Revert attempt to limit private types in lubs. Has to be somewhere more directly tied to structural refinements. See run/lub-visibility.scala before/after output for motivation. Closes SI-5534. Conflicts: src/compiler/scala/tools/nsc/symtab/Types.scala --- src/compiler/scala/tools/nsc/symtab/Types.scala | 2 +- test/files/pos/t5534.scala | 61 +++++++++++++++++++++++++ test/files/run/lub-visibility.check | 14 ++++++ test/files/run/lub-visibility.scala | 8 ++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 test/files/pos/t5534.scala create mode 100644 test/files/run/lub-visibility.check create mode 100644 test/files/run/lub-visibility.scala diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index d19aba470b..03d8c369d2 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -5175,7 +5175,7 @@ A type's typeSymbol should never be inspected directly. } } - loop(ts map (_.baseTypeSeq.toList filter (_.typeSymbol.isPublic))) + loop(ts map (_.baseTypeSeq.toList)) } // @AM the following problem is solved by elimHOTparams in lublist diff --git a/test/files/pos/t5534.scala b/test/files/pos/t5534.scala new file mode 100644 index 0000000000..39682a2fff --- /dev/null +++ b/test/files/pos/t5534.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/test/files/run/lub-visibility.check b/test/files/run/lub-visibility.check new file mode 100644 index 0000000000..3461d1bf6b --- /dev/null +++ b/test/files/run/lub-visibility.check @@ -0,0 +1,14 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> // should infer List[scala.collection.immutable.Seq[Nothing]] + +scala> // but reverted that for SI-5534. + +scala> val x = List(List(), Vector()) +x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq{def dropRight(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def takeRight(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def drop(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def take(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]}]; def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.Ab... +scala> + +scala> diff --git a/test/files/run/lub-visibility.scala b/test/files/run/lub-visibility.scala new file mode 100644 index 0000000000..8d5d3ae11a --- /dev/null +++ b/test/files/run/lub-visibility.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.ReplTest +object Test extends ReplTest { + def code = """ + |// should infer List[scala.collection.immutable.Seq[Nothing]] + |// but reverted that for SI-5534. + |val x = List(List(), Vector()) + """.stripMargin +} -- cgit v1.2.3