Version 2.13.0-140.0.dev
Merge commit 'c9e10c931cb7f6453fd34a9258c5ee53547afec8' into 'dev'
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index 1f20658..05338a0 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
@@ -112,7 +112,7 @@
if ((alreadyGenerated & _COMPLETION_TYPE_SETTER) != 0) {
return false;
} else if (element.hasDeprecated &&
- !element.correspondingGetter.hasDeprecated) {
+ !(element.correspondingGetter?.hasDeprecated ?? true)) {
// A deprecated setter should not take priority over a non-deprecated
// getter.
return false;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
index 9e5cf33..94d8faf 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
@@ -161,7 +161,9 @@
Source newSource =
NonExistingSource(newFile, pathos.toUri(newFile), UriKind.FILE_URI);
var restoredUri = driver.sourceFactory.restoreUri(newSource);
- if (restoredUri != null) {
+ // If the new URI is not a package: URI, fall back to computing a relative
+ // URI below.
+ if (restoredUri?.isScheme('package') ?? false) {
return restoredUri.toString();
}
}
diff --git a/pkg/analysis_server/test/services/refactoring/move_file_test.dart b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
index fc03973..e83a314 100644
--- a/pkg/analysis_server/test/services/refactoring/move_file_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
@@ -237,6 +237,31 @@
assertNoFileChange(testFile);
}
+ Future<void> test_file_moveOutOfLib() async {
+ var binMainPath = convertPath('/home/test/bin/main.dart');
+ addSource(binMainPath, '''
+import 'package:test/test.dart';
+
+main() {
+ var a = new Foo();
+}
+''');
+ await resolveTestCode('''
+class Foo {}
+''');
+ // perform refactoring
+ _createRefactoring('/home/test/bin/test.dart');
+ await _assertSuccessfulRefactoring();
+ assertFileChangeResult(binMainPath, '''
+import 'test.dart';
+
+main() {
+ var a = new Foo();
+}
+''');
+ assertNoFileChange(testFile);
+ }
+
@failingTest
Future<void> test_file_referenced_by_multiple_libraries() async {
// This test fails because the search index doesn't support multiple uris for
diff --git a/pkg/analysis_server/test/src/services/completion/dart/completion_test.dart b/pkg/analysis_server/test/src/services/completion/dart/completion_test.dart
index 79c79b7..004e07b 100644
--- a/pkg/analysis_server/test/src/services/completion/dart/completion_test.dart
+++ b/pkg/analysis_server/test/src/services/completion/dart/completion_test.dart
@@ -33,7 +33,22 @@
@reflectiveTest
class PropertyAccessorCompletionTest extends CompletionTestCase {
- Future<void> test_constructor_abstract() async {
+ Future<void> test_setter_deprecated() async {
+ addTestFile('''
+void f(C c) {
+ c.^;
+}
+class C {
+ @deprecated
+ set x(int x) {}
+}
+''');
+ await getSuggestions();
+ assertHasCompletion('x',
+ elementKind: ElementKind.SETTER, isDeprecated: true);
+ }
+
+ Future<void> test_setter_deprecated_withNonDeprecatedGetter() async {
addTestFile('''
void f(C c) {
c.^;
diff --git a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart
index 47dd6a1..b8aa152 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart
+++ b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart
@@ -18,6 +18,7 @@
int b = a + constTwo;
return b;
}
+
const value = addTwo(2);
return value;
}
@@ -53,6 +54,13 @@
return value;
}
+int function8() {
+ int add(int a, int b) => a + b;
+ const value = add(1, 1);
+ const value1 = add(2, 3);
+ return value + value1;
+}
+
void main() {
Expect.equals(function1(), 12);
Expect.equals(function2(), 4);
@@ -61,4 +69,5 @@
Expect.equals(function5(), 3);
Expect.equals(function6(), 1);
Expect.equals(function7(), 2);
+ Expect.equals(function8(), 7);
}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.strong.expect b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.strong.expect
index b20b02d..cd90a2e 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.strong.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.strong.expect
@@ -43,6 +43,11 @@
return a;
return #C1;
}
+static method function8() → core::int {
+ function add(core::int a, core::int b) → core::int
+ return a.{core::num::+}(b);
+ return (#C1).{core::num::+}(#C4);
+}
static method main() → void {
exp::Expect::equals(self::function1(), 12);
exp::Expect::equals(self::function2(), 4);
@@ -51,6 +56,7 @@
exp::Expect::equals(self::function5(), 3);
exp::Expect::equals(self::function6(), 1);
exp::Expect::equals(self::function7(), 2);
+ exp::Expect::equals(self::function8(), 7);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.strong.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.strong.transformed.expect
index b20b02d..2dc0292 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.strong.transformed.expect
@@ -43,6 +43,11 @@
return a;
return #C1;
}
+static method function8() → core::int {
+ function add(core::int a, core::int b) → core::int
+ return a.{core::num::+}(b);
+ return (#C1).{core::num::+}(#C4);
+}
static method main() → void {
exp::Expect::equals(self::function1(), 12);
exp::Expect::equals(self::function2(), 4);
@@ -51,6 +56,7 @@
exp::Expect::equals(self::function5(), 3);
exp::Expect::equals(self::function6(), 1);
exp::Expect::equals(self::function7(), 2);
+ exp::Expect::equals(self::function8(), 7);
}
constants {
@@ -63,3 +69,7 @@
#C7 = 0
#C8 = 1
}
+
+Extra constant evaluation status:
+Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_local_functions.dart:61:16 -> IntConstant(7)
+Extra constant evaluation: evaluated: 33, effectively constant: 1
diff --git a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.textual_outline.expect b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.textual_outline.expect
index 91aaea8..6b92e59 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.textual_outline.expect
@@ -8,4 +8,5 @@
int function5() {}
int function6() {}
int function7() {}
+int function8() {}
void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.textual_outline_modelled.expect
index 44ce8bf..06caca3 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.textual_outline_modelled.expect
@@ -8,4 +8,5 @@
int function5() {}
int function6() {}
int function7() {}
+int function8() {}
void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.expect b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.expect
index b20b02d..cd90a2e 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.expect
@@ -43,6 +43,11 @@
return a;
return #C1;
}
+static method function8() → core::int {
+ function add(core::int a, core::int b) → core::int
+ return a.{core::num::+}(b);
+ return (#C1).{core::num::+}(#C4);
+}
static method main() → void {
exp::Expect::equals(self::function1(), 12);
exp::Expect::equals(self::function2(), 4);
@@ -51,6 +56,7 @@
exp::Expect::equals(self::function5(), 3);
exp::Expect::equals(self::function6(), 1);
exp::Expect::equals(self::function7(), 2);
+ exp::Expect::equals(self::function8(), 7);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.outline.expect b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.outline.expect
index 7e9d751..2d98dcf2 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.outline.expect
@@ -19,5 +19,7 @@
;
static method function7() → core::int
;
+static method function8() → core::int
+ ;
static method main() → void
;
diff --git a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.transformed.expect
index b20b02d..2dc0292 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_local_functions.dart.weak.transformed.expect
@@ -43,6 +43,11 @@
return a;
return #C1;
}
+static method function8() → core::int {
+ function add(core::int a, core::int b) → core::int
+ return a.{core::num::+}(b);
+ return (#C1).{core::num::+}(#C4);
+}
static method main() → void {
exp::Expect::equals(self::function1(), 12);
exp::Expect::equals(self::function2(), 4);
@@ -51,6 +56,7 @@
exp::Expect::equals(self::function5(), 3);
exp::Expect::equals(self::function6(), 1);
exp::Expect::equals(self::function7(), 2);
+ exp::Expect::equals(self::function8(), 7);
}
constants {
@@ -63,3 +69,7 @@
#C7 = 0
#C8 = 1
}
+
+Extra constant evaluation status:
+Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_local_functions.dart:61:16 -> IntConstant(7)
+Extra constant evaluation: evaluated: 33, effectively constant: 1
diff --git a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart
index d77e883..78ad9d9 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart
+++ b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart
@@ -35,6 +35,10 @@
const doubleResult = doubleFn(2.2, 2);
double doubleFn(double a, double b) => a * b;
+const multi = multiFn(1);
+const multi2 = multiFn(2);
+int multiFn(int a) => a + 1;
+
void main() {
Expect.equals(binary, 1);
Expect.equals(optional, 2);
@@ -47,4 +51,6 @@
Expect.equals(negative, -2);
Expect.equals(boolean, true);
Expect.equals(doubleResult, 4.4);
+ Expect.equals(multi, 2);
+ Expect.equals(multi2, 3);
}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.strong.expect b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.strong.expect
index 977caaa..0d13bf0 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.strong.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.strong.expect
@@ -16,6 +16,8 @@
static const field core::int negative = #C9;
static const field core::bool boolean = #C8;
static const field core::double doubleResult = #C10;
+static const field core::int multi = #C2;
+static const field core::int multi2 = #C3;
static method binaryFn(core::int a, core::int b) → core::int
return a.{core::num::-}(b);
static method optionalFn(core::int c, [core::int d = #C11]) → core::int
@@ -34,6 +36,8 @@
return a || b;
static method doubleFn(core::double a, core::double b) → core::double
return a.{core::double::*}(b);
+static method multiFn(core::int a) → core::int
+ return a.{core::num::+}(1);
static method main() → void {
exp::Expect::equals(#C1, 1);
exp::Expect::equals(#C2, 2);
@@ -46,6 +50,8 @@
exp::Expect::equals(#C9, 2.{core::int::unary-}());
exp::Expect::equals(#C8, true);
exp::Expect::equals(#C10, 4.4);
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C3, 3);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.strong.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.strong.transformed.expect
index 920ec7f..de39112 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.strong.transformed.expect
@@ -16,6 +16,8 @@
static const field core::int negative = #C9;
static const field core::bool boolean = #C8;
static const field core::double doubleResult = #C10;
+static const field core::int multi = #C2;
+static const field core::int multi2 = #C3;
static method binaryFn(core::int a, core::int b) → core::int
return a.{core::num::-}(b);
static method optionalFn(core::int c, [core::int d = #C11]) → core::int
@@ -34,6 +36,8 @@
return a || b;
static method doubleFn(core::double a, core::double b) → core::double
return a.{core::double::*}(b);
+static method multiFn(core::int a) → core::int
+ return a.{core::num::+}(1);
static method main() → void {
exp::Expect::equals(#C1, 1);
exp::Expect::equals(#C2, 2);
@@ -46,6 +50,8 @@
exp::Expect::equals(#C9, 2.{core::int::unary-}());
exp::Expect::equals(#C8, true);
exp::Expect::equals(#C10, 4.4);
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C3, 3);
}
constants {
@@ -63,5 +69,5 @@
}
Extra constant evaluation status:
-Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_simple_invocations.dart:47:27 -> IntConstant(-2)
-Extra constant evaluation: evaluated: 35, effectively constant: 1
+Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_simple_invocations.dart:51:27 -> IntConstant(-2)
+Extra constant evaluation: evaluated: 39, effectively constant: 1
diff --git a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.textual_outline.expect b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.textual_outline.expect
index 13bdbb5..81a6fa3 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.textual_outline.expect
@@ -20,4 +20,7 @@
bool boolFn(bool a, bool b) => a || b;
const doubleResult = doubleFn(2.2, 2);
double doubleFn(double a, double b) => a * b;
+const multi = multiFn(1);
+const multi2 = multiFn(2);
+int multiFn(int a) => a + 1;
void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.textual_outline_modelled.expect
index a3e7b8c..6428837 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.textual_outline_modelled.expect
@@ -8,6 +8,8 @@
const boolean = boolFn(true, false);
const doubleResult = doubleFn(2.2, 2);
const eq = equalFn(2, 2);
+const multi = multiFn(1);
+const multi2 = multiFn(2);
const named = namedFn(2, f: 2);
const named1 = namedFn(2);
const negative = unary(2);
@@ -17,6 +19,7 @@
const type = typeFn(6);
double doubleFn(double a, double b) => a * b;
int binaryFn(int a, int b) => a - b;
+int multiFn(int a) => a + 1;
int namedFn(int e, {int f = 3}) => e + f;
int optionalFn(int c, [int d = 0]) => c + d;
int unary(int a) => -a;
diff --git a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.expect b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.expect
index 977caaa..0d13bf0 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.expect
@@ -16,6 +16,8 @@
static const field core::int negative = #C9;
static const field core::bool boolean = #C8;
static const field core::double doubleResult = #C10;
+static const field core::int multi = #C2;
+static const field core::int multi2 = #C3;
static method binaryFn(core::int a, core::int b) → core::int
return a.{core::num::-}(b);
static method optionalFn(core::int c, [core::int d = #C11]) → core::int
@@ -34,6 +36,8 @@
return a || b;
static method doubleFn(core::double a, core::double b) → core::double
return a.{core::double::*}(b);
+static method multiFn(core::int a) → core::int
+ return a.{core::num::+}(1);
static method main() → void {
exp::Expect::equals(#C1, 1);
exp::Expect::equals(#C2, 2);
@@ -46,6 +50,8 @@
exp::Expect::equals(#C9, 2.{core::int::unary-}());
exp::Expect::equals(#C8, true);
exp::Expect::equals(#C10, 4.4);
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C3, 3);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.outline.expect b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.outline.expect
index f3f61d3..d5201b0 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.outline.expect
@@ -15,6 +15,8 @@
static const field core::int negative = self::unary(2);
static const field core::bool boolean = self::boolFn(true, false);
static const field core::double doubleResult = self::doubleFn(2.2, 2.0);
+static const field core::int multi = self::multiFn(1);
+static const field core::int multi2 = self::multiFn(2);
static method binaryFn(core::int a, core::int b) → core::int
;
static method optionalFn(core::int c, [core::int d]) → core::int
@@ -33,5 +35,7 @@
;
static method doubleFn(core::double a, core::double b) → core::double
;
+static method multiFn(core::int a) → core::int
+ ;
static method main() → void
;
diff --git a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.transformed.expect
index 920ec7f..de39112 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_simple_invocations.dart.weak.transformed.expect
@@ -16,6 +16,8 @@
static const field core::int negative = #C9;
static const field core::bool boolean = #C8;
static const field core::double doubleResult = #C10;
+static const field core::int multi = #C2;
+static const field core::int multi2 = #C3;
static method binaryFn(core::int a, core::int b) → core::int
return a.{core::num::-}(b);
static method optionalFn(core::int c, [core::int d = #C11]) → core::int
@@ -34,6 +36,8 @@
return a || b;
static method doubleFn(core::double a, core::double b) → core::double
return a.{core::double::*}(b);
+static method multiFn(core::int a) → core::int
+ return a.{core::num::+}(1);
static method main() → void {
exp::Expect::equals(#C1, 1);
exp::Expect::equals(#C2, 2);
@@ -46,6 +50,8 @@
exp::Expect::equals(#C9, 2.{core::int::unary-}());
exp::Expect::equals(#C8, true);
exp::Expect::equals(#C10, 4.4);
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C3, 3);
}
constants {
@@ -63,5 +69,5 @@
}
Extra constant evaluation status:
-Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_simple_invocations.dart:47:27 -> IntConstant(-2)
-Extra constant evaluation: evaluated: 35, effectively constant: 1
+Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_simple_invocations.dart:51:27 -> IntConstant(-2)
+Extra constant evaluation: evaluated: 39, effectively constant: 1
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart
index 345e14c..537caea 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart
@@ -27,6 +27,7 @@
}
const var3 = varAssignmentTest3(1);
+const var4 = varAssignmentTest3(2);
int varAssignmentTest3(int a) {
int x = 4;
x = a + 1;
@@ -37,4 +38,5 @@
Expect.equals(var1, 3);
Expect.equals(function(), 3);
Expect.equals(var3, 2);
+ Expect.equals(var4, 3);
}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.strong.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.strong.expect
index 337c656..7107ba3 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.strong.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.strong.expect
@@ -7,6 +7,7 @@
static const field core::int var1 = #C1;
static const field core::int var3 = #C2;
+static const field core::int var4 = #C1;
static method varAssignmentTest(core::int a) → core::int {
core::int x = 4;
{
@@ -31,6 +32,7 @@
exp::Expect::equals(#C1, 3);
exp::Expect::equals(self::function(), 3);
exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C1, 3);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.strong.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.strong.transformed.expect
index 337c656..7107ba3 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.strong.transformed.expect
@@ -7,6 +7,7 @@
static const field core::int var1 = #C1;
static const field core::int var3 = #C2;
+static const field core::int var4 = #C1;
static method varAssignmentTest(core::int a) → core::int {
core::int x = 4;
{
@@ -31,6 +32,7 @@
exp::Expect::equals(#C1, 3);
exp::Expect::equals(self::function(), 3);
exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C1, 3);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.textual_outline.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.textual_outline.expect
index 801ab46..0db1b6d 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.textual_outline.expect
@@ -4,5 +4,6 @@
int varAssignmentTest(int a) {}
int function() {}
const var3 = varAssignmentTest3(1);
+const var4 = varAssignmentTest3(2);
int varAssignmentTest3(int a) {}
void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.textual_outline_modelled.expect
index 5f57ea4..87b42cc 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.textual_outline_modelled.expect
@@ -2,6 +2,7 @@
const var1 = varAssignmentTest(1);
const var3 = varAssignmentTest3(1);
+const var4 = varAssignmentTest3(2);
int function() {}
int varAssignmentTest(int a) {}
int varAssignmentTest3(int a) {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.expect
index 337c656..7107ba3 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.expect
@@ -7,6 +7,7 @@
static const field core::int var1 = #C1;
static const field core::int var3 = #C2;
+static const field core::int var4 = #C1;
static method varAssignmentTest(core::int a) → core::int {
core::int x = 4;
{
@@ -31,6 +32,7 @@
exp::Expect::equals(#C1, 3);
exp::Expect::equals(self::function(), 3);
exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C1, 3);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.outline.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.outline.expect
index 71847ee..911659e 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.outline.expect
@@ -6,6 +6,7 @@
static const field core::int var1 = self::varAssignmentTest(1);
static const field core::int var3 = self::varAssignmentTest3(1);
+static const field core::int var4 = self::varAssignmentTest3(2);
static method varAssignmentTest(core::int a) → core::int
;
static method function() → core::int
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.transformed.expect
index 337c656..7107ba3 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_assignments.dart.weak.transformed.expect
@@ -7,6 +7,7 @@
static const field core::int var1 = #C1;
static const field core::int var3 = #C2;
+static const field core::int var4 = #C1;
static method varAssignmentTest(core::int a) → core::int {
core::int x = 4;
{
@@ -31,6 +32,7 @@
exp::Expect::equals(#C1, 3);
exp::Expect::equals(self::function(), 3);
exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C1, 3);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart
index 4cbaa94..7c1c573 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart
@@ -7,6 +7,7 @@
import "package:expect/expect.dart";
const var1 = function1(1, 2);
+const var1_1 = function1(2, 2);
int function1(int a, int b) {
var x = 1 + a + b;
return x;
@@ -40,6 +41,7 @@
void main() {
Expect.equals(var1, 4);
+ Expect.equals(var1_1, 5);
Expect.equals(var2, "string");
Expect.equals(var3, 6);
Expect.equals(var4, 2);
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.strong.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.strong.expect
index 0be3638..425972a 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.strong.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.strong.expect
@@ -6,10 +6,11 @@
import "package:expect/expect.dart";
static const field core::int var1 = #C1;
-static const field core::String var2 = #C2;
-static const field core::int var3 = #C3;
-static const field core::int var4 = #C4;
-static const field core::int var5 = #C5;
+static const field core::int var1_1 = #C2;
+static const field core::String var2 = #C3;
+static const field core::int var3 = #C4;
+static const field core::int var4 = #C5;
+static const field core::int var5 = #C6;
static method function1(core::int a, core::int b) → core::int {
core::int x = 1.{core::num::+}(a).{core::num::+}(b);
return x;
@@ -29,20 +30,22 @@
return first.{core::num::+}(second);
}
static method function5() → core::int {
- return #C5;
+ return #C6;
}
static method main() → void {
exp::Expect::equals(#C1, 4);
- exp::Expect::equals(#C2, "string");
- exp::Expect::equals(#C3, 6);
- exp::Expect::equals(#C4, 2);
- exp::Expect::equals(#C5, 2.{core::int::unary-}());
+ exp::Expect::equals(#C2, 5);
+ exp::Expect::equals(#C3, "string");
+ exp::Expect::equals(#C4, 6);
+ exp::Expect::equals(#C5, 2);
+ exp::Expect::equals(#C6, 2.{core::int::unary-}());
}
constants {
#C1 = 4
- #C2 = "string"
- #C3 = 6
- #C4 = 2
- #C5 = -2
+ #C2 = 5
+ #C3 = "string"
+ #C4 = 6
+ #C5 = 2
+ #C6 = -2
}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.strong.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.strong.transformed.expect
index de3ed54..9ea2e2a 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.strong.transformed.expect
@@ -6,10 +6,11 @@
import "package:expect/expect.dart";
static const field core::int var1 = #C1;
-static const field core::String var2 = #C2;
-static const field core::int var3 = #C3;
-static const field core::int var4 = #C4;
-static const field core::int var5 = #C5;
+static const field core::int var1_1 = #C2;
+static const field core::String var2 = #C3;
+static const field core::int var3 = #C4;
+static const field core::int var4 = #C5;
+static const field core::int var5 = #C6;
static method function1(core::int a, core::int b) → core::int {
core::int x = 1.{core::num::+}(a).{core::num::+}(b);
return x;
@@ -29,24 +30,26 @@
return first.{core::num::+}(second);
}
static method function5() → core::int {
- return #C5;
+ return #C6;
}
static method main() → void {
exp::Expect::equals(#C1, 4);
- exp::Expect::equals(#C2, "string");
- exp::Expect::equals(#C3, 6);
- exp::Expect::equals(#C4, 2);
- exp::Expect::equals(#C5, 2.{core::int::unary-}());
+ exp::Expect::equals(#C2, 5);
+ exp::Expect::equals(#C3, "string");
+ exp::Expect::equals(#C4, 6);
+ exp::Expect::equals(#C5, 2);
+ exp::Expect::equals(#C6, 2.{core::int::unary-}());
}
constants {
#C1 = 4
- #C2 = "string"
- #C3 = 6
- #C4 = 2
- #C5 = -2
+ #C2 = 5
+ #C3 = "string"
+ #C4 = 6
+ #C5 = 2
+ #C6 = -2
}
Extra constant evaluation status:
-Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_variable_declarations.dart:46:23 -> IntConstant(-2)
-Extra constant evaluation: evaluated: 20, effectively constant: 1
+Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_variable_declarations.dart:48:23 -> IntConstant(-2)
+Extra constant evaluation: evaluated: 21, effectively constant: 1
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.textual_outline.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.textual_outline.expect
index 723b134..1b140e3 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.textual_outline.expect
@@ -1,6 +1,7 @@
import "package:expect/expect.dart";
const var1 = function1(1, 2);
+const var1_1 = function1(2, 2);
int function1(int a, int b) {}
const var2 = function2();
String function2() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.textual_outline_modelled.expect
index d1c0ddb..7dcb573 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.textual_outline_modelled.expect
@@ -2,6 +2,7 @@
String function2() {}
const var1 = function1(1, 2);
+const var1_1 = function1(2, 2);
const var2 = function2();
const var3 = function3();
const var4 = function4();
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.expect
index 0be3638..425972a 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.expect
@@ -6,10 +6,11 @@
import "package:expect/expect.dart";
static const field core::int var1 = #C1;
-static const field core::String var2 = #C2;
-static const field core::int var3 = #C3;
-static const field core::int var4 = #C4;
-static const field core::int var5 = #C5;
+static const field core::int var1_1 = #C2;
+static const field core::String var2 = #C3;
+static const field core::int var3 = #C4;
+static const field core::int var4 = #C5;
+static const field core::int var5 = #C6;
static method function1(core::int a, core::int b) → core::int {
core::int x = 1.{core::num::+}(a).{core::num::+}(b);
return x;
@@ -29,20 +30,22 @@
return first.{core::num::+}(second);
}
static method function5() → core::int {
- return #C5;
+ return #C6;
}
static method main() → void {
exp::Expect::equals(#C1, 4);
- exp::Expect::equals(#C2, "string");
- exp::Expect::equals(#C3, 6);
- exp::Expect::equals(#C4, 2);
- exp::Expect::equals(#C5, 2.{core::int::unary-}());
+ exp::Expect::equals(#C2, 5);
+ exp::Expect::equals(#C3, "string");
+ exp::Expect::equals(#C4, 6);
+ exp::Expect::equals(#C5, 2);
+ exp::Expect::equals(#C6, 2.{core::int::unary-}());
}
constants {
#C1 = 4
- #C2 = "string"
- #C3 = 6
- #C4 = 2
- #C5 = -2
+ #C2 = 5
+ #C3 = "string"
+ #C4 = 6
+ #C5 = 2
+ #C6 = -2
}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.outline.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.outline.expect
index 5941219..f119780 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.outline.expect
@@ -5,6 +5,7 @@
import "package:expect/expect.dart";
static const field core::int var1 = self::function1(1, 2);
+static const field core::int var1_1 = self::function1(2, 2);
static const field core::String var2 = self::function2();
static const field core::int var3 = self::function3();
static const field core::int var4 = self::function4();
diff --git a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.transformed.expect
index de3ed54..9ea2e2a 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_variable_declarations.dart.weak.transformed.expect
@@ -6,10 +6,11 @@
import "package:expect/expect.dart";
static const field core::int var1 = #C1;
-static const field core::String var2 = #C2;
-static const field core::int var3 = #C3;
-static const field core::int var4 = #C4;
-static const field core::int var5 = #C5;
+static const field core::int var1_1 = #C2;
+static const field core::String var2 = #C3;
+static const field core::int var3 = #C4;
+static const field core::int var4 = #C5;
+static const field core::int var5 = #C6;
static method function1(core::int a, core::int b) → core::int {
core::int x = 1.{core::num::+}(a).{core::num::+}(b);
return x;
@@ -29,24 +30,26 @@
return first.{core::num::+}(second);
}
static method function5() → core::int {
- return #C5;
+ return #C6;
}
static method main() → void {
exp::Expect::equals(#C1, 4);
- exp::Expect::equals(#C2, "string");
- exp::Expect::equals(#C3, 6);
- exp::Expect::equals(#C4, 2);
- exp::Expect::equals(#C5, 2.{core::int::unary-}());
+ exp::Expect::equals(#C2, 5);
+ exp::Expect::equals(#C3, "string");
+ exp::Expect::equals(#C4, 6);
+ exp::Expect::equals(#C5, 2);
+ exp::Expect::equals(#C6, 2.{core::int::unary-}());
}
constants {
#C1 = 4
- #C2 = "string"
- #C3 = 6
- #C4 = 2
- #C5 = -2
+ #C2 = 5
+ #C3 = "string"
+ #C4 = 6
+ #C5 = 2
+ #C6 = -2
}
Extra constant evaluation status:
-Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_variable_declarations.dart:46:23 -> IntConstant(-2)
-Extra constant evaluation: evaluated: 20, effectively constant: 1
+Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_variable_declarations.dart:48:23 -> IntConstant(-2)
+Extra constant evaluation: evaluated: 21, effectively constant: 1
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index 9f62f59..11c57fc 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -1214,18 +1214,8 @@
return "native function";
}
- // Resolver::ResolveDynamic uses.
- const auto& selector = String::Handle(Z, function.name());
- if (selector.ptr() == Symbols::toString().ptr() ||
- selector.ptr() == Symbols::AssignIndexToken().ptr() ||
- selector.ptr() == Symbols::IndexToken().ptr() ||
- selector.ptr() == Symbols::hashCode().ptr() ||
- selector.ptr() == Symbols::NoSuchMethod().ptr() ||
- selector.ptr() == Symbols::EqualOperator().ptr()) {
- return "used by VM in Resolver::ResolveDynamic call";
- }
-
// Use the same check for _Closure.call as in stack_trace.{h|cc}.
+ const auto& selector = String::Handle(Z, function.name());
if (selector.ptr() == Symbols::Call().ptr()) {
const auto& name = String::Handle(Z, function.QualifiedScrubbedName());
if (name.Equals(Symbols::_ClosureCall())) {
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index 6b18881..ce2a0a9 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -6912,19 +6912,27 @@
compiler::Label is_true, is_false;
BranchLabels labels = {&is_true, &is_false, &is_false};
Condition true_condition = EmitComparisonCode(compiler, labels);
- const Register result = this->locs()->out(0).reg();
- // TODO(dartbug.com/29908): Use csel here for better branch prediction?
- if (true_condition != kInvalidCondition) {
- EmitBranchOnCondition(compiler, true_condition, labels);
+ const Register result = this->locs()->out(0).reg();
+ if (is_true.IsLinked() || is_false.IsLinked()) {
+ if (true_condition != kInvalidCondition) {
+ EmitBranchOnCondition(compiler, true_condition, labels);
+ }
+ compiler::Label done;
+ __ Bind(&is_false);
+ __ LoadObject(result, Bool::False());
+ __ b(&done);
+ __ Bind(&is_true);
+ __ LoadObject(result, Bool::True());
+ __ Bind(&done);
+ } else {
+ // If EmitComparisonCode did not use the labels and just returned
+ // a condition we can avoid the branch and use conditional loads.
+ ASSERT(true_condition != kInvalidCondition);
+ __ LoadObject(TMP, Bool::True());
+ __ LoadObject(TMP2, Bool::False());
+ __ csel(result, TMP, TMP2, true_condition);
}
- compiler::Label done;
- __ Bind(&is_false);
- __ LoadObject(result, Bool::False());
- __ b(&done);
- __ Bind(&is_true);
- __ LoadObject(result, Bool::True());
- __ Bind(&done);
}
void ComparisonInstr::EmitBranchCode(FlowGraphCompiler* compiler,
diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc
index 5d55d70..379ba84 100644
--- a/runtime/vm/compiler/backend/il_x64.cc
+++ b/runtime/vm/compiler/backend/il_x64.cc
@@ -931,17 +931,31 @@
compiler::Label is_true, is_false;
BranchLabels labels = {&is_true, &is_false, &is_false};
Condition true_condition = EmitComparisonCode(compiler, labels);
- if (true_condition != kInvalidCondition) {
- EmitBranchOnCondition(compiler, true_condition, labels);
- }
+
Register result = locs()->out(0).reg();
- compiler::Label done;
- __ Bind(&is_false);
- __ LoadObject(result, Bool::False());
- __ jmp(&done);
- __ Bind(&is_true);
- __ LoadObject(result, Bool::True());
- __ Bind(&done);
+ if (is_true.IsLinked() || is_false.IsLinked()) {
+ if (true_condition != kInvalidCondition) {
+ EmitBranchOnCondition(compiler, true_condition, labels);
+ }
+ compiler::Label done;
+ __ Bind(&is_false);
+ __ LoadObject(result, Bool::False());
+ __ jmp(&done, compiler::Assembler::kNearJump);
+ __ Bind(&is_true);
+ __ LoadObject(result, Bool::True());
+ __ Bind(&done);
+ } else {
+ // If EmitComparisonCode did not use the labels and just returned
+ // a condition we can avoid the branch and use conditional loads.
+ ASSERT(true_condition != kInvalidCondition);
+ __ setcc(InvertCondition(true_condition), ByteRegisterOf(result));
+ __ movzxb(result, result);
+ __ movq(result,
+ compiler::Address(THR, result, TIMES_8,
+ compiler::target::Thread::bool_true_offset()));
+ ASSERT(compiler::target::Thread::bool_true_offset() + 8 ==
+ compiler::target::Thread::bool_false_offset());
+ }
}
void ComparisonInstr::EmitBranchCode(FlowGraphCompiler* compiler,
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 8fcc8b9..712bdb0 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -275,36 +275,51 @@
current_func, field_count, num_fields);
}
-static ObjectPtr Send0Arg(const Instance& receiver, const String& selector) {
- const intptr_t kTypeArgsLen = 0;
- const intptr_t kNumArgs = 1;
- ArgumentsDescriptor args_desc(
- Array::Handle(ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArgs)));
+static FunctionPtr FindCoreLibPrivateFunction(Zone* zone, const String& name) {
+ const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
+ ASSERT(!core_lib.IsNull());
const Function& function =
- Function::Handle(Resolver::ResolveDynamic(receiver, selector, args_desc));
- if (function.IsNull()) {
- return ApiError::New(String::Handle(String::New("")));
- }
- const Array& args = Array::Handle(Array::New(kNumArgs));
- args.SetAt(0, receiver);
+ Function::Handle(zone, core_lib.LookupFunctionAllowPrivate(name));
+ ASSERT(!function.IsNull());
+ return function.ptr();
+}
+
+static ObjectPtr CallStatic1Arg(Zone* zone,
+ const String& name,
+ const Instance& arg0) {
+ const intptr_t kNumArgs = 1;
+ const Function& function =
+ Function::Handle(zone, FindCoreLibPrivateFunction(zone, name));
+ const Array& args = Array::Handle(zone, Array::New(kNumArgs));
+ args.SetAt(0, arg0);
return DartEntry::InvokeFunction(function, args);
}
-static ObjectPtr Send1Arg(const Instance& receiver,
- const String& selector,
- const Instance& argument) {
- const intptr_t kTypeArgsLen = 0;
+static ObjectPtr CallStatic2Args(Zone* zone,
+ const String& name,
+ const Instance& arg0,
+ const Instance& arg1) {
const intptr_t kNumArgs = 2;
- ArgumentsDescriptor args_desc(
- Array::Handle(ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArgs)));
const Function& function =
- Function::Handle(Resolver::ResolveDynamic(receiver, selector, args_desc));
- if (function.IsNull()) {
- return ApiError::New(String::Handle(String::New("")));
- }
+ Function::Handle(zone, FindCoreLibPrivateFunction(zone, name));
+ const Array& args = Array::Handle(zone, Array::New(kNumArgs));
+ args.SetAt(0, arg0);
+ args.SetAt(1, arg1);
+ return DartEntry::InvokeFunction(function, args);
+}
+
+static ObjectPtr CallStatic3Args(Zone* zone,
+ const String& name,
+ const Instance& arg0,
+ const Instance& arg1,
+ const Instance& arg2) {
+ const intptr_t kNumArgs = 3;
+ const Function& function =
+ Function::Handle(zone, FindCoreLibPrivateFunction(zone, name));
const Array& args = Array::Handle(Array::New(kNumArgs));
- args.SetAt(0, receiver);
- args.SetAt(1, argument);
+ args.SetAt(0, arg0);
+ args.SetAt(1, arg1);
+ args.SetAt(2, arg2);
return DartEntry::InvokeFunction(function, args);
}
@@ -3187,21 +3202,8 @@
return Api::NewArgumentError(
"Object does not implement the List interface");
}
- const String& name = String::Handle(Z, Field::GetterName(Symbols::Length()));
- const int kTypeArgsLen = 0;
- const int kNumArgs = 1;
- ArgumentsDescriptor args_desc(
- Array::Handle(Z, ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArgs)));
- const Function& function =
- Function::Handle(Z, Resolver::ResolveDynamic(instance, name, args_desc));
- if (function.IsNull()) {
- return Api::NewArgumentError("List object does not have a 'length' field.");
- }
-
- const Array& args = Array::Handle(Z, Array::New(kNumArgs));
- args.SetAt(0, instance); // Set up the receiver as the first argument.
const Object& retval =
- Object::Handle(Z, DartEntry::InvokeFunction(function, args));
+ Object::Handle(Z, CallStatic1Arg(Z, Symbols::_listLength(), instance));
if (retval.IsSmi()) {
*len = Smi::Cast(retval).Value();
return Api::Success();
@@ -3242,9 +3244,9 @@
// Check and handle a dart object that implements the List interface.
const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
if (!instance.IsNull()) {
- return Api::NewHandle(T,
- Send1Arg(instance, Symbols::IndexToken(),
- Instance::Handle(Z, Integer::New(index))));
+ return Api::NewHandle(
+ T, CallStatic2Args(Z, Symbols::_listGetAt(), instance,
+ Instance::Handle(Z, Integer::New(index))));
}
return Api::NewArgumentError(
"Object does not implement the 'List' interface");
@@ -3281,27 +3283,21 @@
// Check and handle a dart object that implements the List interface.
const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
if (!instance.IsNull()) {
- const intptr_t kTypeArgsLen = 0;
const intptr_t kNumArgs = 2;
- ArgumentsDescriptor args_desc(
- Array::Handle(ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArgs)));
const Function& function = Function::Handle(
- Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(),
- args_desc));
- if (!function.IsNull()) {
- const Array& args = Array::Handle(Array::New(kNumArgs));
- args.SetAt(0, instance);
- Instance& index = Instance::Handle(Z);
- for (intptr_t i = 0; i < length; ++i) {
- index = Integer::New(i);
- args.SetAt(1, index);
- Dart_Handle value =
- Api::NewHandle(T, DartEntry::InvokeFunction(function, args));
- if (Api::IsError(value)) return value;
- result[i] = value;
- }
- return Api::Success();
+ Z, FindCoreLibPrivateFunction(Z, Symbols::_listGetAt()));
+ const Array& args = Array::Handle(Z, Array::New(kNumArgs));
+ args.SetAt(0, instance);
+ Instance& index = Instance::Handle(Z);
+ for (intptr_t i = 0; i < length; ++i) {
+ index = Integer::New(i);
+ args.SetAt(1, index);
+ Dart_Handle value =
+ Api::NewHandle(T, DartEntry::InvokeFunction(function, args));
+ if (Api::IsError(value)) return value;
+ result[i] = value;
}
+ return Api::Success();
}
return Api::NewArgumentError(
"Object does not implement the 'List' interface");
@@ -3339,25 +3335,14 @@
// Check and handle a dart object that implements the List interface.
const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
if (!instance.IsNull()) {
- const intptr_t kTypeArgsLen = 0;
- const intptr_t kNumArgs = 3;
- ArgumentsDescriptor args_desc(
- Array::Handle(ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArgs)));
- const Function& function = Function::Handle(
- Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(),
- args_desc));
- if (!function.IsNull()) {
- const Integer& index_obj = Integer::Handle(Z, Integer::New(index));
- const Object& value_obj = Object::Handle(Z, Api::UnwrapHandle(value));
- if (!value_obj.IsNull() && !value_obj.IsInstance()) {
- RETURN_TYPE_ERROR(Z, value, Instance);
- }
- const Array& args = Array::Handle(Z, Array::New(kNumArgs));
- args.SetAt(0, instance);
- args.SetAt(1, index_obj);
- args.SetAt(2, value_obj);
- return Api::NewHandle(T, DartEntry::InvokeFunction(function, args));
+ const Integer& index_obj = Integer::Handle(Z, Integer::New(index));
+ const Object& value_obj = Object::Handle(Z, Api::UnwrapHandle(value));
+ if (!value_obj.IsNull() && !value_obj.IsInstance()) {
+ RETURN_TYPE_ERROR(Z, value, Instance);
}
+ return Api::NewHandle(
+ T, CallStatic3Args(Z, Symbols::_listSetAt(), instance, index_obj,
+ Instance::Cast(value_obj)));
}
return Api::NewArgumentError(
"Object does not implement the 'List' interface");
@@ -3524,41 +3509,35 @@
// Check and handle a dart object that implements the List interface.
const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
if (!instance.IsNull()) {
- const int kTypeArgsLen = 0;
const int kNumArgs = 2;
- ArgumentsDescriptor args_desc(
- Array::Handle(ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArgs)));
const Function& function = Function::Handle(
- Z,
- Resolver::ResolveDynamic(instance, Symbols::IndexToken(), args_desc));
- if (!function.IsNull()) {
- Object& result = Object::Handle(Z);
- Integer& intobj = Integer::Handle(Z);
- const Array& args = Array::Handle(Z, Array::New(kNumArgs));
- args.SetAt(0, instance); // Set up the receiver as the first argument.
- for (int i = 0; i < length; i++) {
- HANDLESCOPE(T);
- intobj = Integer::New(offset + i);
- args.SetAt(1, intobj);
- result = DartEntry::InvokeFunction(function, args);
- if (result.IsError()) {
- return Api::NewHandle(T, result.ptr());
- }
- if (!result.IsInteger()) {
- return Api::NewError(
- "%s expects the argument 'list' to be "
- "a List of int",
- CURRENT_FUNC);
- }
- const Integer& integer_result = Integer::Cast(result);
- ASSERT(integer_result.AsInt64Value() <= 0xff);
- // TODO(hpayer): value should always be smaller then 0xff. Add error
- // handling.
- native_array[i] =
- static_cast<uint8_t>(integer_result.AsInt64Value() & 0xff);
+ Z, FindCoreLibPrivateFunction(Z, Symbols::_listGetAt()));
+ Object& result = Object::Handle(Z);
+ Integer& intobj = Integer::Handle(Z);
+ const Array& args = Array::Handle(Z, Array::New(kNumArgs));
+ args.SetAt(0, instance); // Set up the receiver as the first argument.
+ for (int i = 0; i < length; i++) {
+ HANDLESCOPE(T);
+ intobj = Integer::New(offset + i);
+ args.SetAt(1, intobj);
+ result = DartEntry::InvokeFunction(function, args);
+ if (result.IsError()) {
+ return Api::NewHandle(T, result.ptr());
}
- return Api::Success();
+ if (!result.IsInteger()) {
+ return Api::NewError(
+ "%s expects the argument 'list' to be "
+ "a List of int",
+ CURRENT_FUNC);
+ }
+ const Integer& integer_result = Integer::Cast(result);
+ ASSERT(integer_result.AsInt64Value() <= 0xff);
+ // TODO(hpayer): value should always be smaller then 0xff. Add error
+ // handling.
+ native_array[i] =
+ static_cast<uint8_t>(integer_result.AsInt64Value() & 0xff);
}
+ return Api::Success();
}
return Api::NewArgumentError(
"Object does not implement the 'List' interface");
@@ -3611,31 +3590,25 @@
// Check and handle a dart object that implements the List interface.
const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
if (!instance.IsNull()) {
- const int kTypeArgsLen = 0;
const int kNumArgs = 3;
- ArgumentsDescriptor args_desc(Array::Handle(
- Z, ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArgs)));
const Function& function = Function::Handle(
- Z, Resolver::ResolveDynamic(instance, Symbols::AssignIndexToken(),
- args_desc));
- if (!function.IsNull()) {
- Integer& indexobj = Integer::Handle(Z);
- Integer& valueobj = Integer::Handle(Z);
- const Array& args = Array::Handle(Z, Array::New(kNumArgs));
- args.SetAt(0, instance); // Set up the receiver as the first argument.
- for (int i = 0; i < length; i++) {
- indexobj = Integer::New(offset + i);
- valueobj = Integer::New(native_array[i]);
- args.SetAt(1, indexobj);
- args.SetAt(2, valueobj);
- const Object& result =
- Object::Handle(Z, DartEntry::InvokeFunction(function, args));
- if (result.IsError()) {
- return Api::NewHandle(T, result.ptr());
- }
+ Z, FindCoreLibPrivateFunction(Z, Symbols::_listSetAt()));
+ Integer& indexobj = Integer::Handle(Z);
+ Integer& valueobj = Integer::Handle(Z);
+ const Array& args = Array::Handle(Z, Array::New(kNumArgs));
+ args.SetAt(0, instance); // Set up the receiver as the first argument.
+ for (int i = 0; i < length; i++) {
+ indexobj = Integer::New(offset + i);
+ valueobj = Integer::New(native_array[i]);
+ args.SetAt(1, indexobj);
+ args.SetAt(2, valueobj);
+ const Object& result =
+ Object::Handle(Z, DartEntry::InvokeFunction(function, args));
+ if (result.IsError()) {
+ return Api::NewHandle(T, result.ptr());
}
- return Api::Success();
}
+ return Api::Success();
}
return Api::NewArgumentError(
"Object does not implement the 'List' interface");
@@ -3653,8 +3626,8 @@
if (!(key_obj.IsInstance() || key_obj.IsNull())) {
return Api::NewError("Key is not an instance");
}
- return Api::NewHandle(
- T, Send1Arg(instance, Symbols::IndexToken(), Instance::Cast(key_obj)));
+ return Api::NewHandle(T, CallStatic2Args(Z, Symbols::_mapGet(), instance,
+ Instance::Cast(key_obj)));
}
return Api::NewArgumentError("Object does not implement the 'Map' interface");
}
@@ -3670,8 +3643,8 @@
return Api::NewError("Key is not an instance");
}
return Api::NewHandle(
- T, Send1Arg(instance, String::Handle(Z, String::New("containsKey")),
- Instance::Cast(key_obj)));
+ T, CallStatic2Args(Z, Symbols::_mapContainsKey(), instance,
+ Instance::Cast(key_obj)));
}
return Api::NewArgumentError("Object does not implement the 'Map' interface");
}
@@ -3682,13 +3655,7 @@
Object& obj = Object::Handle(Z, Api::UnwrapHandle(map));
Instance& instance = Instance::Handle(Z, GetMapInstance(Z, obj));
if (!instance.IsNull()) {
- const Object& iterator = Object::Handle(
- Send0Arg(instance, String::Handle(Z, String::New("get:keys"))));
- if (!iterator.IsInstance()) {
- return Api::NewHandle(T, iterator.ptr());
- }
- return Api::NewHandle(T, Send0Arg(Instance::Cast(iterator),
- String::Handle(String::New("toList"))));
+ return Api::NewHandle(T, CallStatic1Arg(Z, Symbols::_mapKeys(), instance));
}
return Api::NewArgumentError("Object does not implement the 'Map' interface");
}
diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc
index 691bd6c..ec04ca2 100644
--- a/runtime/vm/dart_entry.cc
+++ b/runtime/vm/dart_entry.cc
@@ -344,21 +344,10 @@
}
// Now use the invocation mirror object and invoke NoSuchMethod.
- const int kTypeArgsLen = 0;
const int kNumArguments = 2;
- const ArgumentsDescriptor nsm_args_desc(Array::Handle(
- zone, ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArguments)));
- Function& function = Function::Handle(
- zone, Resolver::ResolveDynamic(receiver, Symbols::NoSuchMethod(),
- nsm_args_desc));
- if (function.IsNull()) {
- ASSERT(!FLAG_lazy_dispatchers);
- // If noSuchMethod(invocation) is not found, call Object::noSuchMethod.
- function = Resolver::ResolveDynamicForReceiverClass(
- Class::Handle(zone,
- thread->isolate_group()->object_store()->object_class()),
- Symbols::NoSuchMethod(), nsm_args_desc);
- }
+ const Function& function = Function::Handle(
+ zone,
+ core_lib.LookupFunctionAllowPrivate(Symbols::_objectNoSuchMethod()));
ASSERT(!function.IsNull());
const Array& args = Array::Handle(zone, Array::New(kNumArguments));
args.SetAt(0, receiver);
@@ -621,55 +610,71 @@
}
ObjectPtr DartLibraryCalls::ToString(const Instance& receiver) {
- const int kTypeArgsLen = 0;
- const int kNumArguments = 1; // Receiver.
- ArgumentsDescriptor args_desc(Array::Handle(
- ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArguments)));
- const Class& receiver_class = Class::Handle(receiver.clazz());
- const auto& error = receiver_class.EnsureIsFinalized(Thread::Current());
- ASSERT(error == Error::null());
- const Function& function = Function::Handle(
- Resolver::ResolveDynamic(receiver, Symbols::toString(), args_desc));
- ASSERT(!function.IsNull());
- const Array& args = Array::Handle(Array::New(kNumArguments));
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
+ Function& function = Function::Handle(
+ zone,
+ thread->isolate_group()->object_store()->_object_to_string_function());
+ if (function.IsNull()) {
+ const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
+ ASSERT(!core_lib.IsNull());
+ function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectToString());
+ ASSERT(!function.IsNull());
+ thread->isolate_group()->object_store()->set__object_to_string_function(
+ function);
+ }
+ const int kNumArguments = 1;
+ const Array& args = Array::Handle(zone, Array::New(kNumArguments));
args.SetAt(0, receiver);
const Object& result =
- Object::Handle(DartEntry::InvokeFunction(function, args));
+ Object::Handle(zone, DartEntry::InvokeFunction(function, args));
ASSERT(result.IsInstance() || result.IsError());
return result.ptr();
}
ObjectPtr DartLibraryCalls::HashCode(const Instance& receiver) {
- const int kTypeArgsLen = 0;
- const int kNumArguments = 1; // Receiver.
- ArgumentsDescriptor args_desc(Array::Handle(
- ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArguments)));
- const Function& function = Function::Handle(
- Resolver::ResolveDynamic(receiver, Symbols::hashCode(), args_desc));
- ASSERT(!function.IsNull());
- const Array& args = Array::Handle(Array::New(kNumArguments));
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
+ Function& function = Function::Handle(
+ zone,
+ thread->isolate_group()->object_store()->_object_hash_code_function());
+ if (function.IsNull()) {
+ const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
+ ASSERT(!core_lib.IsNull());
+ function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectHashCode());
+ ASSERT(!function.IsNull());
+ thread->isolate_group()->object_store()->set__object_hash_code_function(
+ function);
+ }
+ const int kNumArguments = 1;
+ const Array& args = Array::Handle(zone, Array::New(kNumArguments));
args.SetAt(0, receiver);
const Object& result =
- Object::Handle(DartEntry::InvokeFunction(function, args));
+ Object::Handle(zone, DartEntry::InvokeFunction(function, args));
ASSERT(result.IsInstance() || result.IsError());
return result.ptr();
}
ObjectPtr DartLibraryCalls::Equals(const Instance& left,
const Instance& right) {
- const int kTypeArgsLen = 0;
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
+ Function& function = Function::Handle(
+ zone, thread->isolate_group()->object_store()->_object_equals_function());
+ if (function.IsNull()) {
+ const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
+ ASSERT(!core_lib.IsNull());
+ function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectEquals());
+ ASSERT(!function.IsNull());
+ thread->isolate_group()->object_store()->set__object_equals_function(
+ function);
+ }
const int kNumArguments = 2;
- ArgumentsDescriptor args_desc(Array::Handle(
- ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArguments)));
- const Function& function = Function::Handle(
- Resolver::ResolveDynamic(left, Symbols::EqualOperator(), args_desc));
- ASSERT(!function.IsNull());
-
- const Array& args = Array::Handle(Array::New(kNumArguments));
+ const Array& args = Array::Handle(zone, Array::New(kNumArguments));
args.SetAt(0, left);
args.SetAt(1, right);
const Object& result =
- Object::Handle(DartEntry::InvokeFunction(function, args));
+ Object::Handle(zone, DartEntry::InvokeFunction(function, args));
ASSERT(result.IsInstance() || result.IsError());
return result.ptr();
}
@@ -821,23 +826,4 @@
return result.ptr();
}
-ObjectPtr DartLibraryCalls::MapSetAt(const Instance& map,
- const Instance& key,
- const Instance& value) {
- const int kTypeArgsLen = 0;
- const int kNumArguments = 3;
- ArgumentsDescriptor args_desc(Array::Handle(
- ArgumentsDescriptor::NewBoxed(kTypeArgsLen, kNumArguments)));
- const Function& function = Function::Handle(
- Resolver::ResolveDynamic(map, Symbols::AssignIndexToken(), args_desc));
- ASSERT(!function.IsNull());
- const Array& args = Array::Handle(Array::New(kNumArguments));
- args.SetAt(0, map);
- args.SetAt(1, key);
- args.SetAt(2, value);
- const Object& result =
- Object::Handle(DartEntry::InvokeFunction(function, args));
- return result.ptr();
-}
-
} // namespace dart
diff --git a/runtime/vm/dart_entry.h b/runtime/vm/dart_entry.h
index cfd0c06..4b5fd32 100644
--- a/runtime/vm/dart_entry.h
+++ b/runtime/vm/dart_entry.h
@@ -296,13 +296,6 @@
// _startMicrotaskLoop from dart:async.
// Returns null on success, an ErrorPtr on failure.
static ObjectPtr EnsureScheduleImmediate();
-
- // map[key] = value;
- //
- // Returns null on success, an ErrorPtr on failure.
- static ObjectPtr MapSetAt(const Instance& map,
- const Instance& key,
- const Instance& value);
};
} // namespace dart
diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h
index 55f8b6d..a452fd3 100644
--- a/runtime/vm/object_store.h
+++ b/runtime/vm/object_store.h
@@ -158,6 +158,9 @@
RW(GrowableObjectArray, pending_classes) \
RW(Instance, stack_overflow) \
RW(Instance, out_of_memory) \
+ RW(Function, _object_equals_function) \
+ RW(Function, _object_hash_code_function) \
+ RW(Function, _object_to_string_function) \
RW(Function, lookup_port_handler) \
RW(Function, lookup_open_ports) \
RW(Function, handle_message_function) \
diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h
index e647701..ff0ad5e 100644
--- a/runtime/vm/symbols.h
+++ b/runtime/vm/symbols.h
@@ -439,9 +439,19 @@
V(_get, "_get") \
V(_handleMessage, "_handleMessage") \
V(_instanceOf, "_instanceOf") \
+ V(_listGetAt, "_listGetAt") \
+ V(_listLength, "_listLength") \
+ V(_listSetAt, "_listSetAt") \
V(_lookupHandler, "_lookupHandler") \
V(_lookupOpenPorts, "_lookupOpenPorts") \
+ V(_mapContainsKey, "_mapContainsKey") \
+ V(_mapGet, "_mapGet") \
+ V(_mapKeys, "_mapKeys") \
V(_name, "_name") \
+ V(_objectEquals, "_objectEquals") \
+ V(_objectHashCode, "_objectHashCode") \
+ V(_objectNoSuchMethod, "_objectNoSuchMethod") \
+ V(_objectToString, "_objectToString") \
V(_onData, "_onData") \
V(_rehashObjects, "_rehashObjects") \
V(_resultOrListeners, "_resultOrListeners") \
diff --git a/sdk/lib/_internal/vm/lib/array_patch.dart b/sdk/lib/_internal/vm/lib/array_patch.dart
index f6edca3..92824e6 100644
--- a/sdk/lib/_internal/vm/lib/array_patch.dart
+++ b/sdk/lib/_internal/vm/lib/array_patch.dart
@@ -71,3 +71,17 @@
return makeFixedListUnmodifiable(result);
}
}
+
+// Used by Dart_ListLength.
+@pragma("vm:entry-point", "call")
+int _listLength(List list) => list.length;
+
+// Used by Dart_ListGetRange, Dart_ListGetAsBytes.
+@pragma("vm:entry-point", "call")
+Object? _listGetAt(List list, int index) => list[index];
+
+// Used by Dart_ListSetAt, Dart_ListSetAsBytes.
+@pragma("vm:entry-point", "call")
+void _listSetAt(List list, int index, Object? value) {
+ list[index] = value;
+}
diff --git a/sdk/lib/_internal/vm/lib/map_patch.dart b/sdk/lib/_internal/vm/lib/map_patch.dart
index 07dbc69..3e6b3db 100644
--- a/sdk/lib/_internal/vm/lib/map_patch.dart
+++ b/sdk/lib/_internal/vm/lib/map_patch.dart
@@ -29,3 +29,15 @@
@patch
factory Map() => new LinkedHashMap<K, V>();
}
+
+// Used by Dart_MapContainsKey.
+@pragma("vm:entry-point", "call")
+bool _mapContainsKey(Map map, Object? key) => map.containsKey(key);
+
+// Used by Dart_MapGetAt.
+@pragma("vm:entry-point", "call")
+Object? _mapGet(Map map, Object? key) => map[key];
+
+// Used by Dart_MapKeys.
+@pragma("vm:entry-point", "call")
+List _mapKeys(Map map) => map.keys.toList();
diff --git a/sdk/lib/_internal/vm/lib/object_patch.dart b/sdk/lib/_internal/vm/lib/object_patch.dart
index ac85705..0c20579 100644
--- a/sdk/lib/_internal/vm/lib/object_patch.dart
+++ b/sdk/lib/_internal/vm/lib/object_patch.dart
@@ -78,3 +78,20 @@
@pragma("vm:entry-point", "call")
bool _simpleInstanceOfFalse(type) => false;
}
+
+// Used by DartLibraryCalls::Equals.
+@pragma("vm:entry-point", "call")
+bool _objectEquals(Object? o1, Object? o2) => o1 == o2;
+
+// Used by DartLibraryCalls::HashCode.
+@pragma("vm:entry-point", "call")
+int _objectHashCode(Object? obj) => obj.hashCode;
+
+// Used by DartLibraryCalls::ToString.
+@pragma("vm:entry-point", "call")
+String _objectToString(Object? obj) => obj.toString();
+
+// Used by DartEntry::InvokeNoSuchMethod.
+@pragma("vm:entry-point", "call")
+dynamic _objectNoSuchMethod(Object? obj, Invocation invocation) =>
+ obj.noSuchMethod(invocation);
diff --git a/tests/language/const_functions/const_functions_local_functions_test.dart b/tests/language/const_functions/const_functions_local_functions_test.dart
index dc3eacb..1358e62 100644
--- a/tests/language/const_functions/const_functions_local_functions_test.dart
+++ b/tests/language/const_functions/const_functions_local_functions_test.dart
@@ -70,6 +70,17 @@
return value;
}
+int function8() {
+ int add(int a, int b) => a + b;
+ const value = add(1, 1);
+ // ^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ const value1 = add(2, 3);
+ // ^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ return value + value1;
+}
+
void main() {
Expect.equals(function1(), 12);
Expect.equals(function2(), 4);
@@ -78,4 +89,5 @@
Expect.equals(function5(), 3);
Expect.equals(function6(), 1);
Expect.equals(function7(), 2);
+ Expect.equals(function8(), 7);
}
diff --git a/tests/language/const_functions/const_functions_simple_invocations_test.dart b/tests/language/const_functions/const_functions_simple_invocations_test.dart
index 2280197..9c51ea6 100644
--- a/tests/language/const_functions/const_functions_simple_invocations_test.dart
+++ b/tests/language/const_functions/const_functions_simple_invocations_test.dart
@@ -59,6 +59,14 @@
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
double doubleFn(double a, double b) => a * b;
+const multi = multiFn(1);
+// ^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+const multi2 = multiFn(2);
+// ^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+int multiFn(int a) => a + 1;
+
void main() {
Expect.equals(binary, 1);
Expect.equals(optional, 2);
@@ -71,4 +79,6 @@
Expect.equals(neg, -2);
Expect.equals(boolean, true);
Expect.equals(doub, 4.4);
+ Expect.equals(multi, 2);
+ Expect.equals(multi2, 3);
}
diff --git a/tests/language/const_functions/const_functions_variable_assignments_test.dart b/tests/language/const_functions/const_functions_variable_assignments_test.dart
index f2c47cb..0348ee6 100644
--- a/tests/language/const_functions/const_functions_variable_assignments_test.dart
+++ b/tests/language/const_functions/const_functions_variable_assignments_test.dart
@@ -35,6 +35,9 @@
const var3 = varAssignmentTest3(1);
// ^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+const var4 = varAssignmentTest3(2);
+// ^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
int varAssignmentTest3(int a) {
int x = 4;
x = a + 1;
@@ -45,4 +48,5 @@
Expect.equals(var1, 3);
Expect.equals(function(), 3);
Expect.equals(var3, 2);
+ Expect.equals(var4, 3);
}
diff --git a/tests/language/const_functions/const_functions_variable_declarations_test.dart b/tests/language/const_functions/const_functions_variable_declarations_test.dart
index 1bd577f..492a8cc 100644
--- a/tests/language/const_functions/const_functions_variable_declarations_test.dart
+++ b/tests/language/const_functions/const_functions_variable_declarations_test.dart
@@ -11,6 +11,9 @@
const var1 = function1(1, 2);
// ^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+const var1_1 = function1(2, 2);
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
int function1(int a, int b) {
var x = 1 + a + b;
return x;
@@ -52,6 +55,7 @@
void main() {
Expect.equals(var1, 4);
+ Expect.equals(var1_1, 5);
Expect.equals(var2, "string");
Expect.equals(var3, 6);
Expect.equals(var4, 2);
diff --git a/tools/VERSION b/tools/VERSION
index 6aec146..faca9a1 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 13
PATCH 0
-PRERELEASE 139
+PRERELEASE 140
PRERELEASE_PATCH 0
\ No newline at end of file