| Index: packages/analyzer/test/generated/non_error_resolver_test.dart
|
| diff --git a/packages/analyzer/test/generated/non_error_resolver_test.dart b/packages/analyzer/test/generated/non_error_resolver_test.dart
|
| index 8a6c71f162ad9cb2deaae19c1da08b320a92b6c8..6dd2519da6d6d88e48841f88dce886ead7f6ed09 100644
|
| --- a/packages/analyzer/test/generated/non_error_resolver_test.dart
|
| +++ b/packages/analyzer/test/generated/non_error_resolver_test.dart
|
| @@ -2,24 +2,25 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -library engine.non_error_resolver_test;
|
| +library analyzer.test.generated.non_error_resolver_test;
|
|
|
| -import 'package:analyzer/src/generated/ast.dart';
|
| -import 'package:analyzer/src/generated/element.dart';
|
| +import 'package:analyzer/dart/ast/ast.dart';
|
| +import 'package:analyzer/dart/element/element.dart';
|
| +import 'package:analyzer/error/error.dart';
|
| +import 'package:analyzer/src/error/codes.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| -import 'package:analyzer/src/generated/error.dart';
|
| import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
|
| import 'package:analyzer/src/generated/source_io.dart';
|
| +import 'package:test_reflective_loader/test_reflective_loader.dart';
|
| import 'package:unittest/unittest.dart';
|
|
|
| -import '../reflective_tests.dart';
|
| import '../utils.dart';
|
| -import 'resolver_test.dart';
|
| +import 'resolver_test_case.dart';
|
| import 'test_support.dart';
|
|
|
| main() {
|
| initializeTestEnvironment();
|
| - runReflectiveTests(NonErrorResolverTest);
|
| + defineReflectiveTests(NonErrorResolverTest);
|
| }
|
|
|
| @reflectiveTest
|
| @@ -35,6 +36,85 @@ E e() {
|
| verify([source]);
|
| }
|
|
|
| + void test_abstractSuperMemberReference_superHasNoSuchMethod() {
|
| + Source source = addSource('''
|
| +abstract class A {
|
| + int m();
|
| + noSuchMethod(_) => 42;
|
| +}
|
| +
|
| +class B extends A {
|
| + int m() => super.m();
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_abstractSuperMemberReference_superSuperHasConcrete_getter() {
|
| + Source source = addSource('''
|
| +abstract class A {
|
| + int get m => 0;
|
| +}
|
| +
|
| +abstract class B extends A {
|
| + int get m;
|
| +}
|
| +
|
| +class C extends B {
|
| + int get m => super.m;
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_abstractSuperMemberReference_superSuperHasConcrete_method() {
|
| + Source source = addSource('''
|
| +void main() {
|
| + print(new C().m());
|
| +}
|
| +
|
| +abstract class A {
|
| + int m() => 0;
|
| +}
|
| +
|
| +abstract class B extends A {
|
| + int m();
|
| +}
|
| +
|
| +class C extends B {
|
| + int m() => super.m();
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_abstractSuperMemberReference_superSuperHasConcrete_setter() {
|
| + Source source = addSource('''
|
| +abstract class A {
|
| + void set m(int v) {}
|
| +}
|
| +
|
| +abstract class B extends A {
|
| + void set m(int v);
|
| +}
|
| +
|
| +class C extends B {
|
| + void set m(int v) {
|
| + super.m = 0;
|
| + }
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_ambiguousExport() {
|
| Source source = addSource(r'''
|
| library L;
|
| @@ -166,8 +246,16 @@ class N1 {}''');
|
| library lib2;
|
| class N {}
|
| class N2 {}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
|
| + }
|
| +
|
| + void test_annotated_partOfDeclaration() {
|
| + Source source = addSource('library L; part "part.dart";');
|
| + addNamedSource('/part.dart', '@deprecated part of L;');
|
| computeLibrarySourceErrors(source);
|
| assertNoErrors(source);
|
| + verify([source]);
|
| }
|
|
|
| void test_argumentTypeNotAssignable_classWithCall_Function() {
|
| @@ -262,6 +350,82 @@ f(A a) {
|
| verify([source]);
|
| }
|
|
|
| + void test_assert_with_message_await() {
|
| + resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
|
| + Source source = addSource('''
|
| +import 'dart:async';
|
| +f() async {
|
| + assert(false, await g());
|
| +}
|
| +Future<String> g() => null;
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_assert_with_message_dynamic() {
|
| + resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
|
| + Source source = addSource('''
|
| +f() {
|
| + assert(false, g());
|
| +}
|
| +g() => null;
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_assert_with_message_non_string() {
|
| + resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
|
| + Source source = addSource('''
|
| +f() {
|
| + assert(false, 3);
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_assert_with_message_null() {
|
| + resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
|
| + Source source = addSource('''
|
| +f() {
|
| + assert(false, null);
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_assert_with_message_string() {
|
| + resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
|
| + Source source = addSource('''
|
| +f() {
|
| + assert(false, 'message');
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_assert_with_message_suppresses_unused_var_hint() {
|
| + resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
|
| + Source source = addSource('''
|
| +f() {
|
| + String message = 'msg';
|
| + assert(true, message);
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_assignability_function_expr_rettype_from_typedef_cls() {
|
| // In the code below, the type of (() => f()) has a return type which is
|
| // a class, and that class is inferred from the return type of the typedef
|
| @@ -838,6 +1002,24 @@ f(String s) {
|
| verify([source]);
|
| }
|
|
|
| + void test_class_type_alias_documentationComment() {
|
| + Source source = addSource('''
|
| +/**
|
| + * Documentation
|
| + */
|
| +class C = D with E;
|
| +
|
| +class D {}
|
| +class E {}''');
|
| + computeLibrarySourceErrors(source);
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| + ClassElement classC = unit.element.getType('C');
|
| + expect(classC.documentationComment, isNotNull);
|
| + }
|
| +
|
| void test_commentReference_beforeConstructor() {
|
| String code = r'''
|
| abstract class A {
|
| @@ -850,10 +1032,9 @@ abstract class A {
|
| verify([source]);
|
| CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| {
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "p]", (node) => node is SimpleIdentifier);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
|
| - ParameterElement, ref.staticElement);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, "p]");
|
| + expect(ref.staticElement, new isInstanceOf<ParameterElement>());
|
| }
|
| }
|
|
|
| @@ -872,22 +1053,22 @@ enum Samurai {
|
| verify([source]);
|
| CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| {
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "Samurai]", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'Samurai]');
|
| ClassElement refElement = ref.staticElement;
|
| expect(refElement, isNotNull);
|
| expect(refElement.name, 'Samurai');
|
| }
|
| {
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "int]", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'int]');
|
| ClassElement refElement = ref.staticElement;
|
| expect(refElement, isNotNull);
|
| expect(refElement.name, 'int');
|
| }
|
| {
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "WITH_SWORD]", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'WITH_SWORD]');
|
| PropertyAccessorElement refElement = ref.staticElement;
|
| expect(refElement, isNotNull);
|
| expect(refElement.name, 'WITH_SWORD');
|
| @@ -904,10 +1085,9 @@ foo(int p) {
|
| assertNoErrors(source);
|
| verify([source]);
|
| CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "p]", (node) => node is SimpleIdentifier);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is ParameterElement, ParameterElement, ref.staticElement);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
|
| + expect(ref.staticElement, new isInstanceOf<ParameterElement>());
|
| }
|
|
|
| void test_commentReference_beforeFunction_expressionBody() {
|
| @@ -919,10 +1099,42 @@ foo(int p) => null;''';
|
| assertNoErrors(source);
|
| verify([source]);
|
| CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "p]", (node) => node is SimpleIdentifier);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is ParameterElement, ParameterElement, ref.staticElement);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
|
| + expect(ref.staticElement, new isInstanceOf<ParameterElement>());
|
| + }
|
| +
|
| + void test_commentReference_beforeFunctionTypeAlias() {
|
| + String code = r'''
|
| +/// [p]
|
| +typedef Foo(int p);
|
| +''';
|
| + Source source = addSource(code);
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'p]');
|
| + expect(ref.staticElement, new isInstanceOf<ParameterElement>());
|
| + }
|
| +
|
| + void test_commentReference_beforeGetter() {
|
| + String code = r'''
|
| +abstract class A {
|
| + /// [int]
|
| + get g => null;
|
| +}''';
|
| + Source source = addSource(code);
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| + {
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'int]');
|
| + expect(ref.staticElement, isNotNull);
|
| + }
|
| }
|
|
|
| void test_commentReference_beforeMethod() {
|
| @@ -932,24 +1144,28 @@ abstract class A {
|
| ma(int p1) {}
|
| /// [p2]
|
| mb(int p2);
|
| + /// [p3] and [p4]
|
| + mc(int p3, p4());
|
| + /// [p5]
|
| + md(int p5, {int p6});
|
| }''';
|
| Source source = addSource(code);
|
| computeLibrarySourceErrors(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| - {
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "p1]", (node) => node is SimpleIdentifier);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
|
| - ParameterElement, ref.staticElement);
|
| - }
|
| - {
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "p2]", (node) => node is SimpleIdentifier);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
|
| - ParameterElement, ref.staticElement);
|
| + assertIsParameter(String search) {
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, search);
|
| + expect(ref.staticElement, new isInstanceOf<ParameterElement>());
|
| }
|
| +
|
| + assertIsParameter('p1');
|
| + assertIsParameter('p2');
|
| + assertIsParameter('p3');
|
| + assertIsParameter('p4');
|
| + assertIsParameter('p5');
|
| + assertIsParameter('p6');
|
| }
|
|
|
| void test_commentReference_class() {
|
| @@ -963,10 +1179,9 @@ class A {
|
| assertNoErrors(source);
|
| verify([source]);
|
| CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "foo]", (node) => node is SimpleIdentifier);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is MethodElement, MethodElement, ref.staticElement);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'foo]');
|
| + expect(ref.staticElement, new isInstanceOf<MethodElement>());
|
| }
|
|
|
| void test_commentReference_setter() {
|
| @@ -987,16 +1202,14 @@ class B extends A {
|
| verify([source]);
|
| CompilationUnit unit = _getResolvedLibraryUnit(source);
|
| {
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "x] in A", (node) => node is SimpleIdentifier);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement,
|
| - PropertyAccessorElement, ref.staticElement);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, "x] in A");
|
| + expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>());
|
| }
|
| {
|
| - SimpleIdentifier ref = EngineTestCase.findNode(
|
| - unit, code, "x] in B", (node) => node is SimpleIdentifier);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement,
|
| - PropertyAccessorElement, ref.staticElement);
|
| + SimpleIdentifier ref =
|
| + EngineTestCase.findSimpleIdentifier(unit, code, 'x] in B');
|
| + expect(ref.staticElement, new isInstanceOf<PropertyAccessorElement>());
|
| }
|
| }
|
|
|
| @@ -1345,6 +1558,26 @@ main() {
|
| verify([source]);
|
| }
|
|
|
| + void test_constRedirectSkipsSupertype() {
|
| + // Since C redirects to C.named, it doesn't implicitly refer to B's
|
| + // unnamed constructor. Therefore there is no cycle.
|
| + Source source = addSource('''
|
| +class B {
|
| + final x;
|
| + const B() : x = y;
|
| + const B.named() : x = null;
|
| +}
|
| +class C extends B {
|
| + const C() : this.named();
|
| + const C.named() : super.named();
|
| +}
|
| +const y = const C();
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_constructorDeclaration_scope_signature() {
|
| Source source = addSource(r'''
|
| const app = 0;
|
| @@ -1356,6 +1589,19 @@ class A {
|
| verify([source]);
|
| }
|
|
|
| + void test_constWithNonConstantArgument_constField() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + const A(x);
|
| +}
|
| +main() {
|
| + const A(double.INFINITY);
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_constWithNonConstantArgument_literals() {
|
| Source source = addSource(r'''
|
| class A {
|
| @@ -1856,6 +2102,30 @@ class A implements Function {
|
| verify([source]);
|
| }
|
|
|
| + void test_functionWithoutCall_withNoSuchMethod_mixin() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(inv) {}
|
| +}
|
| +class B extends Object with A implements Function {
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_functionWithoutCall_withNoSuchMethod_superclass() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(inv) {}
|
| +}
|
| +class B extends A implements Function {
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_implicitConstructorDependencies() {
|
| // No warning should be generated for the code below; this requires that
|
| // implicit constructors are generated for C1 before C2, even though C1
|
| @@ -2638,7 +2908,7 @@ f() {
|
| void test_invalidFactoryNameNotAClass() {
|
| Source source = addSource(r'''
|
| class A {
|
| - factory A() {}
|
| + factory A() => null;
|
| }''');
|
| computeLibrarySourceErrors(source);
|
| assertNoErrors(source);
|
| @@ -2973,6 +3243,23 @@ class B extends A {
|
| verify([source]);
|
| }
|
|
|
| + void test_invocationOfNonFunction_functionTypeTypeParameter() {
|
| + Source source = addSource(r'''
|
| +typedef void Action<T>(T x);
|
| +class C<T, U extends Action<T>> {
|
| + T value;
|
| + U action;
|
| + C(this.value, [this.action]);
|
| + void act() {
|
| + action(value);
|
| + }
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_invocationOfNonFunction_getter() {
|
| Source source = addSource(r'''
|
| class A {
|
| @@ -3302,7 +3589,7 @@ class B extends Object with A {}''');
|
| void test_mixinDeclaresConstructor_factory() {
|
| Source source = addSource(r'''
|
| class A {
|
| - factory A() {}
|
| + factory A() => null;
|
| }
|
| class B extends Object with A {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -3469,7 +3756,8 @@ f() {
|
| verify([source]);
|
| }
|
|
|
| - void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_getter() {
|
| + void
|
| + test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_getter() {
|
| Source source = addSource(r'''
|
| class A {
|
| int get g => 0;
|
| @@ -3483,7 +3771,8 @@ class C extends B {}''');
|
| verify([source]);
|
| }
|
|
|
| - void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_method() {
|
| + void
|
| + test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_method() {
|
| Source source = addSource(r'''
|
| class A {
|
| m(p) {}
|
| @@ -3497,7 +3786,8 @@ class C extends B {}''');
|
| verify([source]);
|
| }
|
|
|
| - void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_setter() {
|
| + void
|
| + test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcretes_setter() {
|
| Source source = addSource(r'''
|
| class A {
|
| set s(v) {}
|
| @@ -3511,7 +3801,8 @@ class C extends B {}''');
|
| verify([source]);
|
| }
|
|
|
| - void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() {
|
| + void
|
| + test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() {
|
| // 15979
|
| Source source = addSource(r'''
|
| abstract class M {}
|
| @@ -3538,7 +3829,8 @@ abstract class B = A with M;''');
|
| verify([source]);
|
| }
|
|
|
| - void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() {
|
| + void
|
| + test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() {
|
| // 15979
|
| Source source = addSource(r'''
|
| class M {}
|
| @@ -3623,7 +3915,35 @@ class B extends A {
|
| verify([source]);
|
| }
|
|
|
| - void test_nonAbstractClassInheritsAbstractMemberOne_overridesMethodInObject() {
|
| + void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_mixin() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(v) => '';
|
| +}
|
| +class B extends Object with A {
|
| + m(p);
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void
|
| + test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_superclass() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(v) => '';
|
| +}
|
| +class B extends A {
|
| + m(p);
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void
|
| + test_nonAbstractClassInheritsAbstractMemberOne_overridesMethodInObject() {
|
| Source source = addSource(r'''
|
| class A {
|
| String toString([String prefix = '']) => '${prefix}Hello';
|
| @@ -3669,6 +3989,21 @@ f(bool pb, pd) {
|
| verify([source]);
|
| }
|
|
|
| + void test_nonBoolNegationExpression_dynamic() {
|
| + Source source = addSource(r'''
|
| +f1(bool dynamic) {
|
| + !dynamic;
|
| +}
|
| +f2() {
|
| + bool dynamic = true;
|
| + !dynamic;
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_nonBoolOperand_and_bool() {
|
| Source source = addSource(r'''
|
| bool f(bool left, bool right) {
|
| @@ -3709,6 +4044,15 @@ bool f(dynamic left, right) {
|
| verify([source]);
|
| }
|
|
|
| + void test_nonConstantDefaultValue_constField() {
|
| + Source source = addSource(r'''
|
| +f([a = double.INFINITY]) {
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_nonConstantDefaultValue_function_named() {
|
| Source source = addSource("f({x : 2 + 3}) {}");
|
| computeLibrarySourceErrors(source);
|
| @@ -3763,6 +4107,19 @@ class A {
|
| verify([source]);
|
| }
|
|
|
| + void test_nonConstantDefaultValue_typedConstList() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + m([p111 = const <String>[]]) {}
|
| +}
|
| +class B extends A {
|
| + m([p222 = const <String>[]]) {}
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_nonConstantValueInInitializer_namedArgument() {
|
| Source source = addSource(r'''
|
| class A {
|
| @@ -3777,7 +4134,23 @@ class B extends A {
|
| verify([source]);
|
| }
|
|
|
| - void test_nonConstCaseExpression() {
|
| + void test_nonConstCaseExpression_constField() {
|
| + Source source = addSource(r'''
|
| +f(double p) {
|
| + switch (p) {
|
| + case double.INFINITY:
|
| + return true;
|
| + default:
|
| + return false;
|
| + }
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertErrors(
|
| + source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_nonConstCaseExpression_typeLiteral() {
|
| Source source = addSource(r'''
|
| f(Type t) {
|
| switch (t) {
|
| @@ -3793,6 +4166,16 @@ f(Type t) {
|
| verify([source]);
|
| }
|
|
|
| + void test_nonConstListElement_constField() {
|
| + Source source = addSource(r'''
|
| +main() {
|
| + const [double.INFINITY];
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_nonConstMapAsExpressionStatement_const() {
|
| Source source = addSource(r'''
|
| f() {
|
| @@ -3823,6 +4206,27 @@ f() {
|
| verify([source]);
|
| }
|
|
|
| + void test_nonConstMapKey_constField() {
|
| + Source source = addSource(r'''
|
| +main() {
|
| + const {double.INFINITY: 0};
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertErrors(source,
|
| + [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_nonConstMapValue_constField() {
|
| + Source source = addSource(r'''
|
| +main() {
|
| + const {0: double.INFINITY};
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_nonConstValueInInitializer_binary_bool() {
|
| Source source = addSource(r'''
|
| class A {
|
| @@ -3969,7 +4373,7 @@ class A {
|
| Source source = addSource(r'''
|
| class A {
|
| A.named() {}
|
| - factory A() {}
|
| + factory A() => null;
|
| }
|
| class B extends A {
|
| B() : super.named();
|
| @@ -4387,7 +4791,7 @@ class B implements A {
|
| factory B() = C;
|
| }
|
| class C implements B {
|
| - factory C() {}
|
| + factory C() => null;
|
| }''');
|
| computeLibrarySourceErrors(source);
|
| assertNoErrors(source);
|
| @@ -4806,6 +5210,43 @@ f() { return new G<B>(); }''');
|
| verify([source]);
|
| }
|
|
|
| + void test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound() {
|
| + Source source = addSource(r'''
|
| +class A {}
|
| +class B extends A {}
|
| +typedef F<T extends A>();
|
| +F<A> fa;
|
| +F<B> fb;
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_hasBound2() {
|
| + Source source = addSource(r'''
|
| +class MyClass<T> {}
|
| +typedef MyFunction<T, P extends MyClass<T>>();
|
| +class A<T, P extends MyClass<T>> {
|
| + MyFunction<T, P> f;
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias_noBound() {
|
| + Source source = addSource(r'''
|
| +typedef F<T>();
|
| +F<int> f1;
|
| +F<String> f2;
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_typeArgumentNotMatchingBounds_typeArgumentList_0() {
|
| Source source = addSource("abstract class A<T extends A>{}");
|
| computeLibrarySourceErrors(source);
|
| @@ -4838,7 +5279,8 @@ main(Object p) {
|
| verify([source]);
|
| }
|
|
|
| - void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignment() {
|
| + void
|
| + test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignment() {
|
| Source source = addSource(r'''
|
| callMe(f()) { f(); }
|
| main(Object p) {
|
| @@ -4875,7 +5317,8 @@ main(Object p) {
|
| verify([source]);
|
| }
|
|
|
| - void test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() {
|
| + void
|
| + test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() {
|
| Source source = addSource(r'''
|
| callMe(f()) { f(); }
|
| main(Object p) {
|
| @@ -5273,26 +5716,6 @@ class B extends A<List> {
|
| verify([source]);
|
| }
|
|
|
| - void test_undefinedIdentifier_hide() {
|
| - Source source = addSource(r'''
|
| -library L;
|
| -export 'lib1.dart' hide a;''');
|
| - addNamedSource("/lib1.dart", "library lib1;");
|
| - computeLibrarySourceErrors(source);
|
| - assertNoErrors(source);
|
| - verify([source]);
|
| - }
|
| -
|
| - void test_undefinedIdentifier_show() {
|
| - Source source = addSource(r'''
|
| -library L;
|
| -export 'lib1.dart' show a;''');
|
| - addNamedSource("/lib1.dart", "library lib1;");
|
| - computeLibrarySourceErrors(source);
|
| - assertNoErrors(source);
|
| - verify([source]);
|
| - }
|
| -
|
| void test_undefinedIdentifier_synthetic_whenExpression() {
|
| Source source = addSource(r'''
|
| print(x) {}
|
| @@ -5445,6 +5868,17 @@ main() {
|
| verify([source]);
|
| }
|
|
|
| + void test_unusedShownName_unresolved() {
|
| + Source source = addSource(r'''
|
| +import 'dart:math' show max, FooBar;
|
| +main() {
|
| + print(max(1, 2));
|
| +}
|
| +''');
|
| + computeLibrarySourceErrors(source);
|
| + assertErrors(source, [HintCode.UNDEFINED_SHOWN_NAME]);
|
| + }
|
| +
|
| void test_uriDoesNotExist_dll() {
|
| addNamedSource("/lib.dll", "");
|
| Source source = addSource("import 'dart-ext:lib';");
|
|
|