Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implicit coercion of a value of type X to an unrelated type X

Hi
I have this error :

Implicit coercion of a value of type X to an unrelated type X

where X is the type of the object and yes it's type X to an unrelated type X. It appears 6 times in my project, in 3 differents .mxml file, in the script element. It's in 3 files that I'm not editing and the file I has changing has no link with the 3 files with the errors.

Here a line of code with the problem.

var loadApplicationEvent:LoadApplicationEvent = new LoadApplicationEvent(application);

It was working perfect an when it was compiling and other file that I changed, it put me and error.

Bug from Flash Builder or Flex? Or not?
How can I get ride of it?

like image 711
Snote Avatar asked Aug 03 '11 12:08

Snote


2 Answers

I just ran into this issue myself with Flash Builder 4.5. The return type is exactly as it should be.

The solution for me was to do a full rebuild of the project via: Project -> Clean.

like image 182
Chris Avatar answered Nov 15 '22 19:11

Chris


I have recently started having this problem with FlashBuilder and here's what I did.

Starting with:

    protected var _foo:FooType;
(X) public function get foo():FooType { return this._foo; }

(where (X) is the error in the form Snote described it, with X = FooType)

change to:

    protected var _foo:FooType;
    public function get foo():* { return this._foo; }

and rebuild. The * type always passes type checking no matter what, so the error disappears.

Then change it back:

    protected var _foo:FooType;
    public function get foo():FooType { return this._foo; }

The error message then disappears, at least for a while.

So far this technique seems to be reliable, if annoying.

like image 38
Eric deRiel Avatar answered Nov 15 '22 20:11

Eric deRiel