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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_ast_test.dart

Issue 2782533002: Report errors for the new top-level inference rules. (Closed)
Patch Set: Update language_strong status for analyzer. Created 3 years, 9 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/analyzer/test/src/summary/resynthesize_ast_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
index 4fde69aa1d6d524f7f94f5cbeb6ea0a04a46d083..2cb5cc0d8ffd4b23129bb1c95837d581d2a10a64 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
@@ -4,8 +4,6 @@
library analyzer.test.src.summary.resynthesize_ast_test;
-import 'dart:async';
-
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
@@ -28,7 +26,6 @@ import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../context/abstract_context.dart';
-import '../task/strong/inferred_type_test.dart';
import 'element_text.dart';
import 'resynthesize_common.dart';
import 'summary_common.dart';
@@ -37,7 +34,6 @@ main() {
defineReflectiveSuite(() {
defineReflectiveTests(ResynthesizeAstSpecTest);
defineReflectiveTests(ResynthesizeAstStrongTest);
- defineReflectiveTests(AstInferredTypeTest);
defineReflectiveTests(ApplyCheckElementTextReplacements);
});
}
@@ -50,636 +46,6 @@ class ApplyCheckElementTextReplacements {
}
@reflectiveTest
-class AstInferredTypeTest extends AbstractResynthesizeTest
- with _AstResynthesizeTestMixin, InferredTypeMixin {
- @override
- bool get isStrongMode => true;
-
- @override
- bool get mayCheckTypesOfLocals => false;
-
- @override
- void addFile(String content, {String name: '/main.dart'}) {
- addLibrarySource(name, content);
- }
-
- @override
- Future<CompilationUnitElement> checkFileElement(String content) async {
- Source source = addSource('/main.dart', content);
- SummaryResynthesizer resynthesizer = _encodeLibrary(source);
- LibraryElementImpl resynthesized = _checkSource(resynthesizer, source);
- for (Source otherSource in otherLibrarySources) {
- _checkSource(resynthesizer, otherSource);
- }
- _reset();
- return resynthesized.definingCompilationUnit;
- }
-
- @override
- void compareLocalElementsOfExecutable(ExecutableElement resynthesized,
- ExecutableElement original, String desc) {
- // We don't resynthesize local elements during link.
- // So, we should not compare them.
- }
-
- @override
- DartSdk createDartSdk() => AbstractContextTest.SHARED_STRONG_MOCK_SDK;
-
- @override
- AnalysisOptionsImpl createOptions() =>
- new AnalysisOptionsImpl()..strongMode = true;
-
- @override
- @failingTest
- test_blockBodiedLambdas_async_allReturnsAreFutures_topLevel() async {
- await super.test_blockBodiedLambdas_async_allReturnsAreFutures_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_async_allReturnsAreValues_topLevel() async {
- await super.test_blockBodiedLambdas_async_allReturnsAreValues_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_async_mixOfValuesAndFutures_topLevel() async {
- await super.test_blockBodiedLambdas_async_mixOfValuesAndFutures_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_asyncStar_topLevel() async {
- await super.test_blockBodiedLambdas_asyncStar_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_basic_topLevel() async {
- await super.test_blockBodiedLambdas_basic_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_inferBottom_async_topLevel() async {
- await super.test_blockBodiedLambdas_inferBottom_async_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_inferBottom_asyncStar_topLevel() async {
- await super.test_blockBodiedLambdas_inferBottom_asyncStar_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_inferBottom_sync_topLevel() async {
- await super.test_blockBodiedLambdas_inferBottom_sync_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_inferBottom_syncStar_topLevel() async {
- await super.test_blockBodiedLambdas_inferBottom_syncStar_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_LUB_topLevel() async {
- await super.test_blockBodiedLambdas_LUB_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_nestedLambdas_topLevel() async {
- await super.test_blockBodiedLambdas_nestedLambdas_topLevel();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_syncStar_topLevel() async {
- await super.test_blockBodiedLambdas_syncStar_topLevel();
- }
-
- @override
- @failingTest
- test_circularReference_viaClosures_initializerTypes() async {
- await super.test_circularReference_viaClosures_initializerTypes();
- }
-
- @override
- @failingTest
- test_blockBodiedLambdas_noReturn_topLevel() =>
- super.test_blockBodiedLambdas_noReturn_topLevel();
-
- @failingTest
- @override
- test_listLiteralsCanInferNull_topLevel() =>
- super.test_listLiteralsCanInferNull_topLevel();
-
- @failingTest
- @override
- test_mapLiteralsCanInferNull_topLevel() =>
- super.test_mapLiteralsCanInferNull_topLevel();
-
- test_infer_extractIndex_custom() async {
- var unit = await checkFileElement('''
-class A {
- String operator [](_) => null;
-}
-var a = new A();
-var b = a[0];
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'String');
- }
-
- test_infer_extractIndex_fromList() async {
- var unit = await checkFileElement('''
-var a = <int>[1, 2, 3];
-var b = a[0];
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'int');
- }
-
- test_infer_extractIndex_fromMap() async {
- var unit = await checkFileElement('''
-var a = <int, double>{};
-var b = a[0];
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'double');
- }
-
- test_infer_extractProperty_getter() async {
- await checkFileElement(r'''
-var a = 1.isEven;
-var b = 2.isNaN;
-var c = 3.foo;
-var d = foo.bar;
- ''');
- }
-
- test_infer_extractProperty_getter_sequence() async {
- var unit = await checkFileElement(r'''
-class A {
- B b = new B();
-}
-class B {
- C c = new C();
-}
-class C {
- int d;
-}
-var a = new A();
-var v = a.b.c.d;
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
- }
-
- test_infer_extractProperty_getter_sequence_generic() async {
- var unit = await checkFileElement(r'''
-class A<T> {
- B<T> b = new B<T>();
-}
-class B<K> {
- C<List<K>, int> c = new C<List<K>, int>();
-}
-class C<K, V> {
- Map<K, V> d;
-}
-var a = new A<double>();
-var v = a.b.c.d;
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
- }
-
- test_infer_extractProperty_getter_sequence_withUnresolved() async {
- var unit = await checkFileElement(r'''
-class A {
- B b = new B();
-}
-class B {
- int c;
-}
-var a = new A();
-var v = a.b.foo.c;
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
- }
-
- test_infer_extractProperty_method() async {
- var unit = await checkFileElement(r'''
-class A {
- int m(double p1, String p2) => 42;
-}
-var a = new A();
-var v = a.m;
- ''');
- expect(unit.topLevelVariables[1].type.toString(), '(double, String) → int');
- }
-
- test_infer_extractProperty_method2() async {
- var unit = await checkFileElement(r'''
-var a = 1.round;
- ''');
- expect(unit.topLevelVariables[0].type.toString(), '() → int');
- }
-
- test_infer_extractProperty_method_sequence() async {
- var unit = await checkFileElement(r'''
-class A {
- B b = new B();
-}
-class B {
- C c = new C();
-}
-class C {
- int m(double p1, String p2) => 42;
-}
-var a = new A();
-var v = a.b.c.m;
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
- }
-
- test_infer_invokeConstructor_factoryRedirected() async {
- await checkFileElement(r'''
-class A {
- factory A() = B;
-}
-class B implements A {}
-var a = new A();
- ''');
- }
-
- test_infer_invokeConstructor_named() async {
- await checkFileElement(r'''
-class A {
- A.aaa();
-}
-class B<K, V> {
- B.bbb();
-}
-var a = new A.aaa();
-var b1 = new B.bbb();
-var b2 = new B<int, String>.bbb();
-var b3 = new B<List<int>, Map<List<int>, Set<String>>>.bbb();
- ''');
- }
-
- test_infer_invokeConstructor_named_importedWithPrefix() async {
- addFile(
- r'''
-class A {
- A.aaa();
-}
-class B<K, V> {
- B.bbb();
-}
-''',
- name: '/a.dart');
- await checkFileElement(r'''
-import 'a.dart' as p;
-var a = new p.A.aaa();
-var b1 = new p.B.bbb();
-var b2 = new p.B<int, String>.bbb();
- ''');
- }
-
- test_infer_invokeConstructor_unnamed() async {
- await checkFileElement(r'''
-class A {
- A();
-}
-class B<T> {
- B();
-}
-var a = new A();
-var b1 = new B();
-var b2 = new B<int>();
- ''');
- }
-
- test_infer_invokeConstructor_unnamed_synthetic() async {
- await checkFileElement(r'''
-class A {}
-class B<T> {}
-var a = new A();
-var b1 = new B();
-var b2 = new B<int>();
- ''');
- }
-
- test_infer_invokeMethodRef_function() async {
- var unit = await checkFileElement(r'''
-int m() => 0;
-var a = m();
- ''');
- expect(unit.topLevelVariables[0].type.toString(), 'int');
- }
-
- test_infer_invokeMethodRef_function_generic() async {
- var unit = await checkFileElement(r'''
-/*=Map<int, V>*/ m/*<V>*/(/*=V*/ a) => null;
-var a = m(2.3);
- ''');
- expect(unit.topLevelVariables[0].type.toString(), 'Map<int, double>');
- }
-
- test_infer_invokeMethodRef_function_importedWithPrefix() async {
- addFile(
- r'''
-int m() => 0;
-''',
- name: '/a.dart');
- var unit = await checkFileElement(r'''
-import 'a.dart' as p;
-var a = p.m();
- ''');
- expect(unit.topLevelVariables[0].type.toString(), 'int');
- }
-
- test_infer_invokeMethodRef_method() async {
- var unit = await checkFileElement(r'''
-class A {
- int m() => 0;
-}
-var a = new A();
-var b = a.m();
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'int');
- }
-
- test_infer_invokeMethodRef_method_g() async {
- var unit = await checkFileElement(r'''
-class A {
- /*=T*/ m/*<T>*/(/*=T*/ a) => null;
-}
-var a = new A();
-var b = a.m(1.0);
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'double');
- }
-
- test_infer_invokeMethodRef_method_genericSequence() async {
- var unit = await checkFileElement(r'''
-class A<T> {
- B<T> b = new B<T>();
-}
-class B<K> {
- C<List<K>, int> c = new C<List<K>, int>();
-}
-class C<K, V> {
- Map<K, V> m() => null;
-}
-var a = new A<double>();
-var v = a.b.c.m();
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
- }
-
- test_infer_invokeMethodRef_method_gg() async {
- var unit = await checkFileElement(r'''
-class A<K> {
- /*=Map<K, V>*/ m/*<V>*/(/*=V*/ a) => null;
-}
-var a = new A<int>();
-var b = a.m(1.0);
- ''');
- expect(unit.topLevelVariables[1].type.toString(), 'Map<int, double>');
- }
-
- test_infer_invokeMethodRef_method_importedWithPrefix() async {
- addFile(
- r'''
-class A {
- int m() => 0;
-}
-var a = new A();
-''',
- name: '/a.dart');
- var unit = await checkFileElement(r'''
-import 'a.dart' as p;
-var b = p.a.m();
- ''');
- expect(unit.topLevelVariables[0].type.toString(), 'int');
- }
-
- test_infer_invokeMethodRef_method_importedWithPrefix2() async {
- addFile(
- r'''
-class A {
- B b = new B();
-}
-class B {
- int m() => 0;
-}
-var a = new A();
-''',
- name: '/a.dart');
- var unit = await checkFileElement(r'''
-import 'a.dart' as p;
-var b = p.a.b.m();
- ''');
- expect(unit.topLevelVariables[0].type.toString(), 'dynamic');
- }
-
- test_infer_invokeMethodRef_method_withInferredTypeInLibraryCycle() async {
- var unit = await checkFileElement('''
-class Base {
- int m() => 0;
-}
-class A extends Base {
- m() => 0; // Inferred return type: int
-}
-var a = new A();
-var b = a.m();
- ''');
- // Type inference operates on static and top level variables prior to
- // instance members. So at the time `b` is inferred, `A.m` still has return
- // type `dynamic`.
- expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
- }
-
- test_infer_invokeMethodRef_method_withInferredTypeOutsideLibraryCycle() async {
- addFile(
- '''
-class Base {
- int m() => 0;
-}
-class A extends Base {
- m() => 0; // Inferred return type: int
-}
-''',
- name: '/a.dart');
- var unit = await checkFileElement('''
-import 'a.dart';
-var a = new A();
-var b = a.m();
-''');
- // Since a.dart is in a separate library file from the compilation unit
- // containing `a` and `b`, its types are inferred first; then `a` and `b`'s
- // types are inferred. So the inferred return type of `int` should be
- // propagated to `b`.
- expect(unit.topLevelVariables[1].type.toString(), 'int');
- }
-
- @override
- @failingTest
- test_inferLocalFunctionReturnType() async {
- await super.test_inferLocalFunctionReturnType();
- }
-
- @override
- @failingTest
- test_inferredType_blockBodiedClosure_noArguments() async {
- await super.test_inferredType_blockBodiedClosure_noArguments();
- }
-
- @override
- @failingTest
- test_inferredType_blockClosure_noArgs_noReturn() async {
- await super.test_inferredType_blockClosure_noArgs_noReturn();
- }
-
- test_invokeMethod_notGeneric_genericClass() async {
- var unit = await checkFileElement(r'''
-class C<T> {
- T m(int a, {String b, T c}) => null;
-}
-var v = new C<double>().m(1, b: 'bbb', c: 2.0);
- ''');
- expect(unit.topLevelVariables[0].type.toString(), 'double');
- }
-
- test_invokeMethod_notGeneric_notGenericClass() async {
- var unit = await checkFileElement(r'''
-class C {
- int m(int a, {String b, int c}) => null;
-}
-var v = new C().m(1, b: 'bbb', c: 2.0);
- ''');
- expect(unit.topLevelVariables[0].type.toString(), 'int');
- }
-
- @override
- @failingTest
- test_nullCoalescingOperator() async {
- await super.test_nullCoalescingOperator();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_closureCall() async {
- await super.test_unsafeBlockClosureInference_closureCall();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_constructorCall_implicitTypeParam() async {
- return super
- .test_unsafeBlockClosureInference_constructorCall_implicitTypeParam();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_explicitDynamicParam_viaExpr2() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_explicitDynamicParam_viaExpr2();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_explicitDynamicParam_viaExpr2_comment() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_explicitDynamicParam_viaExpr2_comment();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_explicitTypeParam_viaExpr2() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_explicitTypeParam_viaExpr2();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_explicitTypeParam_viaExpr2_comment() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_explicitTypeParam_viaExpr2_comment();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_implicitTypeParam() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_implicitTypeParam();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_implicitTypeParam_comment() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_implicitTypeParam_comment();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_implicitTypeParam_viaExpr() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_implicitTypeParam_viaExpr();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_implicitTypeParam_viaExpr_comment() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_implicitTypeParam_viaExpr_comment();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_functionCall_noTypeParam_viaExpr() async {
- return super
- .test_unsafeBlockClosureInference_functionCall_noTypeParam_viaExpr();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_inList_untyped() async {
- await super.test_unsafeBlockClosureInference_inList_untyped();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_inMap_untyped() async {
- await super.test_unsafeBlockClosureInference_inMap_untyped();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_methodCall_implicitTypeParam() async {
- return super
- .test_unsafeBlockClosureInference_methodCall_implicitTypeParam();
- }
-
- @override
- @failingTest
- test_unsafeBlockClosureInference_methodCall_implicitTypeParam_comment() async {
- return super
- .test_unsafeBlockClosureInference_methodCall_implicitTypeParam_comment();
- }
-
- LibraryElementImpl _checkSource(
- SummaryResynthesizer resynthesizer, Source source) {
- LibraryElementImpl resynthesized =
- resynthesizer.getLibraryElement(source.uri.toString());
- LibraryElementImpl original = context.computeLibraryElement(source);
- checkLibraryElements(original, resynthesized);
- return resynthesized;
- }
-}
-
-@reflectiveTest
class ResynthesizeAstSpecTest extends _ResynthesizeAstTest {
@override
bool get isStrongMode => false;
@@ -695,6 +61,13 @@ class ResynthesizeAstStrongTest extends _ResynthesizeAstTest {
super.createOptions()..strongMode = true;
@override
+ @failingTest
+ test_const_invokeConstructor_generic_noTypeArguments() async {
+ await super.test_const_invokeConstructor_generic_noTypeArguments();
+ }
+
+ @override
+ @failingTest
test_instantiateToBounds_boundRefersToItself() async {
await super.test_instantiateToBounds_boundRefersToItself();
}
@@ -827,12 +200,6 @@ abstract class _AstResynthesizeTestMixin
});
}
- void _reset() {
- serializedSources.clear();
- bundleAssembler = new PackageBundleAssembler();
- uriToUnit.clear();
- }
-
void _serializeLibrary(Source librarySource) {
if (librarySource == null || librarySource.isInSystemLibrary) {
return;
« no previous file with comments | « pkg/analyzer/lib/src/task/strong_mode.dart ('k') | pkg/analyzer/test/src/summary/top_level_inference_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698