From c490722ae1b7a9147bcdc884e362409b4017d19f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 9 Nov 2009 10:02:50 +0000 Subject: Fixed #2504 Fixed #2517 --- test/files/neg/t0851.check | 9 +++++++++ test/files/neg/t0851.scala | 25 +++++++++++++++++++++++++ test/files/pos/t2082.scala | 39 +++++++++++++++++++++++++++++++++++++++ test/files/pos/t2504.scala | 5 +++++ test/files/run/t2236.scala | 17 +++++++++++++++++ test/files/run/t2503.scala | 19 +++++++++++++++++++ 6 files changed, 114 insertions(+) create mode 100644 test/files/neg/t0851.check create mode 100644 test/files/neg/t0851.scala create mode 100755 test/files/pos/t2082.scala create mode 100755 test/files/pos/t2504.scala create mode 100755 test/files/run/t2236.scala create mode 100755 test/files/run/t2503.scala (limited to 'test/files') diff --git a/test/files/neg/t0851.check b/test/files/neg/t0851.check new file mode 100644 index 0000000000..61d2a98632 --- /dev/null +++ b/test/files/neg/t0851.check @@ -0,0 +1,9 @@ +t0851.scala:14: error: not enough arguments for method apply: (v1: Int,v2: String)java.lang.String in trait Function2. +Unspecified value parameter v2. + println(f(1)) + ^ +t0851.scala:22: error: not enough arguments for method apply: (v1: Int,v2: String)java.lang.String in trait Function2. +Unspecified value parameter v2. + println(fn(1)) + ^ +two errors found diff --git a/test/files/neg/t0851.scala b/test/files/neg/t0851.scala new file mode 100644 index 0000000000..b28be2c697 --- /dev/null +++ b/test/files/neg/t0851.scala @@ -0,0 +1,25 @@ +package test + +// This gives now type errors about missing parameters, which seems OK to me. +// The tests just make sure it does not crash + +object test1 { + case class Foo[T,T2](f : (T,T2) => String) extends (((T,T2)) => String){ + def apply(t : T) = (s:T2) => f(t,s) + def apply(p : (T,T2)) = f(p._1,p._2) + } + implicit def g[T](f : (T,String) => String) = Foo(f) + def main(args : Array[String]) : Unit = { + val f = (x:Int,s:String) => s + x + println(f(1)) + () + } +} +object Main { + def main(args : Array[String]) { + val fn = (a : Int, str : String) => "a: " + a + ", str: " + str + implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null) + println(fn(1)) + () + } +} diff --git a/test/files/pos/t2082.scala b/test/files/pos/t2082.scala new file mode 100755 index 0000000000..3a160612fe --- /dev/null +++ b/test/files/pos/t2082.scala @@ -0,0 +1,39 @@ + +trait Mapper[T <: Mapper[T]] + +trait KeyedMapper[KeyType, T <: KeyedMapper[KeyType, T]] extends Mapper[T] + + +trait KeyedMetaMapper[KeyType, T <: KeyedMapper[KeyType, T]] + +trait MappedForeignKey[KeyType, Owner <: Mapper[Owner], Other <: KeyedMapper[KeyType, Other]] + +trait IdPK + +class TestSubject extends KeyedMapper[Long, TestSubject] with IdPK + +class TestRun extends KeyedMapper[Long, TestRun] with IdPK { + object testSubject extends MappedForeignKey[Long, TestRun, TestSubject] +} + +object TestRun extends TestRun with KeyedMetaMapper[Long, TestRun] + +class MetaTestSubject extends TestSubject with KeyedMetaMapper[Long, TestSubject] +object TestSubject extends MetaTestSubject + +object Main { + + def oneToOneJoin[PType <: KeyedMapper[Long, PType] with IdPK, + CType <: KeyedMapper[Long, CType] with IdPK, + CMetaType <: CType with KeyedMetaMapper[Long, CType], + FKType <: MappedForeignKey[Long, PType, CType]] + (parents: List[PType], metaMapper: CMetaType, keyGetter: (PType) => FKType ): + Map[Long, CType] = Map.empty + + def callIt { + oneToOneJoin[TestRun, TestSubject, MetaTestSubject, + MappedForeignKey[Long, TestRun, TestSubject]]( + List(), TestSubject, (tr: TestRun) => tr.testSubject) + } + +} diff --git a/test/files/pos/t2504.scala b/test/files/pos/t2504.scala new file mode 100755 index 0000000000..67f8226852 --- /dev/null +++ b/test/files/pos/t2504.scala @@ -0,0 +1,5 @@ +object Test { + val ys: Iterable[_] = Array("abc") + val xs = Array("abc") + xs sameElements Array("abc") +} diff --git a/test/files/run/t2236.scala b/test/files/run/t2236.scala new file mode 100755 index 0000000000..8e2b3900d4 --- /dev/null +++ b/test/files/run/t2236.scala @@ -0,0 +1,17 @@ +class T[A](implicit val m:Manifest[A]) +class Foo +class Bar extends T[Foo] +object Test extends Application { + new Bar +} + +object EvidenceTest { + trait E[T] + trait A[T] { implicit val e: E[T] = null } + class B[T : E] extends A[T] { override val e = null } + + def f[T] { + implicit val e: E[T] = null + new B[T]{} + } +} diff --git a/test/files/run/t2503.scala b/test/files/run/t2503.scala new file mode 100755 index 0000000000..353a1dcac8 --- /dev/null +++ b/test/files/run/t2503.scala @@ -0,0 +1,19 @@ +import scala.collection.mutable._ + +trait SB[A] extends Buffer[A] { + + import collection.Traversable + + abstract override def insertAll(n: Int, iter: Traversable[A]): Unit = synchronized { + super.insertAll(n, iter) + } + + abstract override def update(n: Int, newelem: A): Unit = synchronized { + super.update(n, newelem) + } +} + +object Test extends Application { + new ArrayBuffer[Int] with SB[Int] +} + -- cgit v1.2.3