| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.resolver_test; | 5 library engine.resolver_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/context/context.dart' as newContext; | 9 import 'package:analyzer/src/context/context.dart' as newContext; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 12160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12171 VariableDeclaration declaration = | 12171 VariableDeclaration declaration = |
| 12172 identifier.getAncestor((node) => node is VariableDeclaration); | 12172 identifier.getAncestor((node) => node is VariableDeclaration); |
| 12173 expect(declaration.initializer.staticType.name, 'String'); | 12173 expect(declaration.initializer.staticType.name, 'String'); |
| 12174 expect(declaration.initializer.propagatedType, isNull); | 12174 expect(declaration.initializer.propagatedType, isNull); |
| 12175 } | 12175 } |
| 12176 | 12176 |
| 12177 void test_genericFunction() { | 12177 void test_genericFunction() { |
| 12178 if (!AnalysisEngine.instance.useTaskModel) { | 12178 if (!AnalysisEngine.instance.useTaskModel) { |
| 12179 return; | 12179 return; |
| 12180 } | 12180 } |
| 12181 // TODO(jmesserly): we're missing a case in the parser for the return type, | 12181 _resolveTestUnit(r'/*=T*/ f/*<T>*/(/*=T*/ x) => null;'); |
| 12182 // so "dynamic" must be used to workaround this. | |
| 12183 _resolveTestUnit(r''' | |
| 12184 dynamic/*=T*/ f/*<T>*/(/*=T*/ x) => null; | |
| 12185 '''); | |
| 12186 SimpleIdentifier f = _findIdentifier('f'); | 12182 SimpleIdentifier f = _findIdentifier('f'); |
| 12187 FunctionElementImpl e = f.staticElement; | 12183 FunctionElementImpl e = f.staticElement; |
| 12188 expect(e.typeParameters.toString(), '[T]'); | 12184 expect(e.typeParameters.toString(), '[T]'); |
| 12189 expect(e.type.typeParameters.toString(), '[T]'); | 12185 expect(e.type.typeParameters.toString(), '[T]'); |
| 12190 expect(e.type.typeParameters[0].type, e.type.typeArguments[0]); | 12186 expect(e.type.typeParameters[0].type, e.type.typeArguments[0]); |
| 12191 expect(e.type.toString(), '(T) → T'); | 12187 expect(e.type.toString(), '(T) → T'); |
| 12192 | 12188 |
| 12193 // Substitute for T | 12189 // Substitute for T |
| 12194 DartType t = e.typeParameters[0].type; | 12190 DartType t = e.typeParameters[0].type; |
| 12195 FunctionType ft = e.type.substitute2([typeProvider.stringType], [t]); | 12191 FunctionType ft = e.type.substitute2([typeProvider.stringType], [t]); |
| (...skipping 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15212 | 15208 |
| 15213 void _resolveTestUnit(String code) { | 15209 void _resolveTestUnit(String code) { |
| 15214 testCode = code; | 15210 testCode = code; |
| 15215 testSource = addSource(testCode); | 15211 testSource = addSource(testCode); |
| 15216 LibraryElement library = resolve2(testSource); | 15212 LibraryElement library = resolve2(testSource); |
| 15217 assertNoErrors(testSource); | 15213 assertNoErrors(testSource); |
| 15218 verify([testSource]); | 15214 verify([testSource]); |
| 15219 testUnit = resolveCompilationUnit(testSource, library); | 15215 testUnit = resolveCompilationUnit(testSource, library); |
| 15220 } | 15216 } |
| 15221 } | 15217 } |
| OLD | NEW |