ceylon / ceylon-compiler

DEPRECATED
GNU General Public License v2.0
138 stars 36 forks source link

Ceylon backend error on generic function combined with other generic function #2415

Open renatoathaydes opened 8 years ago

renatoathaydes commented 8 years ago

Sorry for the vague title, but I don't know what's going on exactly here...

Here's my code:

    value parser = many(infix(
        word(), separatedBy<Character>, infix(
            character(','), around<Character>, spaces())));

It's from my library of parser combinators!

I'm experimenting with this infix function that makes parsers very readable, as you probably agree seeing the above.

Even though the IDE seems to accept this code (no highlighted errors), a backend error occurs:

method separatedBy$minOccurrences in class com.athaydes.parcey.combinator.separatedBy_ cannot be applied to given types;
  required: com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor,com.athaydes.parcey.Parser<? extends java.lang.Object>,com.athaydes.parcey.Parser<? extends ceylon.language.Iterable<? extends Item,? extends java.lang.Object>>
  found: com.athaydes.parcey.Parser,com.athaydes.parcey.Parser
  reason: cannot instantiate from arguments because actual and formal argument lists differ in length   helperFunctionsTests.ceylon /parcey/source/test/com/athaydes/parcey Unknown Ceylon Backend Error

The definition of infix is this:

shared Parser<Result> infix<First, Second, Result>(
    Parser<First> first,
    Parser<Result>(Parser<First>, Parser<Second>) operator,
    Parser<Second> second)
        => operator(first, second);

The error showed up when I added the separatedBy function, which has this signature:

shared Parser<{Item*}> separatedBy<Item>(
    Parser<Anything> separator,
    Parser<{Item*}> parser,
    Integer minOccurrences = 0,
    String name = "")

Hope this is enough info. Let me know if you need more (the source code of this project is on GitHub if you need it, the link again).