Merge branch 'SDK_AT_HEAD' into master
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 027dba4..dc1d0bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## Unpublished
+
+## 0.0.17+5
+
+- Fixed an issue where a corrupt URI would crash the plugin on windows.
+
 ## 0.0.17+4
 
 - Refactored how non-angular expressions (`new`, `+=`, `..`, etc.) are detected.
diff --git a/angular_analyzer_plugin/analysis_options.yaml b/angular_analyzer_plugin/analysis_options.yaml
index c01b1e2..28edd97 100644
--- a/angular_analyzer_plugin/analysis_options.yaml
+++ b/angular_analyzer_plugin/analysis_options.yaml
@@ -8,7 +8,6 @@
 
 linter:
   rules:
-    - prefer_final_locals
     - always_declare_return_types
     - always_put_control_body_on_new_line
     - always_require_non_null_named_parameters
diff --git a/angular_analyzer_plugin/lib/plugin.dart b/angular_analyzer_plugin/lib/plugin.dart
index 8ff81a3..1b0575a 100644
--- a/angular_analyzer_plugin/lib/plugin.dart
+++ b/angular_analyzer_plugin/lib/plugin.dart
@@ -153,7 +153,7 @@
   @override
   Future<NavigationRequest> getNavigationRequest(
       plugin.AnalysisGetNavigationParams parameters) async {
-    final AngularDriver driver = driverForPath(parameters.file);
+    final driver = driverForPath(parameters.file) as AngularDriver;
     final isHtml = parameters.file.endsWith('.html');
     final result = isHtml
         ? await driver.requestHtmlResult(parameters.file)
diff --git a/angular_analyzer_plugin/lib/src/angular_driver.dart b/angular_analyzer_plugin/lib/src/angular_driver.dart
index e590c71..94790c6 100644
--- a/angular_analyzer_plugin/lib/src/angular_driver.dart
+++ b/angular_analyzer_plugin/lib/src/angular_driver.dart
@@ -227,9 +227,9 @@
       return null;
     }
 
-    final context = dartResult.unit.element.context;
+    final context = dartResult.unit.declaredElement.context;
     final ast = dartResult.unit;
-    final source = dartResult.unit.element.source;
+    final source = dartResult.unit.declaredElement.source;
     final extractor =
         new DirectiveExtractor(ast, context.typeProvider, source, context);
     final topLevels = extractor.getAngularTopLevels();
diff --git a/angular_analyzer_plugin/lib/src/completion.dart b/angular_analyzer_plugin/lib/src/completion.dart
index 69563db..8b8c3f7 100644
--- a/angular_analyzer_plugin/lib/src/completion.dart
+++ b/angular_analyzer_plugin/lib/src/completion.dart
@@ -1011,7 +1011,7 @@
         continue;
       }
 
