From a6bb10a310b2d10cfd2713b9d8ca5c21af73902d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 19 Jul 2010 13:55:09 +0000 Subject: new test files. --- test/files/pos/t2133.scala | 18 ++++++++++++++++++ test/files/pos/t3174.scala | 14 ++++++++++++++ test/files/pos/t3174b.scala | 12 ++++++++++++ test/files/pos/t3568.scala | 46 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 test/files/pos/t2133.scala create mode 100755 test/files/pos/t3174.scala create mode 100755 test/files/pos/t3174b.scala create mode 100755 test/files/pos/t3568.scala (limited to 'test/files/pos') diff --git a/test/files/pos/t2133.scala b/test/files/pos/t2133.scala new file mode 100644 index 0000000000..c74d0a4bbf --- /dev/null +++ b/test/files/pos/t2133.scala @@ -0,0 +1,18 @@ +trait Foo { + object bar { + private[this] def fn() = 5 + } +} + +trait Foo2 { + object bip { + def fn() = 10 + } +} + +class Bob extends AnyRef with Foo with Foo2 { + import bip._ + import bar._ + + def go() = fn() +} diff --git a/test/files/pos/t3174.scala b/test/files/pos/t3174.scala new file mode 100755 index 0000000000..c3d90a4946 --- /dev/null +++ b/test/files/pos/t3174.scala @@ -0,0 +1,14 @@ +object test { + def method() { + class Foo extends AnyRef { + object Color { + object Blue + } + + class Board { + val grid = Color.Blue + } + } + new Foo + } + } diff --git a/test/files/pos/t3174b.scala b/test/files/pos/t3174b.scala new file mode 100755 index 0000000000..4df1bfe837 --- /dev/null +++ b/test/files/pos/t3174b.scala @@ -0,0 +1,12 @@ +trait Foo[X] { def foo : Map[String,Foo[X]] } + +object Test { + def f[T]() : Foo[T] = { + class Anon extends Foo[T] { + var foo: Map[String, Foo[T]] = Map[String,Foo[T]]() + //def foo = Map[String,Foo[T]]() + //def foo_=(x: Map[String,Foo[T]]) {} + } + new Anon + } +} diff --git a/test/files/pos/t3568.scala b/test/files/pos/t3568.scala new file mode 100755 index 0000000000..c8e3fcc4be --- /dev/null +++ b/test/files/pos/t3568.scala @@ -0,0 +1,46 @@ +import scala.annotation._ +import scala.annotation.unchecked._ +import scala.collection._ + + +package object buffer { + val broken = new ArrayVec2() // commenting out this line causes the file to compile. + + val works = Class.forName("buffer.ArrayVec2").newInstance().asInstanceOf[ArrayVec2] +} + +package buffer { + object Main { + // ArrayVec2 can be compiled, instantiated and used. + def main(args: Array[String]) { println(works) } + } + + trait ElemType { type Element; type Component <: ElemType } + trait Float1 extends ElemType { type Element = Float; type Component = Float1} + class Vec2 extends ElemType { type Element = Vec2; type Component = Float1 } + + abstract class BaseSeq[T <: ElemType, E] + extends IndexedSeq[E] with IndexedSeqOptimized[E, IndexedSeq[E]] { + def length = 1 + def apply(i: Int) :E + } + + abstract class GenericSeq[T <: ElemType] extends BaseSeq[T, T#Element] + trait DataArray[T <: ElemType] extends BaseSeq[T, T#Element] + trait DataView[T <: ElemType] extends BaseSeq[T, T#Element] + abstract class BaseFloat1 extends BaseSeq[Float1, Float] + + class ArrayFloat1 extends BaseFloat1 with DataArray[Float1] { + def apply(i: Int) :Float = 0f + } + + class ViewFloat1 extends BaseFloat1 with DataView[Float1] { + def apply(i: Int) :Float = 0f + } + + class ArrayVec2(val backingSeq: ArrayFloat1) + extends GenericSeq[Vec2] with DataArray[Vec2] { + def this() = this(new ArrayFloat1) + def apply(i: Int) :Vec2 = null + } +} -- cgit v1.2.3