Last active
August 15, 2016 13:45
-
-
Save Perelandric/19501e1d1e93271468077157bbf9be24 to your computer and use it in GitHub Desktop.
Unable to get clone method in generic type to compile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
actor Main | |
new create(env: Env) => None | |
trait MyTrait | |
new create() | |
fun test(): MyTrait | |
class Foo is MyTrait | |
new create() => None | |
fun test(): Foo => Foo | |
class GenericTest[T: MyTrait ref] | |
var value: Array[T] = Array[T] | |
new create() => None | |
fun test() => | |
let a = Array[T] | |
a.push(T.test()) |
Author
Perelandric
commented
Aug 14, 2016
•
Compiles if I do...
a.push(T)
actor Main
new create(env: Env) => None
trait MyTrait[T]
new create()
fun test(): MyTrait[T]
class Foo is MyTrait[Foo]
new create() => None
fun test(): Foo => Foo
class GenericTest[T: MyTrait[T] ref]
fun test() =>
let a = Array[T]
a.push(T.create().test())
actor Main
new create(env: Env) =>
let f = GenericTest[Foo] // A `Foo` version of `GenericTest`
trait MyTrait[T]
new create()
fun test(): MyTrait[T]
class Foo is MyTrait[Foo]
new create() => None
fun test(): Foo => Foo
class GenericTest[T: MyTrait[T] ref]
fun test() =>
let a = Array[MyTrait[T]] // Compiles with `MyTrait[T]` instead of `T`
a.push(T.create().test())
actor Main
new create(env: Env) =>
let f = FooTest
trait MyTrait[T]
new create()
fun test(): MyTrait[T]
class Foo
new create() => None
fun test(): Foo => Foo
class FooTest
fun test() =>
let a = Array[Foo]
a.push(Foo.create().test())
actor Main
new create(env: Env) =>
let f = GenericTest[Foo] // A `Foo` version of `GenericTest`
trait MyTrait[T]
new create()
fun test(): T
class Foo is MyTrait[Foo]
new create() => None
fun test(): Foo => Foo
class GenericTest[T: MyTrait[T] ref]
fun test() =>
let a = Array[T]
a.push(T.create().test())
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment