Skip to content

Instantly share code, notes, and snippets.

@Perelandric
Last active August 15, 2016 13:45
Show Gist options
  • Save Perelandric/19501e1d1e93271468077157bbf9be24 to your computer and use it in GitHub Desktop.
Save Perelandric/19501e1d1e93271468077157bbf9be24 to your computer and use it in GitHub Desktop.
Unable to get clone method in generic type to compile
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())
@Perelandric
Copy link
Author

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())

@Perelandric
Copy link
Author

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