metamodel refs to object members #401

Closed
gavinking opened this Issue Jan 28, 2014 · 12 comments

4 participants

@gavinking
Ceylon member

Given:

see (`value system.milliseconds`, 
     `function process.write`,
     `class system`)
void test() {
    print(`function test`.annotations<SeeAnnotation>());
}

I get:

ceylon run: While reflectively instantiating class ceylon.language.
SeeAnnotation
java.lang.RuntimeException: While reflectively instantiating class ceylon.language.SeeAnnotation
    at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.addAnnotation(Metamodel.java:582)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.addAnnotation(Metamodel.java:557)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.annotations(Metamodel.java:624)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.annotations(Metamodel.java:611)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.FreeNestableDeclaration.annotations(FreeNestableDeclaration.java:127)
    at jav.test_.test(run.ceylon:17)
    at jav.test_.main(run.ceylon)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at ceylon.modules.api.runtime.SecurityActions.invokeRunInternal(SecurityActions.java:58)
    at ceylon.modules.api.runtime.SecurityActions.invokeRun(SecurityActions.java:48)
    at ceylon.modules.api.runtime.AbstractRuntime.invokeRun(AbstractRuntime.java:85)
    at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:145)
    at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:129)
    at ceylon.modules.Main.execute(Main.java:69)
    at ceylon.modules.Main.main(Main.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.modules.Module.run(Module.java:270)
    at org.jboss.modules.Main.main(Main.java:294)
    at ceylon.modules.bootstrap.CeylonRunTool.run(CeylonRunTool.java:208)
    at com.redhat.ceylon.common.tools.CeylonTool.run(CeylonTool.java:343)
    at com.redhat.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:283)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:89)
    at com.redhat.ceylon.launcher.Launcher.main(Launcher.java:21)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.addAnnotation(Metamodel.java:577)
    ... 32 more
Caused by: java.lang.RuntimeException: Could not find type: system in ceylon.language
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.metamodelError(DeclarationParser.java:237)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.metamodelNotFound(DeclarationParser.java:241)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.makeClassOrInterface(DeclarationParser.java:274)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.class_(DeclarationParser.java:220)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.type(DeclarationParser.java:203)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.declaration(DeclarationParser.java:165)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.package_(DeclarationParser.java:157)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.module(DeclarationParser.java:101)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.DeclarationParser.ref(DeclarationParser.java:67)
    at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.parseMetamodelReferences(Metamodel.java:777)
    at ceylon.language.SeeAnnotation.<init>(annotations.ceylon:107)
    ... 37 more
@chochos chochos added a commit that referenced this issue Apr 3, 2014
@chochos chochos make #401 work in js 3a63ec3
@lucaswerkmeister
Ceylon member

Assuming that “Given” means “compile and run”, this works for me now in both IDE and command line. @gavinking can you verify that?

@lucaswerkmeister
Ceylon member

Oh, but there’s another problem!

see (`value system.milliseconds`, 
     `function process.write`,
     `class system`)
void run() {
    print(`function run`.annotations<SeeAnnotation>().first?.programElements);
}

prints

[value ceylon.language::system.milliseconds, function ceylon.language::process.write]

class system is missing! (Changing it to value system makes it appear.)

(This is on the Java backend; for JS, the programElements reference causes a “TypeError: Cannot read property 't' of undefined” when the see annotation contains `function process.write `.)

@FroMage
Ceylon member

Fixed. Does this work in JS?

@chochos
Ceylon member

I doubt it works in JS, seeing as how I haven't done anything about it yet. But... should it work with anonymous classes? And how? Is it correct to return a class named "system"? I thought we weren't supposed to give access to those, since then you could create another instance...

@FroMage
Ceylon member

I can't test the language module in JS anymore, I get LOTS of:

[ceylon-compile-js] Errors found. Compilation stopped.
[ceylon-compile-js] warning encountered [compiler annotations are an unsupported language feature] at 44:0-44:4 of bug259.ceylon
@FroMage
Ceylon member

You can't create another instance since it's a Class<Basic,Nothing>.

@FroMage
Ceylon member

The Nothing for parameters means you can't invoke it.

@FroMage
Ceylon member

OK, well, removing the JVM tag and adding the JS tag then ;) muahaha.

@FroMage FroMage added JS runtime and removed JVM runtime labels Jul 3, 2014
@chochos
Ceylon member

I need to rename all anon class initializers to fix this in JS.

@FroMage
Ceylon member

Or just the metamodel for them?

@chochos
Ceylon member

For toplevel objects you can just get the singleton and get its type, but the initializer for member objects has a private name, accessible only during compile time (no way to recreate that name for a member object in another module).

@chochos chochos added a commit that referenced this issue Jul 4, 2014
@chochos chochos work on #401 c7d40de
@chochos chochos added a commit to ceylon/ceylon-js that referenced this issue Jul 4, 2014
@chochos chochos work on ceylon/ceylon.language#401 0b16475
@chochos chochos added a commit to ceylon/ceylon-js that referenced this issue Jul 4, 2014
@chochos chochos work on ceylon/ceylon.language#401 ffffa02
@chochos chochos added a commit to ceylon/ceylon-js that referenced this issue Jul 4, 2014
@chochos chochos work on ceylon/ceylon.language#401 0f53495
@chochos
Ceylon member

The tests pass now in JS as well. Closing.

@chochos chochos closed this Jul 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment