ceylon / ceylon-js

DEPRECATED
Apache License 2.0
54 stars 9 forks source link

Container's type parameters not available in a generic method #550

Closed jvasileff closed 9 years ago

jvasileff commented 9 years ago

For:

interface Invokable {
    shared formal void invoke();
    shared formal void invokeGeneric<X>();
}

Invokable typePrinter<T>() => object
        satisfies Invokable {
    shared actual void invoke() { print(`T`); }
    shared actual void invokeGeneric<X>() { print(`T`); }
};

shared void run() {
    typePrinter<String>().invoke(); // ok
    typePrinter<String>().invokeGeneric<String>(); // error
}

only the non-generic method invoke has access to T:

$ ceylon run-js simple
ceylon.language::String

/Users/jvasileff/Dropbox/Repos/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:3601
      ^
Error: Missing type argument 'Type' [object Object]
    at Object.typeLiteral$meta (/Users/jvasileff/Dropbox/Repos/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:3601:7)
    at $init$$2.$2$.invokeGeneric (/private/tmp/simple/modules/simple/1.0.0/simple-1.0.0.js:38:15)
    at run (/private/tmp/simple/modules/simple/1.0.0/simple-1.0.0.js:49:47)
    at [eval]:1:282
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:536:25)
    at startup (node.js:80:7)
    at node.js:906:3
chochos commented 9 years ago

This only happens with nested generic functions I think

chochos commented 9 years ago

Here's a simpler version:

void f<F>() {
  void g<G>() {
    print(`F`);
  }
  g<String>();
}
f<Integer>();