Format tests/language/e*.

Since I regenerated the test expectations, this also fills in a few
unspecified errors with more precise information.

Change-Id: I4a2450de030a7d38b08f30f46d9d9feca99404f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407082
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Robert Nystrom
2025-02-03 03:29:35 -08:00
committed by Commit Queue
parent 8e17d8b841
commit 3166d7188f
43 changed files with 559 additions and 555 deletions
+1 -4
View File
@@ -4,10 +4,7 @@
library enum_duplicate_lib;
enum Enum1 {
A,
B,
}
enum Enum1 { A, B }
class Enum2 {
static Iterable get values => ['Enum2.A', 'Enum2.B'];
@@ -29,12 +29,18 @@ void main() {
Expect.identical(EnumPlainSemicolon.v3, EnumPlainSemicolon.values[2]);
Expect.equals(3, EnumPlainTrailingCommaSemicolon.values.length);
Expect.identical(EnumPlainTrailingCommaSemicolon.v1,
EnumPlainTrailingCommaSemicolon.values[0]);
Expect.identical(EnumPlainTrailingCommaSemicolon.v2,
EnumPlainTrailingCommaSemicolon.values[1]);
Expect.identical(EnumPlainTrailingCommaSemicolon.v3,
EnumPlainTrailingCommaSemicolon.values[2]);
Expect.identical(
EnumPlainTrailingCommaSemicolon.v1,
EnumPlainTrailingCommaSemicolon.values[0],
);
Expect.identical(
EnumPlainTrailingCommaSemicolon.v2,
EnumPlainTrailingCommaSemicolon.values[1],
);
Expect.identical(
EnumPlainTrailingCommaSemicolon.v3,
EnumPlainTrailingCommaSemicolon.values[2],
);
Expect.equals(6, EnumAll.values.length);
Expect.identical(EnumAll.v1, EnumAll.values[0]);
@@ -105,7 +111,9 @@ void main() {
Expect.identical(EnumAll.v4, EnumAll.v3 ^ EnumAll.v2);
Expect.equals(
"EnumAll.v1:EnumMixin<num>:ObjectMixin:this", EnumAll.v1.thisAndSuper());
"EnumAll.v1:EnumMixin<num>:ObjectMixin:this",
EnumAll.v1.thisAndSuper(),
);
// Which can reference type parameters.
Expect.isTrue(EnumAll.v2.test(2)); // does `is T` with `T` being `int`.
@@ -148,35 +156,22 @@ void main() {
enum EnumPlain { v1, v2, v3 }
// Also with trailing comma.
enum EnumPlainTrailingComma {
v1,
v2,
v3,
}
enum EnumPlainTrailingComma { v1, v2, v3 }
// Also if using type parameters, mixins or interfaces.
// It only matters whether there is something after the values.
enum EnumNoSemicolon<T extends num> with ObjectMixin implements Interface {
v1,
v2,
v3
v3,
}
// Allows semicolon after values, even when not needed.
// Without trailing comma.
enum EnumPlainSemicolon {
v1,
v2,
v3;
}
enum EnumPlainSemicolon { v1, v2, v3 }
// With trailing comma.
enum EnumPlainTrailingCommaSemicolon {
v1,
v2,
v3,
;
}
enum EnumPlainTrailingCommaSemicolon { v1, v2, v3 }
// Full syntax, with every possible option.
@EnumAll.v1
@@ -193,8 +188,7 @@ enum EnumAll<S extends num, T extends num>
v3<int, int>(y: 2),
v4.named(1, y: 2),
v5<int, int>.renamed(1, y: 2),
v6.new(),
;
v6.new();
/// Static members.
///
@@ -216,16 +210,16 @@ enum EnumAll<S extends num, T extends num>
// Constructors.
// Generative, non-redirecting, unnamed.
const EnumAll({T? y})
: constructor = "unnamed",
this.x = 0 as S,
y = y ?? (0 as T);
: constructor = "unnamed",
this.x = 0 as S,
y = y ?? (0 as T);
// Generative, non-redirecting, named.
const EnumAll.named(this.x, {T? y, String? constructor})
: constructor = constructor ?? "named",
y = y ?? (0 as T);
: constructor = constructor ?? "named",
y = y ?? (0 as T);
// Generative, redirecting.
const EnumAll.renamed(S x, {T? y})
: this.named(x, y: y, constructor: "renamed");
: this.named(x, y: y, constructor: "renamed");
// Factory, non-redirecting.
factory EnumAll.factory(int index) => values[index] as EnumAll<S, T>;
// Factory, redirecting (only to other factory constructor).
@@ -264,7 +264,7 @@ enum ConflictClassTypeParameter<ConflictClassTypeParameter> {
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_CONTAINER
// [cfe] A type variable can't have the same name as its enclosing declaration.
e1;
//^
// [error column 3]
// [cfe] Couldn't find constructor 'ConflictClassTypeParameter'.
}
@@ -405,10 +405,10 @@ enum ConflictClassEnumValue {
// Has conflict with implicitly inserted `values` member.
enum values {
// ^^^^^^
// [analyzer] unspecified
// [analyzer] COMPILE_TIME_ERROR.ENUM_WITH_NAME_VALUES
// [cfe] The name 'values' is not a valid name for an enum. Try using a different name.
e1;
//^
// [error column 3]
// [cfe] Couldn't find constructor 'values'.
}
@@ -449,9 +449,8 @@ enum OverridesEquals {
e1;
bool operator==(Object other) => identical(e1, other);
// ^^^^^^^^
// [analyzer] unspecified
// ^
// ^^
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
// [cfe] An enum can't declare a non-abstract member named '=='.
}
@@ -460,7 +459,7 @@ enum OverridesHashCode {
int get hashCode => 42;
// ^^^^^^^^
// [analyzer] unspecified
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
// [cfe] An enum can't declare a non-abstract member named 'hashCode'.
}
@@ -515,9 +514,9 @@ enum NoConstructorCalls {
// [cfe] Final field 'x' is not initialized by this constructor.
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR
// [cfe] Couldn't find constructor 'NoConstructorCalls.factory'.
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_NON_CONST_CONSTRUCTOR
// [cfe] Couldn't find constructor 'NoConstructorCalls.factory'.
factory NoConstructorCalls.factory() => e1; // Valid.
@@ -614,7 +613,7 @@ enum DeclaresStaticIndex {
enum InheritsIndex with IndexGetter {
// ^^^^^^^^^^^^^
// [analyzer] unspecified
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
// [cfe] An enum can't inherit a member named 'index'.
e1;
}
@@ -643,8 +642,8 @@ enum ImplementsNeverIndex {
}
enum NSMImplementsNeverIndex implements NeverIndexGetter {
// ^^^^^^
// [analyzer] unspecified
// ^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_IMPLEMENTATION_OVERRIDE
// [cfe] The implementation of 'index' in the non-abstract class 'NSMImplementsNeverIndex' does not conform to its interface.
e1;
@@ -670,11 +669,10 @@ enum CyclicReference {
// Since `values` contains `e1`,
// we can't have a reference in the other direction.
enum CyclicReferenceValues {
// ^
// [cfe] Constant evaluation error:
e1(values);
//^^
// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_COMPILE_TIME_CONSTANT
// [cfe] Constant evaluation error:
final List<CyclicReferenceValues> list;
const CyclicReferenceValues(this.list);
}
@@ -35,8 +35,8 @@ abstract class AbstractImplementsWithValues implements Enum {
}
abstract class AbstractExtendsWithValues extends Enum {
// ^
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
// ^
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
int get values => 42;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_ENUM_VALUES
@@ -51,8 +51,8 @@ abstract class AbstractImplementsWithIndex implements Enum {
}
abstract class AbstractExtendsWithIndex extends Enum {
// ^
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
// ^
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
int get index => 42;
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
@@ -184,7 +184,7 @@ enum EnumImplementsEnum implements MyEnum {
// [cfe] 'MyEnum' is an enum and can't be extended or implemented.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
e1;
e1,
}
enum EnumMixesInEnum with MyEnum {
@@ -195,11 +195,9 @@ enum EnumMixesInEnum with MyEnum {
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
// [cfe] The class 'MyEnum' can't be used as a mixin because it extends a class other than 'Object'.
// [cfe] The class 'MyEnum' can't be used as a mixin because it isn't a mixin class nor a mixin.
e1;
e1,
}
void main() {}
enum MyEnum {
e1;
}
enum MyEnum { e1 }
+5 -5
View File
@@ -10,10 +10,10 @@ enum Enum2 { A }
enum Enum3 { B, C }
enum Enum4 {
D,
E,
}
// Don't format to preserve the trailing comma.
// dart format off
enum Enum4 { D, E, }
// dart format on
enum Enum5 { F, G, H }
@@ -35,7 +35,7 @@ enum JSFunctionPrototype {
constructor,
apply,
bind,
call
call,
}
void expectIs<T>(T t, bool Function(Object?) test) {
+1 -4
View File
@@ -8,10 +8,7 @@ library enum_index_test;
import 'package:expect/expect.dart';
enum Enum {
A,
B,
}
enum Enum { A, B }
class Class {
var index;
@@ -9,10 +9,7 @@
// how much stack is left and used by the compiler. It should never crash nor
// produce a runtime exception.
enum Fruit {
apple,
banana,
}
enum Fruit { apple, banana }
getFruit() => Fruit.apple;
+1 -4
View File
@@ -4,7 +4,4 @@
library enum_private_lib;
enum Enum2 {
_A,
_B,
}
enum Enum2 { _A, _B }
@@ -13,10 +13,7 @@ import 'package:expect/expect.dart';
import 'private_lib.dart';
enum Enum1 {
_A,
_B,
}
enum Enum1 { _A, _B }
main() {
Expect.equals('Enum1._A,Enum1._B', Enum1.values.join(','));
@@ -13,10 +13,7 @@ import 'package:expect/expect.dart';
import 'private_lib.dart';
enum Enum1 {
_A,
_B,
}
enum Enum1 { _A, _B }
main() {
Expect.equals('Enum1._A,Enum1._B', Enum1.values.join(','));
+1 -4
View File
@@ -10,10 +10,7 @@ import 'package:expect/expect.dart';
import 'private_lib.dart';
enum Enum1 {
_A,
_B,
}
enum Enum1 { _A, _B }
main() {
Expect.equals('Enum1._A,Enum1._B', Enum1.values.join(','));
@@ -14,9 +14,9 @@ catchUnresolvedBefore() {
} on String catch (oks) {
// This is tested before the catch block below.
} on Unavailable catch (ex) {
// ^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_IN_CATCH_CLAUSE
// [cfe] 'Unavailable' isn't a type.
// ^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_IN_CATCH_CLAUSE
// [cfe] 'Unavailable' isn't a type.
Expect.fail("This code shouldn't be executed");
}
}
@@ -27,9 +27,9 @@ catchUnresolvedAfter() {
throw "foo";
Expect.fail("This code shouldn't be executed");
} on Unavailable catch (ex) {
// ^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_IN_CATCH_CLAUSE
// [cfe] 'Unavailable' isn't a type.
// ^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_IN_CATCH_CLAUSE
// [cfe] 'Unavailable' isn't a type.
// This is tested before the catch block below.
// In both production and checked mode the test causes a type error.
@@ -41,9 +41,13 @@ void test2() {
Expect.equals(15, x);
}
foo(x, y) => throw "foo" "$x";
foo(x, y) =>
throw "foo"
"$x";
bar(x, y) => throw "foo" "${throw x}";
bar(x, y) =>
throw "foo"
"${throw x}";
class Q {
var qqq;
@@ -22,7 +22,7 @@ class MyException implements TestException {
class MyParameterizedException<U, V> implements TestException {
const MyParameterizedException([String message = ""])
: this._message = message;
: this._message = message;
String getMessage() {
return _message;
}
@@ -6,8 +6,6 @@
// BSD-style license that can be found in the LICENSE file.
// Check that private dart:_ libraries cannot be imported.
main() {
print("Done.");
}
+1 -1
View File
@@ -4,7 +4,7 @@
// Check that private dart:_ libraries cannot be imported.
export "dart:_internal";
// [error line 6, column 1, length 24]
// [error column 1, length 24]
// [analyzer] COMPILE_TIME_ERROR.EXPORT_INTERNAL_LIBRARY
// [cfe] Can't access platform private library.
@@ -13,10 +13,10 @@ extension on C {
test(C c) {
c();
//^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] Cannot invoke an instance of 'C' because it declares 'call' to be something other than a method.
// [error column 3, length 1]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// [error column 4, length 1]
// [cfe] Cannot invoke an instance of 'C' because it declares 'call' to be something other than a method.
}
main() {}
@@ -31,18 +31,18 @@ void main() {
// Inferred type of String does not satisfy the bound.
s.e1;
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
// [cfe] The getter 'e1' isn't defined for the class 'String'.
//^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
// [cfe] The getter 'e1' isn't defined for the class 'String'.
E1(s).e1;
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE
// [cfe] The argument type 'String' can't be assigned to the parameter type 'num'.
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE
// [cfe] The argument type 'String' can't be assigned to the parameter type 'num'.
E1<String>(s).e1;
//^
// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'E1|get#e1'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
// [error column 3]
// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'E1|get#e1'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
// Inferred types of int and double are ok
i.e1;
@@ -54,18 +54,18 @@ void main() {
// Inferred type of String does not satisfy the bound.
s.e2;
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
// [cfe] The getter 'e2' isn't defined for the class 'String'.
//^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
// [cfe] The getter 'e2' isn't defined for the class 'String'.
E2(s).e2;
//^^
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
// [cfe] Inferred type argument 'String' doesn't conform to the bound 'S' of the type variable 'T' on 'E2|get#e2'.
// [error column 3, length 2]
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
// [cfe] Inferred type argument 'String' doesn't conform to the bound 'S' of the type variable 'T' on 'E2|get#e2'.
E2<String, num>(s).e2;
//^
// [cfe] Type argument 'String' doesn't conform to the bound 'S' of the type variable 'T' on 'E2|get#e2'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
// [error column 3]
// [cfe] Type argument 'String' doesn't conform to the bound 'S' of the type variable 'T' on 'E2|get#e2'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
// Inferred types of int and double are ok
i.e2;
@@ -78,17 +78,17 @@ void main() {
// Inferred type int for method type parameter doesn't match the inferred
// bound of String
s.f3(3);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
E3(s).f3(3);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
E3<String>(s).f3(3);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
// Inferred type int for method type parameter is ok
i.f3(3);
@@ -98,17 +98,17 @@ void main() {
// Inferred type int for method type parameter doesn't match the inferred
// bound of double
d.f3(3);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
E3(d).f3(3);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
E3<double>(d).f3(3);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
RecSolution recs = RecSolution();
Rec<dynamic> superRec = RecSolution(); // Super-bounded type.
@@ -120,16 +120,16 @@ void main() {
// Inferred super-bounded type is invalid as type argument
superRec.e4;
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
// [cfe] The getter 'e4' isn't defined for the class 'Rec<dynamic>'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
// [cfe] The getter 'e4' isn't defined for the class 'Rec<dynamic>'.
E4(superRec).e4;
//^^
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
// [cfe] Inferred type argument 'Rec<dynamic>' doesn't conform to the bound 'Rec<T>' of the type variable 'T' on 'E4|get#e4'.
// [error column 3, length 2]
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
// [cfe] Inferred type argument 'Rec<dynamic>' doesn't conform to the bound 'Rec<T>' of the type variable 'T' on 'E4|get#e4'.
E4<Rec<dynamic>>(superRec).e4;
//^
// [cfe] Type argument 'Rec<dynamic>' doesn't conform to the bound 'Rec<T>' of the type variable 'T' on 'E4|get#e4'.
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
// [error column 3]
// [cfe] Type argument 'Rec<dynamic>' doesn't conform to the bound 'Rec<T>' of the type variable 'T' on 'E4|get#e4'.
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
@@ -15,74 +15,90 @@ void main() {
const c01 = ~i;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// [cfe] Constant evaluation error:
const c02 = b & b;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c03 = b | b;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c04 = b ^ b;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c05 = i ~/ i;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c06 = i >> i;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c08 = i << i;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c09 = i + i;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c10 = -i;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// [cfe] Constant evaluation error:
const c11 = d - d;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c12 = d * d;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c13 = d / d;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c14 = d % d;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c15 = d < i;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c16 = i <= d;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c17 = d > i;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c18 = i >= i;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
const c19 = s.length;
// ^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_EXTENSION_METHOD
// ^
// [cfe] Constant evaluation error:
}
@@ -7,7 +7,7 @@ import "package:expect/expect.dart";
// It is an error to import a deferred library containing extensions without
// hiding them.
import "helpers/on_object.dart" deferred as p1;
// [error line 9, column 1]
// [error column 1]
// [cfe] Extension 'OnObject' cannot be imported through a deferred import.
// ^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.DEFERRED_IMPORT_OF_EXTENSION
@@ -9,9 +9,9 @@ import "helpers/on_object.dart" deferred as p1 hide OnObject;
void main() {
Object o = 1;
OnObject(o).onObject;
//^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_FUNCTION
// [cfe] Method not found: 'OnObject'.
// [error column 3, length 8]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_FUNCTION
// [cfe] Method not found: 'OnObject'.
o.onObject;
//^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
@@ -164,30 +164,30 @@ void test1() {
// [cfe] The property 'm2' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
c1b[0];
//^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// ^
// [cfe] The operator '[]' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
// [error column 3, length 3]
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// ^
// [cfe] The operator '[]' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
c1b[0] = 0;
//^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// ^
// [cfe] The operator '[]=' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
// [error column 3, length 3]
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// ^
// [cfe] The operator '[]=' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
c1b[0] += 0;
//^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// ^
// [cfe] The operator '[]' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
// [cfe] The operator '[]=' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
// [error column 3, length 3]
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// ^
// [cfe] The operator '[]' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
// [cfe] The operator '[]=' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
c1b[0]++;
//^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// ^
// [cfe] The operator '[]' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
// [cfe] The operator '[]=' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
// [error column 3, length 3]
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// ^
// [cfe] The operator '[]' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
// [cfe] The operator '[]=' is defined in multiple extensions for 'C1<Object?>' and neither is more specific.
C1<Object> c1c = C1<Object>(); // E1A is more specific.
@@ -47,11 +47,12 @@ main() {
// Cascades work.
expectSet(
"E1.v4=E1.v4+[C.v1=C.v1-[C.v3=a]]",
c
..v3 = Result("a")
..v1 -= Result("[$lastSetter]")
..v4 += Result("[$lastSetter]"));
"E1.v4=E1.v4+[C.v1=C.v1-[C.v3=a]]",
c
..v3 = Result("a")
..v1 -= Result("[$lastSetter]")
..v4 += Result("[$lastSetter]"),
);
}
/// Expect the value of [result] to be the [expected] string
@@ -22,38 +22,38 @@ extension E1 on A1 {
void test() {
// The instance getter shadows the global setter
topLevelSetter = topLevelSetter + 1;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
topLevelSetter++;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
topLevelSetter = 0;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
// The instance getter shadows the global field setter
topLevelField = topLevelField + 1;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
topLevelField++;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
topLevelField = 0;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
// The instance getter shadows the global method
topLevelMethod(4);
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
}
}
@@ -68,38 +68,38 @@ extension E2 on A2 {
void test() {
// The instance setter shadows the global getter
topLevelGetter = topLevelGetter + 1;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
topLevelGetter++;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
topLevelGetter;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
topLevelGetter = 3;
// The instance setter shadows the global field getter
topLevelField = topLevelField + 1;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
topLevelField++;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
topLevelField;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
// The instance setter shadows the global method
topLevelMethod(4);
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'topLevelMethod'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'topLevelMethod'.
}
}
@@ -114,38 +114,38 @@ extension E3 on A3 {
void test() {
// The static getter shadows the global setter
topLevelSetter = topLevelSetter + 1;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
topLevelSetter++;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
topLevelSetter = 0;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelSetter'.
// The static getter shadows the global field setter
topLevelField = topLevelField + 1;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
topLevelField++;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
topLevelField = 0;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'topLevelField'.
// The static getter shadows the global method
topLevelMethod(4);
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
}
}
@@ -160,37 +160,37 @@ extension E4 on A4 {
void test() {
// The static setter shadows the global getter
topLevelGetter = topLevelGetter + 1;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
topLevelGetter++;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
topLevelGetter;
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelGetter'.
// The static setter shadows the global field getter
topLevelField = topLevelField + 1;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
topLevelField++;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
topLevelField;
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
// [error column 5, length 13]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'topLevelField'.
// The static setter shadows the global method
topLevelMethod(4);
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'topLevelMethod'.
// [error column 5, length 14]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'topLevelMethod'.
}
}
@@ -210,24 +210,24 @@ extension E6 on A6 {
void test() {
// The instance getter shadows the other extension's setter
extensionSetter = extensionSetter + 1;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
extensionSetter++;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
extensionSetter = 0;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// The instance getter shadows the other extensions method
extensionMethod(4);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
}
}
@@ -241,24 +241,24 @@ class A7 extends A6 {
void test() {
// The instance getter shadows the other extension's setter
extensionSetter = extensionSetter + 1;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] The setter 'extensionSetter' isn't defined for the class 'A7'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] The setter 'extensionSetter' isn't defined for the class 'A7'.
extensionSetter++;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] The setter 'extensionSetter' isn't defined for the class 'A7'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] The setter 'extensionSetter' isn't defined for the class 'A7'.
extensionSetter = 0;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] The setter 'extensionSetter' isn't defined for the class 'A7'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] The setter 'extensionSetter' isn't defined for the class 'A7'.
// The instance getter shadows the other extensions method
extensionMethod(4);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] 'extensionMethod' isn't a function or method and can't be invoked.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] 'extensionMethod' isn't a function or method and can't be invoked.
}
}
@@ -276,23 +276,23 @@ extension E8 on A8 {
void test() {
// The instance setter shadows the other extension's getter
extensionGetter = extensionGetter + 1;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
extensionGetter++;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
extensionGetter;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// The instance setter shadows the other extension's method.
extensionMethod(4);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'extensionMethod'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'extensionMethod'.
}
}
@@ -306,23 +306,23 @@ class A9 extends A8 {
void test() {
// The instance setter shadows the other extension's getter
extensionGetter = extensionGetter + 1;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The getter 'extensionGetter' isn't defined for the class 'A9'.
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The getter 'extensionGetter' isn't defined for the class 'A9'.
extensionGetter++;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The getter 'extensionGetter' isn't defined for the class 'A9'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The getter 'extensionGetter' isn't defined for the class 'A9'.
extensionGetter;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The getter 'extensionGetter' isn't defined for the class 'A9'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The getter 'extensionGetter' isn't defined for the class 'A9'.
// The instance setter shadows the other extension's method.
extensionMethod(4);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] The method 'extensionMethod' isn't defined for the class 'A9'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] The method 'extensionMethod' isn't defined for the class 'A9'.
}
}
@@ -342,38 +342,38 @@ extension E10 on A10 {
void test() {
// The static getter shadows the other extension's setter
extensionSetter = extensionSetter + 1;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
extensionSetter++;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
extensionSetter = 0;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// The static field shadows the other extension's setter
extensionFieldSetter = extensionFieldSetter + 1;
// ^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
// [error column 5, length 20]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
extensionFieldSetter++;
// ^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
// [error column 5, length 20]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
extensionFieldSetter = 0;
// ^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
// [error column 5, length 20]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
// The static getter shadows the other extensions method
extensionMethod(4);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
}
}
@@ -388,38 +388,38 @@ class A11 extends A10 {
void test() {
// The static getter shadows the other extension's setter
extensionSetter = extensionSetter + 1;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
extensionSetter++;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
extensionSetter = 0;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
// [cfe] Setter not found: 'extensionSetter'.
// The static field shadows the other extension's setter
extensionFieldSetter = extensionFieldSetter + 1;
// ^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
// [error column 5, length 20]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
extensionFieldSetter++;
// ^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
// [error column 5, length 20]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
extensionFieldSetter = 0;
// ^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
// [error column 5, length 20]
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] Setter not found: 'extensionFieldSetter'.
// The static getter shadows the other extensions method
extensionMethod(4);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'int'.
}
}
@@ -437,23 +437,23 @@ extension E12 on A12 {
void test() {
// The static setter shadows the other extension's getter
extensionGetter = extensionGetter + 1;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
extensionGetter++;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
extensionGetter;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// The static setter shadows the other extension's method.
extensionMethod(4);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'extensionMethod'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'extensionMethod'.
}
}
@@ -467,23 +467,23 @@ class A13 extends A12 {
void test() {
// The static setter shadows the other extension's getter
extensionGetter = extensionGetter + 1;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
extensionGetter++;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
extensionGetter;
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Getter not found: 'extensionGetter'.
// The static setter shadows the other extension's method.
extensionMethod(4);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'extensionMethod'.
// [error column 5, length 15]
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] Getter not found: 'extensionMethod'.
}
}
@@ -6,9 +6,9 @@
// It is an error to have duplicate type parameter names.
extension E1<T, T> on int {
// ^
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
// [cfe] A type variable can't have the same name as another.
// ^
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
// [cfe] A type variable can't have the same name as another.
}
extension E2 on int {}
@@ -236,23 +236,20 @@ class B extends A {
bool t0 = fieldInExtensionScope;
// ^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// [cfe] The property 'fieldInExtensionScope' is defined in multiple extensions for 'B' and neither is more specific.
// ^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The property 'fieldInExtensionScope' is defined in multiple extensions for 'B' and neither is more specific.
checkExtensionValue(t0);
bool t1 = getterInExtensionScope;
// ^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// [cfe] The property 'getterInExtensionScope' is defined in multiple extensions for 'B' and neither is more specific.
// ^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The property 'getterInExtensionScope' is defined in multiple extensions for 'B' and neither is more specific.
checkExtensionValue(t1);
setterInExtensionScope = extensionValue;
// ^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// [cfe] The property 'setterInExtensionScope' is defined in multiple extensions for 'B' and neither is more specific.
// ^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [error column 7, length 22]
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] The property 'setterInExtensionScope' is defined in multiple extensions for 'B' and neither is more specific.
bool t2 = methodInExtensionScope();
// ^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXTENSION_MEMBER_ACCESS
@@ -18,15 +18,23 @@ class C {
main() {
var string = '';
context<int>(
string.f(contextType([1])..expectStaticType<Exactly<List<int>>>()));
string.f(contextType([1])..expectStaticType<Exactly<List<int>>>()),
);
context<int>(
E(string).f(contextType([1])..expectStaticType<Exactly<List<int>>>()));
E(string).f(contextType([1])..expectStaticType<Exactly<List<int>>>()),
);
var nullableString = '' as String?;
context<int?>(nullableString
?.f(contextType([1])..expectStaticType<Exactly<List<int?>>>()));
context<int?>(E(nullableString)
?.f(contextType([1])..expectStaticType<Exactly<List<int?>>>()));
context<int?>(
nullableString?.f(
contextType([1])..expectStaticType<Exactly<List<int?>>>(),
),
);
context<int?>(
E(
nullableString,
)?.f(contextType([1])..expectStaticType<Exactly<List<int?>>>()),
);
// And just to verify that the expectations above are reasonable, repeat the
// same thing with an ordinary class:
@@ -34,5 +42,6 @@ main() {
context<int>(c.g(contextType([1])..expectStaticType<Exactly<List<int>>>()));
var nullableC = C() as C?;
context<int?>(
nullableC?.g(contextType([1])..expectStaticType<Exactly<List<int?>>>()));
nullableC?.g(contextType([1])..expectStaticType<Exactly<List<int?>>>()),
);
}
@@ -76,10 +76,14 @@ void main() {
expect("(a+b[b(c)]((a*b)))", a + b[c[a] = b(c)](a * b), "c[a]=b(c)");
// Operator precedence is unaffected by being extensions.
expect("(c<((-a)|(b^((~c)&((a<<b)>>((c-a)+((((b*c)~/a)%b)/c)))))))",
c < -a | b ^ ~c & a << b >> c - a + b * c ~/ a % b / c);
expect("((((((((((((c/b)%a)~/c)*b)+a)-c)<<b)>>a)&(~c))^b)|(-a))>b)",
c / b % a ~/ c * b + a - c << b >> a & ~c ^ b | -a > b);
expect(
"(c<((-a)|(b^((~c)&((a<<b)>>((c-a)+((((b*c)~/a)%b)/c)))))))",
c < -a | b ^ ~c & a << b >> c - a + b * c ~/ a % b / c,
);
expect(
"((((((((((((c/b)%a)~/c)*b)+a)-c)<<b)>>a)&(~c))^b)|(-a))>b)",
c / b % a ~/ c * b + a - c << b >> a & ~c ^ b | -a > b,
);
}
// Last value set by []= or setter.
@@ -23,17 +23,22 @@ main() {
context<num>(E(string).s1 = contextType(1)..expectStaticType<Exactly<int>>());
context<num?>(string.s2 = contextType(1)..expectStaticType<Exactly<int?>>());
context<num?>(
E(string).s2 = contextType(1)..expectStaticType<Exactly<int?>>());
E(string).s2 = contextType(1)..expectStaticType<Exactly<int?>>(),
);
var nullableString = '' as String?;
context<num?>(
nullableString?.s1 = contextType(1)..expectStaticType<Exactly<int>>());
nullableString?.s1 = contextType(1)..expectStaticType<Exactly<int>>(),
);
context<num?>(
E(nullableString)?.s1 = contextType(1)..expectStaticType<Exactly<int>>());
E(nullableString)?.s1 = contextType(1)..expectStaticType<Exactly<int>>(),
);
context<num?>(
nullableString?.s2 = contextType(1)..expectStaticType<Exactly<int?>>());
context<num?>(E(nullableString)?.s2 = contextType(1)
..expectStaticType<Exactly<int?>>());
nullableString?.s2 = contextType(1)..expectStaticType<Exactly<int?>>(),
);
context<num?>(
E(nullableString)?.s2 = contextType(1)..expectStaticType<Exactly<int?>>(),
);
// And just to verify that the expectations above are reasonable, repeat the
// same thing with an ordinary class:
@@ -42,7 +47,9 @@ main() {
context<num?>(c.s4 = contextType(1)..expectStaticType<Exactly<int?>>());
var nullableC = C() as C?;
context<num?>(
nullableC?.s3 = contextType(1)..expectStaticType<Exactly<int>>());
nullableC?.s3 = contextType(1)..expectStaticType<Exactly<int>>(),
);
context<num?>(
nullableC?.s4 = contextType(1)..expectStaticType<Exactly<int?>>());
nullableC?.s4 = contextType(1)..expectStaticType<Exactly<int?>>(),
);
}
@@ -7,21 +7,15 @@
// of the setter.
extension E1 on int {
static int get property => 1;
// ^^
// [cfe] unspecified
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int' of the getter 'property' is not a subtype of the type 'String' of the setter 'property'.
static void set property(String value) {}
// ^^
// [cfe] unspecified
int get property2 => 1;
// ^^
// [cfe] unspecified
// ^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int' of the getter 'property2' is not a subtype of the type 'String' of the setter 'property2'.
void set property2(String x) {}
// ^^
// [cfe] unspecified
}
void main() {}
@@ -17,7 +17,6 @@ extension on C? {
f(this.cProp);
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
// ^
// [cfe] Property 'cProp' cannot be accessed on 'C?' because it is potentially null.
f(cProp);
//^^^^^
@@ -18,23 +18,23 @@ extension type ExtensionTypeMap<K, V>(Map<K, V> it) implements Map<K, V> {
nonExhaustiveSealedSubtype(ExtensionTypeList<A> list) {
return switch (list) {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeList<A>' is not exhaustively matched by the switch cases since it doesn't match '[B(), C()]'.
[] => 0,
[_] => 1,
[_, B()] => 2,
[_, _, _, ...] => 3,
};
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeList<A>' is not exhaustively matched by the switch cases since it doesn't match '[B(), C()]'.
[] => 0,
[_] => 1,
[_, B()] => 2,
[_, _, _, ...] => 3,
};
}
nonExhaustiveMapExtensionType1(ExtensionTypeMap<int, A> map) {
var a = switch (map) {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(isEmpty: false)'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(isEmpty: false)'.
Map(isEmpty: true) => 0,
{0: B b, 1: _} => 4,
{0: C c, 1: _} => 5,
@@ -47,52 +47,54 @@ nonExhaustiveMapExtensionType1(ExtensionTypeMap<int, A> map) {
}
nonExhaustiveMapExtensionType2(ExtensionTypeMap<int, A> map) {
var c = switch (map) {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>()'.
var c = switch (map) {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>()'.
Map<int, B>() => 0,
};
}
nonExhaustiveMapMethod(ExtensionTypeMap<int, A> map) {
return switch (map) {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(method: A Function(int) _)'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(method: A Function(int) _)'.
ExtensionTypeMap(:B Function(int) method) => 0,
};
}
nonExhaustiveMapGetter(ExtensionTypeMap<int, A> map) {
return switch (map) {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(getter: C())'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(getter: C())'.
ExtensionTypeMap(:B getter) => 0,
};
}
nonExhaustiveMapGenericMethod(ExtensionTypeMap<int, A> map) {
return switch (map) {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(genericMethod: void Function<T>(int, A, void Function<T>(T)) _)'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(genericMethod: void Function<T>(int, A, void Function<T>(T)) _)'.
ExtensionTypeMap(
:void Function<X>(int, B, void Function(X)) genericMethod) => 0,
:void Function<X>(int, B, void Function(X)) genericMethod,
) =>
0,
};
}
nonExhaustiveMapField(ExtensionTypeMap<int, A> map) {
return switch (map) {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(it: Map<int, A>())'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_EXHAUSTIVE_SWITCH_EXPRESSION
// ^
// [cfe] The type 'ExtensionTypeMap<int, A>' is not exhaustively matched by the switch cases since it doesn't match 'Map<int, A>(it: Map<int, A>())'.
ExtensionTypeMap(:Map<int, B> it) => 0,
};
}
@@ -20,11 +20,11 @@ extension type ExtensionTypeMap<K, V>(Map<K, V> it) implements Map<K, V> {
exhaustiveListExtensionType(ExtensionTypeList<A> list) {
return switch (list) {
[] => 0,
[B()] => 1,
[C()] => 2,
[_, _, ...]=> 3,
};
[] => 0,
[B()] => 1,
[C()] => 2,
[_, _, ...] => 3,
};
}
exhaustiveMapExtensionType1(ExtensionTypeMap<int, A> map) {
@@ -68,7 +68,9 @@ exhaustiveMapGetter(ExtensionTypeMap<int, A> map) {
exhaustiveMapGenericMethod(ExtensionTypeMap<int, A> map) {
return switch (map) {
ExtensionTypeMap(
:void Function<X>(int, A, void Function(X)) genericMethod) => 0,
:void Function<X>(int, A, void Function(X)) genericMethod,
) =>
0,
};
}
@@ -35,4 +35,4 @@ method<T>(G<T> g, T t) {
main() {
method<int>(G<int>(EImpl<int>()), 0);
method<String>(G<String>(EImpl<String>()), '');
}
}
@@ -26,9 +26,7 @@ num Function(A<num>) producingFunctionA() => ((A<num> a) => 0);
test2() =>
acceptingFunctionET1(producingFunctionA()).expectStaticType<Exactly<num>>();
enum E<X> {
element<String>();
}
enum E<X> { element<String>() }
extension type ET2<Y>(E<Y> it) implements E<Y> {}
@@ -39,7 +37,8 @@ ET2<T> producingET2<T>() => ET2<T>(producingE<T>());
// In type constraint generation, ET2<T> is compared against E<String>,
// yielding the constraint T <: String.
test3() => context<E<String>>(
producingET2()..expectStaticType<Exactly<ET2<String>>>());
producingET2()..expectStaticType<Exactly<ET2<String>>>(),
);
T acceptingFunctionET2<T>(T Function(ET2<T>) f) => f(ET2<T>(producingE<T>()));
@@ -47,8 +46,10 @@ String Function(E<String>) producingFunctionE() => ((E<String> e) => "");
// In type constraint generation, E<String> is compared against ET2<T>,
// yielding the constraint String <: T.
test4() => acceptingFunctionET2(producingFunctionE())
.expectStaticType<Exactly<String>>();
test4() =>
acceptingFunctionET2(
producingFunctionE(),
).expectStaticType<Exactly<String>>();
extension type ET3<Y>(A<Y> it) implements ET1<Y> {}
@@ -73,14 +74,17 @@ ET4<T> producingET4<T>() => ET4<T>(producingE<T>());
// In type constraint generation, ET4<T> is compared against E<String>,
// yielding the constraint T <: String.
test7() => context<E<String>>(
producingET4()..expectStaticType<Exactly<ET4<String>>>());
producingET4()..expectStaticType<Exactly<ET4<String>>>(),
);
T acceptingFunctionET4<T>(Function(ET4<T>) f) => f(ET4<T>(producingE<T>()));
// In type constraint generation, E<String> is compared against ET4<T>,
// yielding the constraint String <: T.
test8() => acceptingFunctionET4(producingFunctionE())
.expectStaticType<Exactly<String>>();
test8() =>
acceptingFunctionET4(
producingFunctionE(),
).expectStaticType<Exactly<String>>();
main() {
test1();
@@ -74,4 +74,4 @@ main() {
testMapSwitch(MyMap<String, int>({'foo': 5}), 1);
testMapSwitch(MyMap<String, int>({'bar': 4}), 4);
testMapSwitch(MyMap<String, int>({'bar': 7}), 1);
}
}
@@ -8,12 +8,12 @@
// and getters "conflicting" with them.
extension type const Ext1.name0(int i) {
Ext1.name1(this.i);
Ext1.name2(int i): this.name0(i);
Ext1.name2(int i) : this.name0(i);
factory Ext1.name3(int i) = Ext1.name0;
factory Ext1.name4(int i) => Ext1.name0(i);
const Ext1.name5(this.i);
const Ext1.name6(int i): this.name0(i);
const Ext1.name6(int i) : this.name0(i);
const factory Ext1.name7(int i) = Ext1.name0;
int get name0 => i;
@@ -35,18 +35,17 @@ class C {
// Other instance members with same name as constructors,
// both extension and interface members.
extension type const Ext2.name0(C _) implements C {
Ext2.name1(): this.name0(C());
Ext2.name2(): this.name0(C());
Ext2.name3(): this.name0(C());
Ext2.name4(): this.name0(C());
Ext2.name5(): this.name0(C());
Ext2.name1() : this.name0(C());
Ext2.name2() : this.name0(C());
Ext2.name3() : this.name0(C());
Ext2.name4() : this.name0(C());
Ext2.name5() : this.name0(C());
int get name0 => 0;
set name1(int i) {}
int name2() => 0;
}
void main() {
Ext1 e = Ext1.name0(0);
var res = [
@@ -62,13 +61,6 @@ void main() {
if (res.length != 8) throw AssertionError("Sanity check failed");
Ext2 c = Ext2.name0(C());
var res2 = [
c.name0,
c.name1 = 0,
c.name2(),
c.name3,
c.name4 = 0,
c.name5(),
];
var res2 = [c.name0, c.name1 = 0, c.name2(), c.name3, c.name4 = 0, c.name5()];
if (res2.length != 6) throw AssertionError("Sanity check failed");
}
@@ -9,4 +9,4 @@ extension type const E(Null _) {}
void main() {
E e = const E(null); // Failed here.
assert(e._ == null);
}
}
@@ -15,13 +15,11 @@ List<T> copyList<T>(MyList<T> list) {
return copy;
}
Set<T> copySet<T>(MySet<T> set) {
var copy = {...set};
return copy;
}
Map<K, V> copyMap<K, V>(MyMap<K, V> map) {
var copy = {...map};
return copy;
@@ -29,11 +27,11 @@ Map<K, V> copyMap<K, V>(MyMap<K, V> map) {
main() {
MyList<int> list = MyList([1, 2, 3]);
Expect.deepEquals(list , copyList(list));
Expect.deepEquals(list, copyList(list));
MySet<int> set = MySet({1, 2, 3});
Expect.deepEquals(set , copySet(set));
Expect.deepEquals(set, copySet(set));
MyMap<int, bool> map = MyMap({1: true, 2: false, 3: true});
Expect.deepEquals(map , copyMap(map));
}
Expect.deepEquals(map, copyMap(map));
}
+10 -4
View File
@@ -26,7 +26,7 @@ Iterable<T> duplicateList<T>(MyList<T> list) sync* {
Stream<T> toStream<T>(MyList<T> list) async* {
for (var a in list) {
yield a;
yield a;
}
}
@@ -54,6 +54,12 @@ main() async {
Expect.listEquals([1, 2, 3], await toList(stream));
MyStream<int> stream1 = MyStream<int>(toStream<int>(list));
MyStream<int> stream2 = MyStream<int>(toStream<int>(list));
Expect.listEquals([1, 2, 3, 1, 2, 3],
await toList(MyStream<int>(duplicateStream(stream1, stream2))));
}
Expect.listEquals([
1,
2,
3,
1,
2,
3,
], await toList(MyStream<int>(duplicateStream(stream1, stream2))));
}
@@ -7,13 +7,13 @@
// Check that abstract declarations are abstract.
class Abstract1 {
// ^
// [cfe] The non-abstract class 'Abstract1' is missing implementations for these members:
// ^
// [cfe] The non-abstract class 'Abstract1' is missing implementations for these members:
// The class is not abstract and does not have an implementation of `x`.
abstract int x;
// ^
// [analyzer] unspecified
// [error column 3, length 15]
// [analyzer] COMPILE_TIME_ERROR.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
}
// Check that class has expected interface.
@@ -29,9 +29,8 @@ abstract class Abstract2 {
// Cannot assign to final field.
a.x = 42;
//^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] The setter 'x' isn't defined for the class 'Abstract2'.
// ^
// [analyzer] unspecified
String y = a.y;
a.y = "ab";
@@ -39,7 +38,7 @@ abstract class Abstract2 {
// Cannot assign something of wrong type, even if covariant.
a.y = Object();
// ^^^^^^^^
// [analyzer] unspecified
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// [cfe] A value of type 'Object' can't be assigned to a variable of type 'String'.
}
@@ -49,9 +48,8 @@ abstract class Abstract2 {
// Cannot assign to final field.
this.x = 42;
// ^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] The setter 'x' isn't defined for the class 'Abstract2'.
// ^
// [analyzer] unspecified
String y = this.y;
this.y = "ab";
@@ -59,7 +57,7 @@ abstract class Abstract2 {
// Cannot assign something of wrong type, even if covariant.
this.y = Object();
// ^^^^^^^^
// [analyzer] unspecified
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// [cfe] A value of type 'Object' can't be assigned to a variable of type 'String'.
}
}
@@ -23,8 +23,8 @@ class D {
int u1, u2;
covariant int v1, v2, v3;
covariant var w;
D() :
x1 = 0,
D()
: x1 = 0,
x2 = 0,
y1 = 1,
y2 = 1,
@@ -42,7 +42,8 @@ class D {
class E extends D implements C {}
// Valid declarations when superclass has implementation.
class F extends D { // Class is not abstract.
class F extends D {
// Class is not abstract.
abstract int x1, x2;
abstract var y1, y2, y3;
abstract final z;
@@ -60,14 +61,17 @@ class Logger {
lastName = #x;
return _x;
}
set x(String value) {
lastName = #x;
_x = value;
}
int get y {
lastName = #y;
return _y;
}
set y(int value) {
lastName = #y;
_y = value;
@@ -22,9 +22,9 @@ class External2 {
// Cannot assign to final field.
a.x = 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified
//^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
// [cfe] The setter 'x' isn't defined for the class 'External2'.
String y = a.y;
a.y = "ab";
@@ -32,8 +32,8 @@ class External2 {
// Cannot assign something of wrong type, even if covariant.
a.y = Object();
// ^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// [cfe] A value of type 'Object' can't be assigned to a variable of type 'String'.
}
}