ceylon / ceylon.ast

Apache License 2.0
18 stars 3 forks source link

support specification statements in Interfaces #91

Closed jvasileff closed 9 years ago

jvasileff commented 9 years ago

This typechecks:

interface I1 {
    shared formal String something();
}

interface I2 satisfies I1 {
    something() => "";
}

but is not supported by InterfaceBody, and consequently blows up interfaceBodyToCeylon:

Exception in thread "main" ceylon.language.AssertionError "Assertion failed
    violated is JDeclaration statement"
    at ceylon.ast.redhat.interfaceBodyToCeylon_$2.$call$(InterfaceBody.ceylon:22)
    at ceylon.ast.redhat.interfaceBodyToCeylon_$2.$call$(InterfaceBody.ceylon:21)
    at ceylon.language.Iterable$impl$3$1$1.next(Iterable.ceylon:345)
lucaswerkmeister commented 9 years ago

Per spec, something() => ""; is a LazySpecification, which is a Statement, not a Declaration, and therefore not allowed in an InterfaceBody. As far as I can tell, it is a typechecker bug that I2 is not rejected. @gavinking?

(You can also see this in regular classes: this comment in LinkedList.ceylon is incorrect, since some shortcut refinements extend the initializer section all the way to the bottom of the file, as can be seen in the IDE.)

gavinking commented 9 years ago

No, it's a shortcut refinement, and totally allowed.

gavinking commented 9 years ago

Ah, but indeed the grammar in the spec does not make clear that shortcut refinements are allowed in interface bodies. I need to fix that.

gavinking commented 9 years ago

Fixed in https://github.com/ceylon/ceylon-spec/issues/1389.

jvasileff commented 9 years ago

As you can see, @lucaswerkmeister, this was a report for a future bug, which has now materialized. Or, more charitably, it is an enhancement request to bring Ceylon AST in compliance with the current Ceylon Language Specification.