Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart

Issue 1318043005: Support user generated custom native JS classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: ptal Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
diff --git a/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart b/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
index fccfb8042bee4f2fb745432b3d309880a72bc3d1..8f0f26b169853be4fbcac6fef2ff4efa52a5a480 100644
--- a/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
@@ -454,7 +454,8 @@ abstract class InferrerEngine<T, V extends TypeSystem>
bool isNativeElement(Element element) {
if (element.isNative) return true;
return element.isClassMember
- && element.enclosingClass.isNative
+ && (element.enclosingClass.isNative
+ || element.enclosingClass.isJsInterop)
&& element.isField;
}
@@ -1610,6 +1611,9 @@ class SimpleTypeInferrerVisitor<T>
// we have to forward the call to the effective target of the
// factory.
if (element.isFactoryConstructor) {
+
+ if (element.isJsInterop) return types.dynamicType;
+
// TODO(herhut): Remove the while loop once effectiveTarget forwards to
// patches.
while (element.isFactoryConstructor) {
@@ -1621,6 +1625,7 @@ class SimpleTypeInferrerVisitor<T>
if (compiler.backend.isForeign(element)) {
return handleForeignSend(node, element);
}
+
Selector selector = elements.getSelector(node);
TypeMask mask = elements.getTypeMask(node);
// In erroneous code the number of arguments in the selector might not
@@ -2094,7 +2099,9 @@ class SimpleTypeInferrerVisitor<T>
assert(!element.isFactoryConstructor ||
!(element as ConstructorElement).isRedirectingFactory);
// Erroneous elements may be unresolved, for example missing getters.
+
if (Elements.isUnresolved(element)) return types.dynamicType;
+
// TODO(herhut): should we follow redirecting constructors here? We would
// need to pay attention if the constructor is pointing to an erroneous
// element.
@@ -2124,6 +2131,7 @@ class SimpleTypeInferrerVisitor<T>
ast.Node receiver = send.receiver;
if (receiver != null) {
Element element = elements[receiver];
+
if (Elements.isLocal(element) && !capturedVariables.contains(element)) {
T refinedType = types.refineReceiver(
selector, mask, receiverType, send.isConditional);

Powered by Google App Engine
This is Rietveld 408576698