eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
398 stars 62 forks source link

impossible `x of String` crashes Java backend compiler #7415

Closed jvasileff closed 6 years ago

jvasileff commented 6 years ago

The following unreasonable code (run() can never be called) crashes the Java backend.

void run(Comp<String> c) {
    String s = c of String;
}

interface Comp<T> of T given T satisfies Comp<T> {}
source/simple/run.ceylon:2: error: Ceylon backend error: incompatible types: Comp<String> cannot be converted to String
    String s = c of String;
               ^
Note: Created module simple/1.0.0
ceylon compile: Fatal error: The compiler exited abnormally (4) due to a bug in the compiler.
Please report it:
 https://github.com/ceylon/ceylon/issues/new
Please include:

* the stacktrace printed below
* a description of what you were trying to compile.

Thank you!
com.redhat.ceylon.compiler.CompilerBugException: Codegen Error
gavinking commented 6 years ago

Note that the problem here is that Comp<String> is actually an unpopulated type. And, while coverage analysis detects this, and treats it as Nothing, it is not a type that typechecker aggressively normalizes to Nothing.

gavinking commented 6 years ago

I fixed this.