-      final Component component = directive;
+      final component = directive as Component;
       final view = component?.view;
       if (view == null) {
         continue;
diff --git a/angular_analyzer_plugin/lib/src/directive_extraction.dart b/angular_analyzer_plugin/lib/src/directive_extraction.dart
index 0025846..bb6d018 100644
--- a/angular_analyzer_plugin/lib/src/directive_extraction.dart
+++ b/angular_analyzer_plugin/lib/src/directive_extraction.dart
@@ -165,7 +165,7 @@
   /// Returns `null` if not an Angular annotation.
   AngularAnnotatedClass _getAngularAnnotatedClass(
       ast.ClassDeclaration classDeclaration) {
-    _currentClassElement = classDeclaration.element;
+    _currentClassElement = classDeclaration.declaredElement;
     _bindingTypeSynthesizer = new BindingTypeSynthesizer(
         _currentClassElement, _typeProvider, _context, errorReporter);
     // TODO(scheglov) add support for all the arguments
@@ -237,7 +237,7 @@
   /// Returns `null` if not an Angular annotation.
   FunctionalDirective _getFunctionalDirective(
       ast.FunctionDeclaration functionDeclaration) {
-    var functionElement = functionDeclaration.element;
+    final functionElement = functionDeclaration.declaredElement;
     if (functionElement is FunctionElement) {
       final annotationNode = functionDeclaration.metadata.firstWhere(
           (ann) => isAngularAnnotation(ann, 'Directive'),
@@ -516,13 +516,13 @@
     PropertyAccessorElement property;
     if (node is ast.FieldDeclaration && node.fields.variables.length == 1) {
       final variable = node.fields.variables.first;
-      final fieldElement = variable.element as FieldElement;
+      final fieldElement = variable.declaredElement as FieldElement;
       property = isInput ? fieldElement.setter : fieldElement.getter;
     } else if (node is ast.MethodDeclaration) {
       if (isInput && node.isSetter) {
-        property = node.element as PropertyAccessorElement;
+        property = node.declaredElement as PropertyAccessorElement;
       } else if (isOutput && node.isGetter) {
-        property = node.element as PropertyAccessorElement;
+        property = node.declaredElement as PropertyAccessorElement;
       }
     }
 
diff --git a/angular_analyzer_plugin/lib/src/directive_linking.dart b/angular_analyzer_plugin/lib/src/directive_linking.dart
index 6bd00a9..b95276f 100644
--- a/angular_analyzer_plugin/lib/src/directive_linking.dart
+++ b/angular_analyzer_plugin/lib/src/directive_linking.dart
@@ -849,7 +849,7 @@
       return;
     }
 
-    final Component component = directive;
+    final component = directive as Component;
 
     if (component?.view?.exports == null) {
       return;
diff --git a/angular_analyzer_plugin/lib/src/navigation.dart b/angular_analyzer_plugin/lib/src/navigation.dart
index 8be5fbc..6b82b12 100644
--- a/angular_analyzer_plugin/lib/src/navigation.dart
+++ b/angular_analyzer_plugin/lib/src/navigation.dart
@@ -18,7 +18,7 @@
       NavigationRequest baseRequest, NavigationCollector collector,
       {bool templatesOnly: false}) {
     // cast this
-    final AngularNavigationRequest request = baseRequest;
+    final request = baseRequest as AngularNavigationRequest;
     final length = request.length;
     final offset = request.offset;
     final result = request.result;
diff --git a/angular_analyzer_plugin/lib/src/pipe_extraction.dart b/angular_analyzer_plugin/lib/src/pipe_extraction.dart
index 81f0912..d7d632b 100644
--- a/angular_analyzer_plugin/lib/src/pipe_extraction.dart
+++ b/angular_analyzer_plugin/lib/src/pipe_extraction.dart
@@ -1,4 +1,3 @@
-import 'package:analyzer/analyzer.dart' as analyzer;
 import 'package:analyzer/dart/ast/ast.dart' as ast;
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/src/dart/ast/utilities.dart' as utils;
@@ -60,7 +59,7 @@
     }
     for (final parameter in parameters) {
       // If named or positional
-      if (parameter.parameterKind == analyzer.ParameterKind.NAMED) {
+      if (parameter.isNamed) {
         errorReporter.reportErrorForElement(
             AngularWarningCode.PIPE_TRANSFORM_NO_NAMED_ARGS, parameter);
         continue;
@@ -77,7 +76,7 @@
   /// Returns an Angular [Pipe] for the given [node].
   /// Returns `null` if not an Angular @Pipe annotation.
   Pipe _createPipe(ast.ClassDeclaration classDeclaration, ast.Annotation node) {
-    _currentClassElement = classDeclaration.element;
+    _currentClassElement = classDeclaration.declaredElement;
     if (isAngularAnnotation(node, 'Pipe')) {
       String pipeName;
       int pipeNameOffset;
diff --git a/angular_analyzer_plugin/lib/src/resolver.dart b/angular_analyzer_plugin/lib/src/resolver.dart
index 846bdd3..7e046b6 100644
--- a/angular_analyzer_plugin/lib/src/resolver.dart
+++ b/angular_analyzer_plugin/lib/src/resolver.dart
@@ -1265,7 +1265,7 @@
   }
 
   DartType _getIterableItemType(Expression expression) {
-    final itemsType = expression.bestType;
+    final itemsType = expression.staticType;
     if (itemsType is InterfaceType) {
       final iteratorType = _lookupGetterReturnType(itemsType, 'iterator');
       if (iteratorType is InterfaceType) {
@@ -1621,7 +1621,8 @@
     // half-complete-code case: ensure the expression is actually there
     if (attribute.expression != null &&
         !typeSystem.isAssignableTo(
-            attribute.expression.bestType, typeProvider.boolType)) {
+            attribute.expression.staticType ?? typeProvider.dynamicType,
+            typeProvider.boolType)) {
       errorListener.onError(new AnalysisError(
         templateSource,
         attribute.valueOffset,
@@ -1766,7 +1767,8 @@
       // half-complete-code case: ensure the expression is actually there
       if (attribute.expression != null &&
           !typeSystem.isAssignableTo(
-              attribute.expression.bestType, typeProvider.numType)) {
+              attribute.expression.staticType ?? typeProvider.dynamicType,
+              typeProvider.numType)) {
         errorListener.onError(new AnalysisError(
             templateSource,
             attribute.valueOffset,
@@ -1809,13 +1811,17 @@
           // half-complete-code case: ensure the expression is actually there
           if (attribute.expression != null &&
               !typeSystem.isAssignableTo(
-                  eventType, attribute.expression.bestType)) {
+                  eventType,
+                  attribute.expression.staticType ??
+                      typeProvider.dynamicType)) {
             errorListener.onError(new AnalysisError(
                 templateSource,
                 attribute.valueOffset,
                 attribute.value.length,
-                AngularWarningCode.TWO_WAY_BINDING_OUTPUT_TYPE_ERROR,
-                [output.eventType, attribute.expression.bestType]));
+                AngularWarningCode.TWO_WAY_BINDING_OUTPUT_TYPE_ERROR, [
+              output.eventType,
+              attribute.expression.staticType ?? typeProvider.dynamicType
+            ]));
           }
         }
       }
@@ -1837,7 +1843,7 @@
       ExpressionBoundAttribute attr, InputElement input) {
     // half-complete-code case: ensure the expression is actually there
     if (attr.expression != null) {
-      final attrType = attr.expression.bestType;
+      final attrType = attr.expression.staticType ?? typeProvider.dynamicType;
       final inputType = input.setterType;
       final securityContext = input.securityContext;
 
@@ -2006,7 +2012,7 @@
 
   @override
   void visitSimpleIdentifier(SimpleIdentifier node) {
-    final dartElement = node.bestElement;
+    final dartElement = node.staticElement;
     if (dartElement != null) {
       final angularElement =
           dartToAngularMap[dartElement] ?? new DartElement(dartElement);
diff --git a/angular_analyzer_plugin/lib/src/standard_components.dart b/angular_analyzer_plugin/lib/src/standard_components.dart
index e89a9a6..d0793e2 100644
--- a/angular_analyzer_plugin/lib/src/standard_components.dart
+++ b/angular_analyzer_plugin/lib/src/standard_components.dart
@@ -52,7 +52,7 @@
 
   @override
   void visitClassDeclaration(ast.ClassDeclaration node) {
-    classElement = node.element;
+    classElement = node.declaredElement;
     super.visitClassDeclaration(node);
     if (classElement.name == 'HtmlElement') {
       final outputElements = _buildOutputs(true);
@@ -85,10 +85,10 @@
     super.visitCompilationUnit(unit);
 
     missingOutputs.forEach((name, type) {
-      final namespace = unit.element.library.publicNamespace;
-      final ClassElement eventClass = namespace.get(type);
-      events[name] = new OutputElement(
-          name, null, null, unit.element.source, null, null, eventClass.type);
+      final namespace = unit.declaredElement.library.publicNamespace;
+      final eventClass = namespace.get(type) as ClassElement;
+      events[name] = new OutputElement(name, null, null,
+          unit.declaredElement.source, null, null, eventClass.type);
     });
   }
 
@@ -324,11 +324,12 @@
       {ResolvedUnitResult angularResult,
       ResolvedUnitResult securityResult,
       ResolvedUnitResult protoSecurityResult}) {
-    final ng = angularResult.unit.element.library.exportNamespace;
-    final security = securityResult.unit.element.library.exportNamespace;
+    final ng = angularResult.unit.declaredElement.library.exportNamespace;
+    final security =
+        securityResult.unit.declaredElement.library.exportNamespace;
     final protoSecurity = protoSecurityResult == null
         ? null
-        : protoSecurityResult.unit.element.library.exportNamespace;
+        : protoSecurityResult.unit.declaredElement.library.exportNamespace;
 
     List<DartType> interfaceTypes(List<Element> elements) => elements
         .whereType<ClassElement>()
diff --git a/angular_analyzer_plugin/lib/src/view_extraction.dart b/angular_analyzer_plugin/lib/src/view_extraction.dart
index 2d42c8a..d318d84 100644
--- a/angular_analyzer_plugin/lib/src/view_extraction.dart
+++ b/angular_analyzer_plugin/lib/src/view_extraction.dart
@@ -58,7 +58,7 @@
     final exceptionHandler = new ng_ast.RecoveringExceptionHandler();
     rawAst = ng_ast.parse(
       content,
-      sourceUrl: source.toString(),
+      sourceUrl: source.uri.toString(),
       desugar: false,
       parseExpressions: false,
       exceptionHandler: exceptionHandler,
@@ -213,7 +213,7 @@
     final views = <View>[];
     for (final unitMember in unit.declarations) {
       if (unitMember is ast.ClassDeclaration) {
-        final classElement = unitMember.element;
+        final classElement = unitMember.declaredElement;
         ast.Annotation componentAnnotation;
 
         for (final annotation in unitMember.metadata) {
diff --git a/angular_analyzer_plugin/pubspec.yaml b/angular_analyzer_plugin/pubspec.yaml
index 4146594..0b904f9 100644
--- a/angular_analyzer_plugin/pubspec.yaml
+++ b/angular_analyzer_plugin/pubspec.yaml
@@ -1,5 +1,5 @@
 name: angular_analyzer_plugin
-version: 0.0.17+4
+version: 0.0.17+5
 description: Dart analyzer plugin for Angular 2+
 authors:
   - Konstantin Scheglov <[email protected]>
@@ -9,10 +9,10 @@
 environment:
   sdk: '>=2.0.0-dev.0.0 <3.0.0'
 dependencies:
-  analyzer: '0.33.1'
+  analyzer: '0.34.2'
   plugin: '^0.2.0'
   #  tuple: '^1.0.1' Does not yet support Dart 2
-  analyzer_plugin: '0.0.1-alpha.5'
+  analyzer_plugin: '0.0.1-alpha.6'
   angular_ast: '^0.5.0'
   meta: ^1.0.2
   yaml: ^2.1.2
diff --git a/angular_analyzer_plugin/test/abstract_angular.dart b/angular_analyzer_plugin/test/abstract_angular.dart
index b9573ce..83cd19d 100644
--- a/angular_analyzer_plugin/test/abstract_angular.dart
+++ b/angular_analyzer_plugin/test/abstract_angular.dart
@@ -28,15 +28,15 @@
 
 void assertComponentReference(
     ResolvedRange resolvedRange, Component component) {
-  final ElementNameSelector selector = component.selector;
+  final selector = component.selector as ElementNameSelector;
   final element = resolvedRange.element;
   expect(element, selector.nameElement);
   expect(resolvedRange.range.length, selector.nameElement.name.length);
 }
 
 PropertyAccessorElement assertGetter(ResolvedRange resolvedRange) {
-  final PropertyAccessorElement element =
-      (resolvedRange.element as DartElement).element;
+  final element =
+      (resolvedRange.element as DartElement).element as PropertyAccessorElement;
   expect(element.isGetter, isTrue);
   return element;
 }
diff --git a/angular_analyzer_plugin/test/angular_driver_test.dart b/angular_analyzer_plugin/test/angular_driver_test.dart
index 52a0494d1c..329e090 100644
--- a/angular_analyzer_plugin/test/angular_driver_test.dart
+++ b/angular_analyzer_plugin/test/angular_driver_test.dart
@@ -966,14 +966,14 @@
     expect(childrens, hasLength(1));
     expect(
         childrens.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType children = childrens.first.query;
+    final children = childrens.first.query as DirectiveQueriedChildType;
 
     expect(children.directive, equals(directives[1]));
 
     final childs = component.contentChilds;
     expect(childs, hasLength(1));
     expect(childs.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType child = childs.first.query;
+    final child = childs.first.query as DirectiveQueriedChildType;
 
     expect(child.directive, equals(directives[1]));
     // validate
@@ -1000,7 +1000,7 @@
     final childs = component.contentChilds;
     expect(childs, hasLength(1));
     expect(childs.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType child = childs.first.query;
+    final child = childs.first.query as DirectiveQueriedChildType;
 
     expect(child.directive, equals(directives[1]));
     // validate
@@ -1027,7 +1027,7 @@
     final childs = component.contentChilds;
     expect(childs, hasLength(1));
     expect(childs.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType child = childs.first.query;
+    final child = childs.first.query as DirectiveQueriedChildType;
 
     expect(child.directive, equals(directives[1]));
     // validate
@@ -1077,7 +1077,7 @@
     final childs = component.contentChilds;
     expect(childs, hasLength(1));
     expect(childs.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType child = childs.first.query;
+    final child = childs.first.query as DirectiveQueriedChildType;
     expect(child.directive, equals(directives[1]));
 
     // validate
@@ -1151,7 +1151,7 @@
     final childs = component.contentChilds;
     expect(childs, hasLength(1));
     expect(childs.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType child = childs.first.query;
+    final child = childs.first.query as DirectiveQueriedChildType;
     expect(child.directive, equals(directives[1]));
 
     // validate
@@ -1237,43 +1237,44 @@
     final childs = component.contentChilds;
     expect(childs, hasLength(6));
 
-    final LetBoundQueriedChildType childDirective = childs
+    final childDirective = childs
         .singleWhere((c) => c.field.fieldName == "contentChildDirective")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childDirective, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childDirective.letBoundName, equals("foo"));
     expect(childDirective.containerType.toString(), equals("ContentChildComp"));
 
-    final LetBoundQueriedChildType childTemplate =
-        childs.singleWhere((c) => c.field.fieldName == "contentChildTpl").query;
+    final childTemplate = childs
+        .singleWhere((c) => c.field.fieldName == "contentChildTpl")
+        .query as LetBoundQueriedChildType;
     expect(childTemplate, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childTemplate.letBoundName, equals("fooTpl"));
     expect(childTemplate.containerType.toString(), equals("TemplateRef"));
 
-    final LetBoundQueriedChildType childElement = childs
+    final childElement = childs
         .singleWhere((c) => c.field.fieldName == "contentChildElem")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childElement, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childElement.letBoundName, equals("fooElem"));
     expect(childElement.containerType.toString(), equals("Element"));
 
-    final LetBoundQueriedChildType childHtmlElement = childs
+    final childHtmlElement = childs
         .singleWhere((c) => c.field.fieldName == "contentChildHtmlElem")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childHtmlElement, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childHtmlElement.letBoundName, equals("fooHtmlElem"));
     expect(childHtmlElement.containerType.toString(), equals("HtmlElement"));
 
-    final LetBoundQueriedChildType childElementRef = childs
+    final childElementRef = childs
         .singleWhere((c) => c.field.fieldName == "contentChildElemRef")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childElementRef, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childElementRef.letBoundName, equals("fooElemRef"));
     expect(childElementRef.containerType.toString(), equals("ElementRef"));
 
-    final LetBoundQueriedChildType childDynamic = childs
+    final childDynamic = childs
         .singleWhere((c) => c.field.fieldName == "contentChildDynamic")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childDynamic, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childDynamic.letBoundName, equals("fooDynamic"));
     expect(childDynamic.containerType.toString(), equals("dynamic"));
@@ -1303,7 +1304,7 @@
     expect(childrens, hasLength(1));
     expect(
         childrens.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType children = childrens.first.query;
+    final children = childrens.first.query as DirectiveQueriedChildType;
 
     expect(children.directive, equals(directives[1]));
     // validate
@@ -1331,7 +1332,7 @@
     expect(childrens, hasLength(1));
     expect(
         childrens.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType children = childrens.first.query;
+    final children = childrens.first.query as DirectiveQueriedChildType;
 
     expect(children.directive, equals(directives[1]));
     // validate
@@ -1359,7 +1360,7 @@
     expect(childrens, hasLength(1));
     expect(
         childrens.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType children = childrens.first.query;
+    final children = childrens.first.query as DirectiveQueriedChildType;
 
     expect(children.directive, equals(directives[1]));
     // validate
@@ -1387,7 +1388,7 @@
     expect(childrens, hasLength(1));
     expect(
         childrens.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType children = childrens.first.query;
+    final children = childrens.first.query as DirectiveQueriedChildType;
 
     expect(children.directive, equals(directives[1]));
     // validate
@@ -1437,7 +1438,7 @@
     expect(childrens, hasLength(1));
     expect(
         childrens.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType children = childrens.first.query;
+    final children = childrens.first.query as DirectiveQueriedChildType;
 
     expect(children.directive, equals(directives[1]));
     // validate
@@ -1487,7 +1488,7 @@
     expect(childrens, hasLength(1));
     expect(
         childrens.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType children = childrens.first.query;
+    final children = childrens.first.query as DirectiveQueriedChildType;
     expect(children.directive, equals(directives[1]));
 
     // validate
@@ -1521,7 +1522,7 @@
     expect(childrens, hasLength(1));
     expect(
         childrens.first.query, const isInstanceOf<DirectiveQueriedChildType>());
-    final DirectiveQueriedChildType children = childrens.first.query;
+    final children = childrens.first.query as DirectiveQueriedChildType;
     expect(children.directive, equals(directives[1]));
 
     // validate
@@ -1638,52 +1639,52 @@
     final childrens = component.contentChildren;
     expect(childrens, hasLength(7));
 
-    final LetBoundQueriedChildType childrenDirective = childrens
+    final childrenDirective = childrens
         .singleWhere((c) => c.field.fieldName == "contentChildDirective")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childrenDirective, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childrenDirective.letBoundName, equals("foo"));
     expect(
         childrenDirective.containerType.toString(), equals("ContentChildComp"));
 
-    final LetBoundQueriedChildType childrenTemplate = childrens
+    final childrenTemplate = childrens
         .singleWhere((c) => c.field.fieldName == "contentChildTpl")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childrenTemplate, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childrenTemplate.letBoundName, equals("fooTpl"));
     expect(childrenTemplate.containerType.toString(), equals("TemplateRef"));
 
-    final LetBoundQueriedChildType childrenElement = childrens
+    final childrenElement = childrens
         .singleWhere((c) => c.field.fieldName == "contentChildElem")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childrenElement, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childrenElement.letBoundName, equals("fooElem"));
     expect(childrenElement.containerType.toString(), equals("Element"));
 
-    final LetBoundQueriedChildType childrenHtmlElement = childrens
+    final childrenHtmlElement = childrens
         .singleWhere((c) => c.field.fieldName == "contentChildHtmlElem")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childrenHtmlElement, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childrenHtmlElement.letBoundName, equals("fooHtmlElem"));
     expect(childrenHtmlElement.containerType.toString(), equals("HtmlElement"));
 
-    final LetBoundQueriedChildType childrenElementRef = childrens
+    final childrenElementRef = childrens
         .singleWhere((c) => c.field.fieldName == "contentChildElemRef")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childrenElementRef, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childrenElementRef.letBoundName, equals("fooElemRef"));
     expect(childrenElementRef.containerType.toString(), equals("ElementRef"));
 
-    final LetBoundQueriedChildType childrenDynamic = childrens
+    final childrenDynamic = childrens
         .singleWhere((c) => c.field.fieldName == "contentChildDynamic")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childrenDynamic, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childrenDynamic.letBoundName, equals("fooDynamic"));
     expect(childrenDynamic.containerType.toString(), equals("dynamic"));
 
-    final LetBoundQueriedChildType childrenQueryList = childrens
+    final childrenQueryList = childrens
         .singleWhere((c) => c.field.fieldName == "contentChildQueryList")
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(childrenQueryList, const isInstanceOf<LetBoundQueriedChildType>());
     expect(childrenQueryList.letBoundName, equals("fooQueryList"));
     expect(
@@ -1776,22 +1777,23 @@
     final children = component.contentChilds;
     expect(children, hasLength(3));
 
-    final LetBoundQueriedChildType objectNotElem =
-        children.singleWhere((c) => c.field.fieldName == 'objectNotElem').query;
+    final objectNotElem = children
+        .singleWhere((c) => c.field.fieldName == 'objectNotElem')
+        .query as LetBoundQueriedChildType;
     expect(objectNotElem, const isInstanceOf<LetBoundQueriedChildType>());
     expect(objectNotElem.letBoundName, equals('el'));
     expect(objectNotElem.containerType.toString(), equals('Element'));
 
-    final LetBoundQueriedChildType elemNotHtmlElem = children
+    final elemNotHtmlElem = children
         .singleWhere((c) => c.field.fieldName == 'elemNotHtmlElem')
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(elemNotHtmlElem, const isInstanceOf<LetBoundQueriedChildType>());
     expect(elemNotHtmlElem.letBoundName, equals('el'));
     expect(elemNotHtmlElem.containerType.toString(), equals('HtmlElement'));
 
-    final LetBoundQueriedChildType objectNotHtmlElem = children
+    final objectNotHtmlElem = children
         .singleWhere((c) => c.field.fieldName == 'objectNotHtmlElem')
-        .query;
+        .query as LetBoundQueriedChildType;
     expect(objectNotHtmlElem, const isInstanceOf<LetBoundQueriedChildType>());
     expect(objectNotHtmlElem.letBoundName, equals('el'));
     expect(objectNotHtmlElem.containerType.toString(), equals('HtmlElement'));
@@ -3124,7 +3126,7 @@
 ''';
     final source = newSource('/test.dart', code);
     await getDirectives(source);
-    final Component component = directives.first;
+    final component = directives.first as Component;
     expect(component.view, isNotNull);
     expect(component.view.exports, hasLength(3));
     {
@@ -3959,7 +3961,7 @@
 ''';
     final source = newSource('/test.dart', code);
     await getDirectives(source);
-    final Component component = directives.first;
+    final component = directives.first as Component;
     expect(component.view, isNotNull);
     expect(component.view.exports, hasLength(2));
     {
@@ -4740,7 +4742,7 @@
 ''';
     final source = newSource('/test.dart', code);
     await getDirectives(source);
-    final Component component = directives.first;
+    final component = directives.first as Component;
     expect(component.view, isNotNull);
     expect(component.view.exports, hasLength(3));
     {
@@ -5038,7 +5040,7 @@
 ''';
     final source = newSource('/test.dart', code);
     await getDirectives(source);
-    final Component component = directives.first;
+    final component = directives.first as Component;
     expect(component.view, isNotNull);
     expect(component.view.exports, hasLength(2));
     {
diff --git a/angular_analyzer_plugin/test/element_assert.dart b/angular_analyzer_plugin/test/element_assert.dart
index 57a9b38..cdaee07 100644
--- a/angular_analyzer_plugin/test/element_assert.dart
+++ b/angular_analyzer_plugin/test/element_assert.dart
@@ -90,7 +90,7 @@
 
   DartElementAssert get dart {
     expect(element, const isInstanceOf<DartElement>());
-    final DartElement dartElement = element;
+    final dartElement = element as DartElement;
     return new DartElementAssert(dartElement.element, _dartSource, _dartCode);
   }
 
diff --git a/angular_analyzer_plugin/test/mock_sdk.dart b/angular_analyzer_plugin/test/mock_sdk.dart
index 3c3dcf7..057ad13 100644
--- a/angular_analyzer_plugin/test/mock_sdk.dart
+++ b/angular_analyzer_plugin/test/mock_sdk.dart
@@ -545,7 +545,7 @@
       : provider = resourceProvider ?? new resource.MemoryResourceProvider(),
         sdkLibraries = dartAsync ? _LIBRARIES : [_LIB_CORE],
         uriMap = dartAsync ? FULL_URI_MAP : NO_ASYNC_URI_MAP {
-    for (_MockSdkLibrary library in sdkLibraries) {
+    for (var library in sdkLibraries.cast<_MockSdkLibrary>()) {
       provider.newFile(provider.convertPath(library.path), library.content);
       library.parts.forEach((path, content) {
         provider.newFile(provider.convertPath(path), content);
@@ -592,7 +592,7 @@
       final libraryPath = provider.convertPath(library.path);
       if (filePath == libraryPath) {
         try {
-          final resource.File file = provider.getResource(filePath);
+          final file = provider.getResource(filePath) as resource.File;
           final dartUri = Uri.parse(library.shortName);
           return file.createSource(dartUri);
         } catch (exception) {
@@ -606,7 +606,7 @@
         final pathInLibrary = filePath.substring(libraryRootPath.length);
         final uriStr = '${library.shortName}/$pathInLibrary';
         try {
-          final resource.File file = provider.getResource(filePath);
+          final file = provider.getResource(filePath) as resource.File;
           final dartUri = Uri.parse(uriStr);
           return file.createSource(dartUri);
         } catch (exception) {
@@ -647,8 +647,8 @@
   Source mapDartUri(String dartUri) {
     final path = uriMap[dartUri];
     if (path != null) {
-      final resource.File file =
-          provider.getResource(provider.convertPath(path));
+      final file =
+          provider.getResource(provider.convertPath(path)) as resource.File;
       final uri = new Uri(scheme: 'dart', path: dartUri.substring(5));
       return file.createSource(uri);
     }
diff --git a/angular_analyzer_plugin/test/options_test.dart b/angular_analyzer_plugin/test/options_test.dart
index 031c2da..d032f8c 100644
--- a/angular_analyzer_plugin/test/options_test.dart
+++ b/angular_analyzer_plugin/test/options_test.dart
@@ -193,7 +193,7 @@
       custom_tag_names: true
 ''', null);
     expect(options.customTagNames, isNotNull);
-    expect(options.customTagNames, const isInstanceOf<List>());
+    expect(options.customTagNames, const TypeMatcher<List>());
     expect(options.customTagNames, isEmpty);
   }
 
@@ -242,7 +242,7 @@
   custom_tag_names: true
 ''', null);
     expect(options.customTagNames, isNotNull);
-    expect(options.customTagNames, const isInstanceOf<List>());
+    expect(options.customTagNames, const TypeMatcher<List>());
     expect(options.customTagNames, isEmpty);
   }
 
diff --git a/angular_analyzer_plugin/test/plugin_test.dart b/angular_analyzer_plugin/test/plugin_test.dart
index 47fafb5..112bbed 100644
--- a/angular_analyzer_plugin/test/plugin_test.dart
+++ b/angular_analyzer_plugin/test/plugin_test.dart
@@ -139,7 +139,7 @@
   // ignore: non_constant_identifier_names
   void test_createAnalysisDriver() {
     enableAnalyzerPluginsAngular();
-    final AngularDriver driver = plugin.createAnalysisDriver(root);
+    final driver = plugin.createAnalysisDriver(root) as AngularDriver;
 
     expect(driver, isNotNull);
     expect(driver.byteStore, isNotNull);
@@ -148,7 +148,7 @@
   // ignore: non_constant_identifier_names
   void test_createAnalysisDriver_containsDartDriver() {
     enableAnalyzerPluginsAngular();
-    final AngularDriver driver = plugin.createAnalysisDriver(root);
+    final driver = plugin.createAnalysisDriver(root) as AngularDriver;
 
     expect(driver, isNotNull);
     expect(driver.dartDriver, isNotNull);
@@ -167,7 +167,7 @@
       '  - bar',
       '  - baz',
     ]);
-    final AngularDriver driver = plugin.createAnalysisDriver(root);
+    final driver = plugin.createAnalysisDriver(root) as AngularDriver;
 
     expect(driver, isNotNull);
     expect(driver.options, isNotNull);
@@ -183,7 +183,7 @@
       '  - bar',
       '  - baz',
     ]);
-    final AngularDriver driver = plugin.createAnalysisDriver(root);
+    final driver = plugin.createAnalysisDriver(root) as AngularDriver;
 
     expect(driver, isNotNull);
     expect(driver.options, isNotNull);
@@ -194,7 +194,7 @@
   // ignore: non_constant_identifier_names
   void test_createAnalysisDriver_defaultOptions() {
     enableAnalyzerPluginsAngular();
-    final AngularDriver driver = plugin.createAnalysisDriver(root);
+    final driver = plugin.createAnalysisDriver(root) as AngularDriver;
 
     expect(driver, isNotNull);
     expect(driver.options, isNotNull);
diff --git a/angular_analyzer_plugin/test/resolver_test.dart b/angular_analyzer_plugin/test/resolver_test.dart
index 257544a..249825c 100644
--- a/angular_analyzer_plugin/test/resolver_test.dart
+++ b/angular_analyzer_plugin/test/resolver_test.dart
@@ -23,7 +23,7 @@
 
 void assertPropertyElement(AngularElement element,
     {nameMatcher, sourceMatcher}) {
-  expect(element, const isInstanceOf<InputElement>());
+  expect(element, const TypeMatcher<InputElement>());
   final inputElement = element;
   if (nameMatcher != null) {
     expect(inputElement.name, nameMatcher);
diff --git a/angular_analyzer_plugin/test/selector_test.dart b/angular_analyzer_plugin/test/selector_test.dart
index ee499ba..de7b806 100644
--- a/angular_analyzer_plugin/test/selector_test.dart
+++ b/angular_analyzer_plugin/test/selector_test.dart
@@ -930,11 +930,11 @@
 
   // ignore: non_constant_identifier_names
   void test_and() {
-    final AndSelector selector =
-        new SelectorParser(source, 10, '[ng-for][ng-for-of]').parse();
+    final selector = new SelectorParser(source, 10, '[ng-for][ng-for-of]')
+        .parse() as AndSelector;
     expect(selector.selectors, hasLength(2));
     {
-      final AttributeSelector subSelector = selector.selectors[0];
+      final subSelector = selector.selectors[0] as AttributeSelector;
       final nameElement = subSelector.nameElement;
       expect(nameElement.source, source);
       expect(nameElement.name, 'ng-for');
@@ -942,7 +942,7 @@
       expect(nameElement.nameLength, 'ng-for'.length);
     }
     {
-      final AttributeSelector subSelector = selector.selectors[1];
+      final subSelector = selector.selectors[1] as AttributeSelector;
       final nameElement = subSelector.nameElement;
       expect(nameElement.source, source);
       expect(nameElement.name, 'ng-for-of');
@@ -977,8 +977,8 @@
 
   // ignore: non_constant_identifier_names
   void test_attribute_hasValue() {
-    final AttributeSelector selector =
-        new SelectorParser(source, 10, '[kind=pretty]').parse();
+    final selector = new SelectorParser(source, 10, '[kind=pretty]').parse()
+        as AttributeSelector;
     {
       final nameElement = selector.nameElement;
       expect(nameElement.source, source);
@@ -991,12 +991,12 @@
 
   // ignore: non_constant_identifier_names
   void test_attribute_hasValueWithQuotes() {
-    final AndSelector selector =
+    final selector =
         new SelectorParser(source, 10, '''[single='quotes'][double="quotes"]''')
-            .parse();
+            .parse() as AndSelector;
     expect(selector.selectors, hasLength(2));
     {
-      final AttributeSelector subSelector = selector.selectors[0];
+      final subSelector = selector.selectors[0] as AttributeSelector;
       {
         final nameElement = subSelector.nameElement;
         expect(nameElement.source, source);
@@ -1006,7 +1006,7 @@
       expect(subSelector.value, 'quotes');
     }
     {
-      final AttributeSelector subSelector = selector.selectors[1];
+      final subSelector = selector.selectors[1] as AttributeSelector;
       {
         final nameElement = subSelector.nameElement;
         expect(nameElement.source, source);
@@ -1019,8 +1019,8 @@
 
   // ignore: non_constant_identifier_names
   void test_attribute_hasWildcard() {
-    final AttributeContainsSelector selector =
-        new SelectorParser(source, 10, '[kind*=pretty]').parse();
+    final selector = new SelectorParser(source, 10, '[kind*=pretty]').parse()
+        as AttributeContainsSelector;
     {
       final nameElement = selector.nameElement;
       expect(nameElement.source, source);
@@ -1033,8 +1033,8 @@
 
   // ignore: non_constant_identifier_names
   void test_attribute_noValue() {
-    final AttributeSelector selector =
-        new SelectorParser(source, 10, '[ng-for]').parse();
+    final selector =
+        new SelectorParser(source, 10, '[ng-for]').parse() as AttributeSelector;
     {
       final nameElement = selector.nameElement;
       expect(nameElement.source, source);
@@ -1059,24 +1059,24 @@
 
   // ignore: non_constant_identifier_names
   void test_attribute_startsWith() {
-    final AttributeStartsWithSelector selector =
-        new SelectorParser(source, 10, '[foo^=bar]').parse();
+    final selector = new SelectorParser(source, 10, '[foo^=bar]').parse()
+        as AttributeStartsWithSelector;
     expect(selector.nameElement.name, 'foo');
     expect(selector.value, 'bar');
   }
 
   // ignore: non_constant_identifier_names
   void test_attribute_startsWith_quoted() {
-    final AttributeStartsWithSelector selector =
-        new SelectorParser(source, 10, '[foo^="bar"]').parse();
+    final selector = new SelectorParser(source, 10, '[foo^="bar"]').parse()
+        as AttributeStartsWithSelector;
     expect(selector.nameElement.name, 'foo');
     expect(selector.value, 'bar');
   }
 
   // ignore: non_constant_identifier_names
   void test_attribute_textRegex() {
-    final AttributeValueRegexSelector selector =
-        new SelectorParser(source, 10, '[*=/pretty/]').parse();
+    final selector = new SelectorParser(source, 10, '[*=/pretty/]').parse()
+        as AttributeValueRegexSelector;
     expect(selector.regexpStr, 'pretty');
   }
 
@@ -1092,8 +1092,8 @@
 
   // ignore: non_constant_identifier_names
   void test_class() {
-    final ClassSelector selector =
-        new SelectorParser(source, 10, '.nice').parse();
+    final selector =
+        new SelectorParser(source, 10, '.nice').parse() as ClassSelector;
     final nameElement = selector.nameElement;
     expect(nameElement.source, source);
     expect(nameElement.name, 'nice');
@@ -1103,66 +1103,68 @@
 
   // ignore: non_constant_identifier_names
   void test_complex_ast() {
-    final OrSelector selector = new SelectorParser(
+    final selector = new SelectorParser(
             source, 10, 'aaa, bbb:not(ccc), :not(:not(ddd)[eee], fff[ggg])')
-        .parse();
+        .parse() as OrSelector;
 
     expect(
         selector.toString(),
         equals('aaa || bbb && :not(ccc) || '
             ':not(:not(ddd) && [eee] || fff && [ggg])'));
     {
-      final ElementNameSelector subSelector = selector.selectors[0];
+      final subSelector = selector.selectors[0] as ElementNameSelector;
       expect(subSelector.toString(), "aaa");
     }
     {
-      final AndSelector subSelector = selector.selectors[1];
+      final subSelector = selector.selectors[1] as AndSelector;
       expect(subSelector.toString(), "bbb && :not(ccc)");
       {
-        final ElementNameSelector subSelector2 = subSelector.selectors[0];
+        final subSelector2 = subSelector.selectors[0] as ElementNameSelector;
         expect(subSelector2.toString(), "bbb");
       }
       {
-        final NotSelector subSelector2 = subSelector.selectors[1];
+        final subSelector2 = subSelector.selectors[1] as NotSelector;
         expect(subSelector2.toString(), ":not(ccc)");
         {
-          final ElementNameSelector subSelector3 = subSelector2.condition;
+          final subSelector3 = subSelector2.condition as ElementNameSelector;
           expect(subSelector3.toString(), "ccc");
         }
       }
     }
     {
-      final NotSelector subSelector = selector.selectors[2];
+      final subSelector = selector.selectors[2] as NotSelector;
       expect(
           subSelector.toString(), ":not(:not(ddd) && [eee] || fff && [ggg])");
       {
-        final OrSelector subSelector2 = subSelector.condition;
+        final subSelector2 = subSelector.condition as OrSelector;
         expect(subSelector2.toString(), ":not(ddd) && [eee] || fff && [ggg]");
         {
-          final AndSelector subSelector3 = subSelector2.selectors[0];
+          final subSelector3 = subSelector2.selectors[0] as AndSelector;
           expect(subSelector3.toString(), ":not(ddd) && [eee]");
           {
-            final NotSelector subSelector4 = subSelector3.selectors[0];
+            final subSelector4 = subSelector3.selectors[0] as NotSelector;
             expect(subSelector4.toString(), ":not(ddd)");
             {
-              final ElementNameSelector subSelector5 = subSelector4.condition;
+              final subSelector5 =
+                  subSelector4.condition as ElementNameSelector;
               expect(subSelector5.toString(), "ddd");
             }
           }
           {
-            final AttributeSelector subSelector4 = subSelector3.selectors[1];
+            final subSelector4 = subSelector3.selectors[1] as AttributeSelector;
             expect(subSelector4.toString(), "[eee]");
           }
         }
         {
-          final AndSelector subSelector3 = subSelector2.selectors[1];
+          final subSelector3 = subSelector2.selectors[1] as AndSelector;
           expect(subSelector3.toString(), "fff && [ggg]");
           {
-            final ElementNameSelector subSelector4 = subSelector3.selectors[0];
+            final subSelector4 =
+                subSelector3.selectors[0] as ElementNameSelector;
             expect(subSelector4.toString(), "fff");
           }
           {
-            final AttributeSelector subSelector4 = subSelector3.selectors[1];
+            final subSelector4 = subSelector3.selectors[1] as AttributeSelector;
             expect(subSelector4.toString(), "[ggg]");
           }
         }
@@ -1172,15 +1174,15 @@
 
   // ignore: non_constant_identifier_names
   void test_contains() {
-    final ContainsSelector selector =
-        new SelectorParser(source, 10, ':contains(/aaa/)').parse();
+    final selector = new SelectorParser(source, 10, ':contains(/aaa/)').parse()
+        as ContainsSelector;
     expect(selector.regex, 'aaa');
   }
 
   // ignore: non_constant_identifier_names
   void test_elementName() {
-    final ElementNameSelector selector =
-        new SelectorParser(source, 10, 'text-panel').parse();
+    final selector = new SelectorParser(source, 10, 'text-panel').parse()
+        as ElementNameSelector;
     final nameElement = selector.nameElement;
     expect(nameElement.source, source);
     expect(nameElement.name, 'text-panel');
@@ -1190,10 +1192,10 @@
 
   // ignore: non_constant_identifier_names
   void test_not() {
-    final NotSelector selector =
-        new SelectorParser(source, 10, ':not(aaa)').parse();
+    final selector =
+        new SelectorParser(source, 10, ':not(aaa)').parse() as NotSelector;
     {
-      final ElementNameSelector condition = selector.condition;
+      final condition = selector.condition as ElementNameSelector;
       final nameElement = condition.nameElement;
       expect(nameElement.source, source);
       expect(nameElement.name, 'aaa');
@@ -1204,11 +1206,11 @@
 
   // ignore: non_constant_identifier_names
   void test_or() {
-    final OrSelector selector =
-        new SelectorParser(source, 10, 'aaa,bbb').parse();
+    final selector =
+        new SelectorParser(source, 10, 'aaa,bbb').parse() as OrSelector;
     expect(selector.selectors, hasLength(2));
     {
-      final ElementNameSelector subSelector = selector.selectors[0];
+      final subSelector = selector.selectors[0] as ElementNameSelector;
       final nameElement = subSelector.nameElement;
       expect(nameElement.source, source);
       expect(nameElement.name, 'aaa');
@@ -1216,7 +1218,7 @@
       expect(nameElement.nameLength, 'aaa'.length);
     }
     {
-      final ElementNameSelector subSelector = selector.selectors[1];
+      final subSelector = selector.selectors[1] as ElementNameSelector;
       final nameElement = subSelector.nameElement;
       expect(nameElement.source, source);
       expect(nameElement.name, 'bbb');