From 8865229d8d49bc5e98844608b621ec6b2e280849 Mon Sep 17 00:00:00 2001 From: John Messerly Date: Tue, 2 Jun 2015 17:06:04 -0700 Subject: [PATCH] fixes #200, library prefixes for unknown imports Take 2. The first version passed checker_test but not inferred_type_test. The library prefix staticElement check needs to come first. R=vsm@google.com Review URL: https://codereview.chromium.org/1161603009 --- pkg/dev_compiler/lib/src/utils.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/dev_compiler/lib/src/utils.dart b/pkg/dev_compiler/lib/src/utils.dart index 4c7339520c67..96166b0998e1 100644 --- a/pkg/dev_compiler/lib/src/utils.dart +++ b/pkg/dev_compiler/lib/src/utils.dart @@ -207,8 +207,16 @@ _MemberTypeGetter _memberTypeGetter(ExecutableElement member) { return f; } -bool isDynamicTarget(Expression node) => - node != null && !isLibraryPrefix(node) && node.staticType.isDynamic; +bool isDynamicTarget(Expression node) { + if (node == null) return false; + + if (isLibraryPrefix(node)) return false; + + // Null type happens when we have unknown identifiers, like a dart: import + // that doesn't resolve. + var type = node.staticType; + return type == null || type.isDynamic; +} bool isLibraryPrefix(Expression node) => node is SimpleIdentifier && node.staticElement is PrefixElement;