Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

task mode: field initializer inference is overriding explicit LHS type #350

Closed
jmesserly opened this issue Sep 25, 2015 · 2 comments
Closed

Comments

@jmesserly
Copy link
Contributor

From @vsmenon's comment:

For the field type inference issue, we're seeing extra casts like:

Zone._current = dart.as(zone, _RootZone);

even though _current is declared in Dart as:

  static Zone _current = _ROOT_ZONE;

It appears that the rhs expression type is incorrectly overriding the lhs declared type.

I've also seen this in 'casts in constant contexts' in checker test:

          class A {
            static const num n = 3.0;
            static const int i = /*info:AssignmentCast*/n;
            final int fi;
            const A(num a) : this.fi = /*info:DownCastImplicit*/a;
          }
          class B extends A {
            const B(Object a) : super(/*info:DownCastImplicit*/a);
          }
          void foo(Object o) {
            var a = const A(/*info:DownCastImplicit*/o);
          }

The i = n initializer fails with a static type error because it thinks n is double instead of num like it should be.

@jmesserly
Copy link
Contributor Author

@vsmenon and I confirmed this is fixed by https://codereview.chromium.org/1370793002/

@leafpetersen
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants