forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht3568.scala
46 lines (36 loc) · 1.45 KB
/
t3568.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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]): Unit = { 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 StrictOptimizedSeqOps[E, IndexedSeq, 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
}
}