-
Notifications
You must be signed in to change notification settings - Fork 26
Migrate DDC to new Analyzer task model #342
Comments
For const fields, a declaration in Dart: const GLOBAL_FUNCTIONS = 'globalFunctions'; is producing the following JS with a cast to _foreign_helper.JS_EMBEDDED_GLOBAL("", dart.as(_js_embedded_names.GLOBAL_FUNCTIONS, core.String)); |
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'm seeing the following type promo regression: Original Dart code: if (index is num && index == index.toInt()) {
_checkIndex(index);
} Old generated JS: if (typeof index == 'number' && index == index[dartx.toInt]()) {
this[_checkIndex](index);
} New (with task model CL) generated JS: if (typeof index == 'number' && dart.equals(index, dart.dsend(index, 'toInt'))) {
this[_checkIndex](dart.as(index, core.int));
} We seem to have lost the type promotion on index. |
This code is now neither triggering an error/warning/info nor generating a dinvoke on the call to toString(): main() {
dynamic toString = () => null;
toString = (x) => x;
toString();
} |
Parameter inference appears to broken for setter override. We used to infer the setter type for Child.x, but with the task model version, we're getting an override error. abstract class Base {
void set x(int value);
}
class Child extends Base {
void set x(value) {}
} |
I think that's in strong_mode.dart, _inferAccessor ... I see it setting the field type and getter return type but not the setter parameter type. Also FWIW, if there's no getter, it doesn't look like it will hit the setter path at all |
I'm seeing the following problem with inference that appears to be related to generic type param substitution. I'm now getting an analyzer message "A value of type 'E' cannot be assigned to a variable of type 'String' (foo.dart, line 14, col 14)" in main below. E is not in scope here. It appears that B.self is inferred to type A. class A<E> {
E value;
A<E> get self => this;
}
class B<E> extends A<E> {
B(E v) { this.value = v; }
get self => this;
}
void main() {
String v = new B<String>('hello').self.value;
print(v);
} |
edit: guess here was wrong. see #342 (comment)
|
|
here's the setter fix: https://codereview.chromium.org/1359243003 ... working on generics |
Hmmm, I'm not able to reproduce the generics issue with InstanceMemberInferrer. Going to investigate further... EDIT: further investigation, it seems InheritanceManager.lookupOverrides does the correct substitution (it returns a PropertyAccessorMember which has correct return type |
This change also decouples setters and getters, which matches what DDC currently does. The benefit is they're inferred as independent methods, which allows code reuse between method/getter/setters. It also prevents ordering issues that might occur otherwise (i.e. if getter inference considers setter's type, and setter inference considers the getter's type). More context: dart-archive/dev_compiler#342 (comment) [email protected] Review URL: https://codereview.chromium.org//1359243003 .
Okay progress on the generic issue: the test is a little more tricky, it doesn't look like a problem with inferred return types. It looks like the methodinvocation node's methodname is not pointing at the right staticElement and/or has the incorrect staticType. So it might be related to the other issue where we get the function type that corresponds to the method's SimpleIdentifier tear-off. edit: I'm going to see what the data structures looked like when our old implementation reached this point in the code. edit2: confirmed, it's the MethodInvocation.methodName.staticElement. In the old code/analyzer, it was correctly substituted generic |
Think I have the generics issue figured out. If we're going to infer a return or parameter type that has an unsubstituted generic arg, we need to make sure the FunctionType also has a generic parameter. Otherwise substitution will fail. Tests & fix here: https://codereview.chromium.org/1364353003 edit: CL is landed, so should be fixed now |
…for an ExecutableElement This matches what resolver.dart visitMethodDeclaration does when it creats the FunctionTypeImpl for the method. So we want to preserve these generic type args when we're building the new inferred function type, otherwise we'll fail to substitute them later on. Context: dart-archive/dev_compiler#342 (comment) [email protected] Review URL: https://codereview.chromium.org//1364353003 .
@vsmenon I believe all issues are now triaged in checker_test and inference_test. I created 4 different bugs, I'll create bugs as well for the 3 issues that don't have bugs yet. |
@vsmenon -- do you know if this still repros: "Const type inference doesn't work - at least in some cases." |
Also if you recall, what was the context for "Not recognizing / trigger some dinvokes (see below)" |
Filed bugs 346-352 for following up with the various issues. Let me know if you remember what these two were, and we can split off bugs for them as well:
|
CL out for #356 |
This is landed. |
🎆 |
AWESOME! |
I have a CL out for this: https://codereview.chromium.org/1355893003/
It's blocked by the following regressions / issues I've hit so far:
JS('-dynamic', ...)
.dynamic
, see task model: inferring type of variable that is explicitdynamic
#349The text was updated successfully, but these errors were encountered: