Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two problems: boxing and generic instantiation #78

Closed
gavinking opened this issue Sep 12, 2011 · 3 comments
Closed

Two problems: boxing and generic instantiation #78

gavinking opened this issue Sep 12, 2011 · 3 comments

Comments

@gavinking
Copy link
Member

This little bit of code illustrates a several issues:

In test.ceylon:

class Single<Element>(Element e) {
    shared Element get() { return e; }
}

void test() {
    value s = Single(69);
    if (s.get()<100) {}
}

Java code generated for test.ceylon

@.com.redhat.ceylon.compiler.metadata.java.Ceylon
class Single<Element> {
     private final Element e;

    @.com.redhat.ceylon.compiler.metadata.java.TypeInfo("Element")
    public final Element get() {
        return e;
    }

    Single(@.com.redhat.ceylon.compiler.metadata.java.Name("e")
    @.com.redhat.ceylon.compiler.metadata.java.TypeInfo("Element")
    Element e) {
        this.e = e;
    }
}
@.com.redhat.ceylon.compiler.metadata.java.Ceylon
@.com.redhat.ceylon.compiler.metadata.java.Method
final class test {

    private test() {
    }

    static void test() {
        final .Single<ceylon.language.Natural> s = new <ceylon.language.Natural>.Single<ceylon.language.Natural>(.ceylon.language.Natural.instance(69L));
        if (s.get().compare(.ceylon.language.Natural.instance(100L)).smaller().booleanValue() == true) {
        }
    }
}

The problems are:

  1. "new <ceylon.language.Natural>.Single<ceylon.language.Natural>" has two type argument lists.
  2. "smaller()" returns unboxed "boolean"
  3. "== true" is just garbage.
@ghost ghost assigned FroMage Sep 12, 2011
@FroMage
Copy link
Member

FroMage commented Sep 30, 2011

Hey look at this, this is legal:

class Bar<Foo> {
    <Gee> Bar(Gee gee){
    }
}

{
    new <java.lang.String> Bar<java.lang.String>("");
}

I never suspected constructors could be parameterized in Java. Guess they can't in Ceylon.

@FroMage
Copy link
Member

FroMage commented Sep 30, 2011

Point 2 is already fixed by previous work.

FroMage added a commit that referenced this issue Sep 30, 2011
FroMage added a commit that referenced this issue Sep 30, 2011
FroMage added a commit that referenced this issue Sep 30, 2011
@FroMage
Copy link
Member

FroMage commented Sep 30, 2011

Fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants