ceylon / ceylon-spec

DEPRECATED
Apache License 2.0
108 stars 34 forks source link

`could not determine type of function or value reference` compiler error #1414

Closed sgalles closed 9 years ago

sgalles commented 9 years ago

The bug is very sensitive to the names of the packages and the names of the ceylon source files, so I've attached a Ceylon project that is affected by this issue in this message https://groups.google.com/d/msg/ceylon-dev/2sw-AU8f05E/5Pdi63MIBwAJ

But basically, in one package I have

import foo.bar {
    Bar
}
shared alias Foo<Item=Bar> => [Item];

and in an other package

import foo {
    Foo
}
shared class Bar(){}

shared void foo(Foo<> f){}
shared void bar(){
    foo([Bar()]);    
}

This should compile, but with the JVM CLI compiler :

source\foo\bar\Bar.ceylon:8: error: could not determine type of function or value reference: 'foo'
        foo([Bar()]);
        ^
source\foo\bar\Bar.ceylon:8: error: parameter type could not be determined: 'f' of 'foo'
        foo([Bar()]);

and with the JS CLI compiler

Error: Errors found. Compilation stopped.
Note: Created module foo/1.0.0
error encountered [parameter type could not be determined: 'f' of 'foo'] at 8:5-8:11 of Bar.ceylon
error encountered [could not determine type of function or value reference: 'foo'] at 8:1-8:3 of Bar.ceylon
ceylon compile-js: 2 errors.

In eclipse, sometimes the error does not show up and you have to clean the project to make the compilation fail.

gavinking commented 9 years ago

The cause of this bug is at AnalyzerUtil:274—the call to Type.involvesDeclaration().

gavinking commented 9 years ago

OMG, after hours staring at this, in the end the fix was simple!

gavinking commented 9 years ago

Test added. Thanks for reporting @sgalles.