diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/tcpoly_ticket2101.check | 4 | ||||
-rw-r--r-- | test/files/neg/tcpoly_ticket2101.scala | 28 | ||||
-rw-r--r-- | test/files/pos/tcpoly_ticket2096.scala | 30 |
3 files changed, 62 insertions, 0 deletions
diff --git a/test/files/neg/tcpoly_ticket2101.check b/test/files/neg/tcpoly_ticket2101.check new file mode 100644 index 0000000000..eac582e8ba --- /dev/null +++ b/test/files/neg/tcpoly_ticket2101.check @@ -0,0 +1,4 @@ +tcpoly_ticket2101.scala:2: error: type arguments [T2,X] do not conform to class T's type parameter bounds [A[Y] <: T[A,B],B] +class T2[X] extends T[T2, X] // ill-typed + ^ +one error found
\ No newline at end of file diff --git a/test/files/neg/tcpoly_ticket2101.scala b/test/files/neg/tcpoly_ticket2101.scala new file mode 100644 index 0000000000..68f061ce70 --- /dev/null +++ b/test/files/neg/tcpoly_ticket2101.scala @@ -0,0 +1,28 @@ +class T[A[Y] <: T[A, B], B] +class T2[X] extends T[T2, X] // ill-typed +// because this bound is not met: +// Forall Y. T2[Y] <: T[T2, X] + +// debugging before fix: +// def isSubType0 --> +// case (PolyType(tparams1, res1), PolyType(tparams2, res2)) => println("<:<PT: "+((tparams1, res1), (tparams2, res2))) //@MDEBUG +// (tparams1.length == tparams2.length && +// List.forall2(tparams1, tparams2) +// ((p1, p2) => p2.info.substSym(tparams2, tparams1) <:< p1.info) && +// res1 <:< res2.substSym(tparams2, tparams1)) + +// generates output: +// <:<PT: ((List(type Y),A[Y]),(List(type Y),T[A,B])) +// <:<PT: ((List(type X),T2[X]),(List(type Y),T[T2,X])) + +// however, last check should have been: +// <:<PT: ((List(type X1),T2[X1]),(List(type Y1),T[T2,X])) + +// case (PolyType(tparams1, res1), PolyType(tparams2, res2)) => println("<:<PT: "+((tparams1, res1), (tparams2, res2))) //@MDEBUG +// (tparams1.length == tparams2.length && +// { +// val tpsFresh = cloneSymbols(tparams1) // @M cloneSymbols(tparams2) should be equivalent -- TODO: check +// List.forall2(tparams1, tparams2) +// ((p1, p2) => p2.info.substSym(tparams2, tpsFresh) <:< p1.info.substSym(tparams1, tpsFresh)) && +// res1.substSym(tparams1, tpsFresh) <:< res2.substSym(tparams2, tpsFresh) +// }) diff --git a/test/files/pos/tcpoly_ticket2096.scala b/test/files/pos/tcpoly_ticket2096.scala new file mode 100644 index 0000000000..d92589c929 --- /dev/null +++ b/test/files/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 ) +}
\ No newline at end of file |