add fasta extension method test
Change-Id: I8de4f01463aa141ac4104d98b8ba42f970e32021
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103881
Commit-Queue: Dan Rubel <danrubel@google.com>
Auto-Submit: Dan Rubel <danrubel@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
diff --git a/pkg/front_end/testcases/extension_methods.dart b/pkg/front_end/testcases/extension_methods.dart
new file mode 100644
index 0000000..51013db
--- /dev/null
+++ b/pkg/front_end/testcases/extension_methods.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+// SharedOptions=--enable-experiment=extension-methods
+
+import 'package:expect/expect.dart';
+
+class C {
+ int get one => 1;
+}
+
+extension E on C {
+ int get two => 2;
+}
+
+main() {
+ C c = C();
+ var result = c.one + c.two;
+ Expect.equals(result, 3);
+}
diff --git a/pkg/front_end/testcases/extension_methods.dart.hierarchy.expect b/pkg/front_end/testcases/extension_methods.dart.hierarchy.expect
new file mode 100644
index 0000000..af7781c
--- /dev/null
+++ b/pkg/front_end/testcases/extension_methods.dart.hierarchy.expect
@@ -0,0 +1,418 @@
+Object:
+ superclasses:
+ interfaces:
+ classMembers:
+ Object._haveSameRuntimeType
+ Object.toString
+ Object.runtimeType
+ Object._toString
+ Object._simpleInstanceOf
+ Object._hashCodeRnd
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._objectHashCode
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+C:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ C.one
+ classSetters:
+
+Expect:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Expect.identical
+ Expect.throwsCastError
+ Expect._fail
+ Expect.notIdentical
+ Expect.isNotNull
+ Expect._getMessage
+ Expect.allIdentical
+ Expect._escapeSubstring
+ Expect.fail
+ Expect._truncateString
+ Expect.isFalse
+ Expect.isTrue
+ Object.toString
+ Expect.subtype
+ Expect.throwsRangeError
+ Expect._stringDifference
+ Expect.throwsArgumentError
+ Expect.stringEquals
+ Object.runtimeType
+ Expect.testError
+ Expect.throwsStateError
+ Object._simpleInstanceOf
+ Expect.isNull
+ Expect.approxEquals
+ Expect.equals
+ Object._instanceOf
+ Expect.allDistinct
+ Expect.throwsTypeError
+ Expect._subtypeAtRuntime
+ Expect.setEquals
+ Object.noSuchMethod
+ Expect.notEquals
+ Expect.listEquals
+ Expect._findEquivalences
+ Expect.mapEquals
+ Object._identityHashCode
+ Expect.throwsUnsupportedError
+ Expect.notType
+ Expect.deepEquals
+ Expect._escapeString
+ Expect.type
+ Object.hashCode
+ Expect.throwsNoSuchMethodError
+ Expect.notSubtype
+ Expect.throws
+ Object._simpleInstanceOfFalse
+ Expect._writeEquivalences
+ Expect.throwsAssertionError
+ Object._simpleInstanceOfTrue
+ Object.==
+ Expect.throwsFormatException
+ classSetters:
+
+Exception:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+ExpectException:
+ Longest path to Object: 2
+ superclasses:
+ Object
+ interfaces: Exception
+ classMembers:
+ ExpectException.message
+ ExpectException.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+ interfaceMembers:
+ ExpectException.message
+ ExpectException.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ interfaceSetters:
+
+Immutable:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Immutable.reason
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+Required:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Required.reason
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_AlwaysThrows:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_Checked:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_Experimental:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_Factory:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_IsTest:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_IsTestGroup:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_Literal:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_MustCallSuper:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_OptionalTypeArgs:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_Protected:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_Sealed:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_Virtual:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_VisibleForOverriding:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
+
+_VisibleForTesting:
+ superclasses:
+ Object
+ interfaces:
+ classMembers:
+ Object.toString
+ Object.runtimeType
+ Object._simpleInstanceOf
+ Object._instanceOf
+ Object.noSuchMethod
+ Object._identityHashCode
+ Object.hashCode
+ Object._simpleInstanceOfFalse
+ Object._simpleInstanceOfTrue
+ Object.==
+ classSetters:
diff --git a/pkg/front_end/testcases/extension_methods.dart.legacy.expect b/pkg/front_end/testcases/extension_methods.dart.legacy.expect
new file mode 100644
index 0000000..7fd1230
--- /dev/null
+++ b/pkg/front_end/testcases/extension_methods.dart.legacy.expect
@@ -0,0 +1,71 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Error: This requires the 'extension-methods' experiment to be enabled.
+// Try enabling this experiment by adding it to the command line when compiling and running.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:16: Error: A function declaration needs an explicit list of parameters.
+// Try adding a parameter list to the function declaration.
+// extension E on C {
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:16: Error: 'C' is already declared in this scope.
+// extension E on C {
+// ^
+// pkg/front_end/testcases/extension_methods.dart:9:7: Context: Previous declaration of 'C'.
+// class C {
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Warning: Type 'extension' not found.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:13: Warning: Type 'on' not found.
+// extension E on C {
+// ^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Warning: 'extension' isn't a type.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:14:7: Error: Expected ';' after this.
+// int get two => 2;
+// ^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:14:15: Error: A function declaration needs an explicit list of parameters.
+// Try adding a parameter list to the function declaration.
+// int get two => 2;
+// ^^
+//
+// pkg/front_end/testcases/extension_methods.dart:18:3: Error: Can't use 'C' because it is declared more than once.
+// C c = C();
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:18:9: Error: Can't use 'C' because it is declared more than once.
+// C c = C();
+// ^
+//
+import self as self;
+import "dart:core" as core;
+import "package:expect/expect.dart" as exp;
+
+import "package:expect/expect.dart";
+
+class C extends core::Object {
+ synthetic constructor •() → self::C
+ : super core::Object::•()
+ ;
+ get one() → core::int
+ return 1;
+}
+static field invalid-type E;
+static method main() → dynamic {
+ invalid-type c = invalid-expression "pkg/front_end/testcases/extension_methods.dart:18:9: Error: Can't use 'C' because it is declared more than once.
+ C c = C();
+ ^".call();
+ dynamic result = c.one.+(c.two);
+ exp::Expect::equals(result, 3);
+}
diff --git a/pkg/front_end/testcases/extension_methods.dart.legacy.transformed.expect b/pkg/front_end/testcases/extension_methods.dart.legacy.transformed.expect
new file mode 100644
index 0000000..7fd1230
--- /dev/null
+++ b/pkg/front_end/testcases/extension_methods.dart.legacy.transformed.expect
@@ -0,0 +1,71 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Error: This requires the 'extension-methods' experiment to be enabled.
+// Try enabling this experiment by adding it to the command line when compiling and running.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:16: Error: A function declaration needs an explicit list of parameters.
+// Try adding a parameter list to the function declaration.
+// extension E on C {
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:16: Error: 'C' is already declared in this scope.
+// extension E on C {
+// ^
+// pkg/front_end/testcases/extension_methods.dart:9:7: Context: Previous declaration of 'C'.
+// class C {
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Warning: Type 'extension' not found.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:13: Warning: Type 'on' not found.
+// extension E on C {
+// ^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Warning: 'extension' isn't a type.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:14:7: Error: Expected ';' after this.
+// int get two => 2;
+// ^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:14:15: Error: A function declaration needs an explicit list of parameters.
+// Try adding a parameter list to the function declaration.
+// int get two => 2;
+// ^^
+//
+// pkg/front_end/testcases/extension_methods.dart:18:3: Error: Can't use 'C' because it is declared more than once.
+// C c = C();
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:18:9: Error: Can't use 'C' because it is declared more than once.
+// C c = C();
+// ^
+//
+import self as self;
+import "dart:core" as core;
+import "package:expect/expect.dart" as exp;
+
+import "package:expect/expect.dart";
+
+class C extends core::Object {
+ synthetic constructor •() → self::C
+ : super core::Object::•()
+ ;
+ get one() → core::int
+ return 1;
+}
+static field invalid-type E;
+static method main() → dynamic {
+ invalid-type c = invalid-expression "pkg/front_end/testcases/extension_methods.dart:18:9: Error: Can't use 'C' because it is declared more than once.
+ C c = C();
+ ^".call();
+ dynamic result = c.one.+(c.two);
+ exp::Expect::equals(result, 3);
+}
diff --git a/pkg/front_end/testcases/extension_methods.dart.outline.expect b/pkg/front_end/testcases/extension_methods.dart.outline.expect
new file mode 100644
index 0000000..ccb8e3f
--- /dev/null
+++ b/pkg/front_end/testcases/extension_methods.dart.outline.expect
@@ -0,0 +1,43 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Error: This requires the 'extension-methods' experiment to be enabled.
+// Try enabling this experiment by adding it to the command line when compiling and running.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:16: Error: A function declaration needs an explicit list of parameters.
+// Try adding a parameter list to the function declaration.
+// extension E on C {
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:16: Error: 'C' is already declared in this scope.
+// extension E on C {
+// ^
+// pkg/front_end/testcases/extension_methods.dart:9:7: Context: Previous declaration of 'C'.
+// class C {
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Warning: Type 'extension' not found.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:13: Warning: Type 'on' not found.
+// extension E on C {
+// ^^
+//
+import self as self;
+import "dart:core" as core;
+
+import "package:expect/expect.dart";
+
+class C extends core::Object {
+ synthetic constructor •() → self::C
+ ;
+ get one() → core::int
+ ;
+}
+static field invalid-type E;
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/extension_methods.dart.strong.expect b/pkg/front_end/testcases/extension_methods.dart.strong.expect
new file mode 100644
index 0000000..b3845b4
--- /dev/null
+++ b/pkg/front_end/testcases/extension_methods.dart.strong.expect
@@ -0,0 +1,71 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Error: This requires the 'extension-methods' experiment to be enabled.
+// Try enabling this experiment by adding it to the command line when compiling and running.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:16: Error: A function declaration needs an explicit list of parameters.
+// Try adding a parameter list to the function declaration.
+// extension E on C {
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:16: Error: 'C' is already declared in this scope.
+// extension E on C {
+// ^
+// pkg/front_end/testcases/extension_methods.dart:9:7: Context: Previous declaration of 'C'.
+// class C {
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Error: Type 'extension' not found.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:13: Error: Type 'on' not found.
+// extension E on C {
+// ^^
+//
+// pkg/front_end/testcases/extension_methods.dart:13:1: Error: 'extension' isn't a type.
+// extension E on C {
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:14:7: Error: Expected ';' after this.
+// int get two => 2;
+// ^^^
+//
+// pkg/front_end/testcases/extension_methods.dart:14:15: Error: A function declaration needs an explicit list of parameters.
+// Try adding a parameter list to the function declaration.
+// int get two => 2;
+// ^^
+//
+// pkg/front_end/testcases/extension_methods.dart:18:3: Error: Can't use 'C' because it is declared more than once.
+// C c = C();
+// ^
+//
+// pkg/front_end/testcases/extension_methods.dart:18:9: Error: Can't use 'C' because it is declared more than once.
+// C c = C();
+// ^
+//
+import self as self;
+import "dart:core" as core;
+import "package:expect/expect.dart" as exp;
+
+import "package:expect/expect.dart";
+
+class C extends core::Object {
+ synthetic constructor •() → self::C
+ : super core::Object::•()
+ ;
+ get one() → core::int
+ return 1;
+}
+static field invalid-type E;
+static method main() → dynamic {
+ invalid-type c = invalid-expression "pkg/front_end/testcases/extension_methods.dart:18:9: Error: Can't use 'C' because it is declared more than once.
+ C c = C();
+ ^".call() as{TypeError} invalid-type;
+ dynamic result = c.one.+(c.two);
+ exp::Expect::equals(result, 3);
+}
diff --git a/pkg/front_end/testcases/legacy.status b/pkg/front_end/testcases/legacy.status
index b1b1917..e98216b 100644
--- a/pkg/front_end/testcases/legacy.status
+++ b/pkg/front_end/testcases/legacy.status
@@ -13,6 +13,7 @@
constructor_initializer_invalid: RuntimeError # Fails execution after recovery
control_flow_collection: RuntimeError
duplicated_field_initializer: RuntimeError
+extension_methods: RuntimeError
external_import: RuntimeError # Expected -- test uses import which doesn't exist.
fallthrough: Fail # Missing FallThroughError.
function_type_recovery: Fail
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index 79ac736..58b6314 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -22,6 +22,7 @@
duplicated_field_initializer: RuntimeError
dynamic_and_void: InstrumentationMismatch # Test assumes Dart 1.0 semantics
expressions: RuntimeError
+extension_methods: TypeCheckError
external_import: RuntimeError # The native extension to import doesn't exist. This is ok.
fallthrough: ExpectationFileMismatch
incomplete_field_formal_parameter: RuntimeError
diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status
index 8508fee..da910da 100644
--- a/pkg/front_end/testcases/text_serialization.status
+++ b/pkg/front_end/testcases/text_serialization.status
@@ -90,6 +90,7 @@
expression/eval: TextSerializationFailure # Was: Pass
expression/main: TextSerializationFailure # Was: Pass
expressions: TextSerializationFailure # Was: RuntimeError
+extension_methods: TypeCheckError
external: TextSerializationFailure # Was: Pass
external_import: TextSerializationFailure # Was: RuntimeError # The native extension to import doesn't exist. This is ok.
fallthrough: ExpectationFileMismatch