Files
sdk/pkg/front_end/testcases/none/operator.dart
T
Johnni Winther 5dbb6e245b [kernel,cfe,ddc] Add new method invocation node to package:kernel
This adds
* InstanceInvocation, DynamicInvocation, FunctionInvocation, and
   LocalFunctionInvocation, EqualsCall, and EqualsNull as a future
   replacement for MethodInvocation.
* InstanceGet, DynamicGet, InstanceTearOff, and FunctionTearOff as a
   future replacement for PropertyGet
* InstanceSet and DynamicSet as a future replacement of PropertySet
* StaticTearOff as an addition to StaticGet

TEST=pkg/front_end/test/binary_md_vm_tags_and_version_test.dart

This CL combines
* https://dart-review.googlesource.com/c/sdk/+/171729
* https://dart-review.googlesource.com/c/sdk/+/172649
* https://dart-review.googlesource.com/c/sdk/+/172650
* https://dart-review.googlesource.com/c/sdk/+/172651

using the initial encoding fo EqualsCall and EqualsNull

Change-Id: I98e020b5f2b405a812663bdcd2c05aba8efa74c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175480
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-12-14 10:55:48 +00:00

133 lines
2.5 KiB
Dart

// Copyright (c) 2020, 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.md file.
class Class<T> {
Class<T> operator +(Class<T> other) => other;
Class<T> operator -() => this;
Class<T> operator [](int index) => this;
operator []=(int index, Class<T> value) {}
int method(double o) => 42;
}
add(num n, int i, double d, Class<String> c, dynamic dyn, Never never,
String string) {
print('InstanceInvocation');
n + n;
n + i;
n + d;
n + dyn;
print('InstanceInvocation');
i + n;
i + i;
i + d;
i + dyn;
print('InstanceInvocation');
d + n;
d + i;
d + d;
i + dyn;
print('InstanceInvocation');
c + c;
c + dyn;
print('DynamicInvocation');
dyn + n;
print('DynamicInvocation (Never)');
never + n;
print('DynamicInvocation (Invalid)');
string - 42;
}
unaryMinus(num n, int i, double d, Class<String> c, dynamic dyn, Never never,
String string) {
print('InstanceInvocation');
-n;
-i;
-d;
-c;
print('DynamicInvocation');
-dyn;
print('DynamicInvocation (Never)');
-never;
print('DynamicInvocation (Invalid)');
-c.method();
print('DynamicInvocation (Unresolved)');
-string;
}
indexGet(List<int> list, Map<String, double> map, Class<String> c, dynamic dyn,
Never never, String string) {
print('InstanceInvocation');
list[0];
map['foo'];
c[0];
print('DynamicInvocation');
dyn[0];
print('DynamicInvocation (Never)');
never[0];
print('DynamicInvocation (Invalid)');
c.method()[0];
print('DynamicInvocation (Unresolved)');
string[0];
}
indexSet(List<int> list, Map<String, double> map, Class<String> c, dynamic dyn,
Never never) {
print('InstanceInvocation');
list[0] = 42;
map['foo'] = 0.5;
c[0] = c;
print('DynamicInvocation');
dyn[0] = 42;
print('DynamicInvocation (Never)');
never[0] = 42;
print('DynamicInvocation (Invalid)');
c.method()[0] = 42;
print('DynamicInvocation (Unresolved)');
string[0] = 42;
}
compound(List<int> list, Map<String, double> map, Class<String> c, dynamic dyn,
Never never) {
print('InstanceInvocation');
list[0] += 42;
map['foo'] += 0.5;
c[0] += c;
print('DynamicInvocation');
dyn[0] += 42;
print('DynamicInvocation (Never)');
never[0] += 42;
print('DynamicInvocation (Invalid)');
c.method()[0] += 42;
print('DynamicInvocation (Unresolved)');
string[0] += 42;
}
main() {}