Version 2.12.0-144.0.dev
Merge commit '7712011bba0b1174770494a0e62b0f65b40457a5' into 'dev'
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index b9bf27d..4038ead 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -2,14 +2,10 @@
// 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.
-import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../dart/analysis/base.dart';
import '../dart/resolution/context_collection_resolution.dart';
import 'element_text.dart';
@@ -17,7 +13,6 @@
defineReflectiveSuite(() {
defineReflectiveTests(TopLevelInferenceTest);
defineReflectiveTests(TopLevelInferenceErrorsTest);
- defineReflectiveTests(TopLevelInferenceTestWithSpread);
// defineReflectiveTests(ApplyCheckElementTextReplacements);
});
}
@@ -30,7 +25,8 @@
}
@reflectiveTest
-class TopLevelInferenceErrorsTest extends PubPackageResolutionTest {
+class TopLevelInferenceErrorsTest extends PubPackageResolutionTest
+ with WithNullSafetyMixin {
test_initializer_additive() async {
await _assertErrorOnlyLeft(['+', '-']);
}
@@ -185,7 +181,7 @@
test_initializer_ifNull() async {
await assertNoErrorsInCode('''
-var a = 1;
+int? a = 1;
var t = a ?? 2;
''');
}
@@ -216,8 +212,8 @@
test_initializer_methodInvocation_function() async {
await assertNoErrorsInCode('''
-int f1() => null;
-T f2<T>() => null;
+int f1() => 0;
+T f2<T>() => throw 0;
var t1 = f1();
var t2 = f2();
var t3 = f2<int>();
@@ -227,8 +223,8 @@
test_initializer_methodInvocation_method() async {
await assertNoErrorsInCode('''
class A {
- int m1() => null;
- T m2<T>() => null;
+ int m1() => 0;
+ T m2<T>() => throw 0;
}
var a = new A();
var t1 = a.m1();
@@ -303,17 +299,17 @@
test_override_conflictFieldType() async {
await assertErrorsInCode('''
abstract class A {
- int aaa;
+ int aaa = 0;
}
abstract class B {
- String aaa;
+ String aaa = '0';
}
class C implements A, B {
var aaa;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 99, 3),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 99, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 109, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 109, 3),
]);
}
@@ -344,7 +340,8 @@
}
@reflectiveTest
-class TopLevelInferenceTest extends BaseAnalysisDriverTest {
+class TopLevelInferenceTest extends PubPackageResolutionTest
+ with WithNullSafetyMixin {
test_initializer_additive() async {
var library = await _encodeDecodeLibrary(r'''
var vPlusIntInt = 1 + 2;
@@ -638,7 +635,7 @@
}
test_initializer_extractProperty_explicitlyTyped_differentLibraryCycle() async {
- newFile('/test/lib/a.dart', content: r'''
+ newFile('$testPackageLibPath/a.dart', content: r'''
class C {
int f = 0;
}
@@ -669,7 +666,7 @@
}
test_initializer_extractProperty_explicitlyTyped_sameLibraryCycle() async {
- newFile('/test/lib/a.dart', content: r'''
+ newFile('$testPackageLibPath/a.dart', content: r'''
import 'test.dart'; // just do make it part of the library cycle
class C {
int f = 0;
@@ -686,7 +683,7 @@
}
test_initializer_extractProperty_implicitlyTyped_differentLibraryCycle() async {
- newFile('/test/lib/a.dart', content: r'''
+ newFile('$testPackageLibPath/a.dart', content: r'''
class C {
var f = 0;
}
@@ -717,7 +714,7 @@
}
test_initializer_extractProperty_implicitlyTyped_sameLibraryCycle() async {
- newFile('/test/lib/a.dart', content: r'''
+ newFile('$testPackageLibPath/a.dart', content: r'''
import 'test.dart'; // just do make it part of the library cycle
class C {
var f = 0;
@@ -2157,6 +2154,34 @@
double foo(int x);
}
abstract class C implements A, B {
+ Never foo/*error: overrideNoCombinedSuperSignature*/(dynamic x);
+}
+''');
+ }
+
+ test_method_error_noCombinedSuperSignature2_legacy() async {
+ var library = await _encodeDecodeLibrary(r'''
+// @dart = 2.9
+abstract class A {
+ int foo(int x);
+}
+
+abstract class B {
+ double foo(int x);
+}
+
+abstract class C implements A, B {
+ Never foo(x);
+}
+''');
+ checkElementText(library, r'''
+abstract class A {
+ int foo(int x);
+}
+abstract class B {
+ double foo(int x);
+}
+abstract class C implements A, B {
Null foo/*error: overrideNoCombinedSuperSignature*/(dynamic x);
}
''');
@@ -2590,7 +2615,7 @@
}
test_method_OK_single_private_linkThroughOtherLibraryOfCycle() async {
- newFile('/test/lib/other.dart', content: r'''
+ newFile('$testPackageLibPath/other.dart', content: r'''
import 'test.dart';
class B extends A2 {}
''');
@@ -2685,21 +2710,9 @@
}
Future<LibraryElement> _encodeDecodeLibrary(String text) async {
- String path = convertPath('/test/lib/test.dart');
- newFile(path, content: text);
- UnitElementResult result = await driver.getUnitElement(path);
+ newFile(testFilePath, content: text);
+ var analysisSession = contextFor(testFilePath).currentSession;
+ var result = await analysisSession.getUnitElement(testFilePath);
return result.element.library /*!*/;
}
}
-
-@reflectiveTest
-class TopLevelInferenceTestWithSpread extends TopLevelInferenceTest {
- @override
- List<String> get enabledExperiments => [EnableString.spread_collections];
-
- @override
- @failingTest
- test_initializer_literal_map_untyped_empty() async {
- fail('times out.');
- }
-}
diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
index 54435dc..d577091 100644
--- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
+++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
@@ -4886,86 +4886,100 @@
// function and token position.
Function& function = Function::ZoneHandle(Z);
- // NOTE: This is not TokenPosition in the general sense!
- function = I->LookupClosureFunction(parsed_function()->function(), position);
+ {
+ SafepointReadRwLocker ml(thread(),
+ thread()->isolate_group()->program_lock());
+ // NOTE: This is not TokenPosition in the general sense!
+ function =
+ I->LookupClosureFunction(parsed_function()->function(), position);
+ }
+
if (function.IsNull()) {
- for (intptr_t i = 0; i < scopes()->function_scopes.length(); ++i) {
- if (scopes()->function_scopes[i].kernel_offset != offset) {
- continue;
- }
-
- const String* name;
- if (declaration) {
- name = &H.DartSymbolObfuscate(name_index);
- } else {
- name = &Symbols::AnonymousClosure();
- }
- // NOTE: This is not TokenPosition in the general sense!
- if (!closure_owner_.IsNull()) {
- function = Function::NewClosureFunctionWithKind(
- FunctionLayout::kClosureFunction, *name,
- parsed_function()->function(), position, closure_owner_);
- } else {
- function = Function::NewClosureFunction(
- *name, parsed_function()->function(), position);
- }
-
- function.set_is_debuggable(function_node_helper.dart_async_marker_ ==
- FunctionNodeHelper::kSync);
- switch (function_node_helper.dart_async_marker_) {
- case FunctionNodeHelper::kSyncStar:
- function.set_modifier(FunctionLayout::kSyncGen);
- break;
- case FunctionNodeHelper::kAsync:
- function.set_modifier(FunctionLayout::kAsync);
- function.set_is_inlinable(!FLAG_causal_async_stacks);
- break;
- case FunctionNodeHelper::kAsyncStar:
- function.set_modifier(FunctionLayout::kAsyncGen);
- function.set_is_inlinable(!FLAG_causal_async_stacks);
- break;
- default:
- // no special modifier
- break;
- }
- function.set_is_generated_body(function_node_helper.async_marker_ ==
- FunctionNodeHelper::kSyncYielding);
- // sync* functions contain two nested synthetic functions, the first of
- // which (sync_op_gen) is a regular sync function so we need to manually
- // label it generated:
- if (function.parent_function() != Function::null()) {
- const auto& parent = Function::Handle(function.parent_function());
- if (parent.IsSyncGenerator()) {
- function.set_is_generated_body(true);
+ SafepointWriteRwLocker ml(thread(),
+ thread()->isolate_group()->program_lock());
+ // NOTE: This is not TokenPosition in the general sense!
+ function =
+ I->LookupClosureFunction(parsed_function()->function(), position);
+ if (function.IsNull()) {
+ for (intptr_t i = 0; i < scopes()->function_scopes.length(); ++i) {
+ if (scopes()->function_scopes[i].kernel_offset != offset) {
+ continue;
}
+
+ const String* name;
+ if (declaration) {
+ name = &H.DartSymbolObfuscate(name_index);
+ } else {
+ name = &Symbols::AnonymousClosure();
+ }
+ // NOTE: This is not TokenPosition in the general sense!
+ if (!closure_owner_.IsNull()) {
+ function = Function::NewClosureFunctionWithKind(
+ FunctionLayout::kClosureFunction, *name,
+ parsed_function()->function(), position, closure_owner_);
+ } else {
+ function = Function::NewClosureFunction(
+ *name, parsed_function()->function(), position);
+ }
+
+ function.set_is_debuggable(function_node_helper.dart_async_marker_ ==
+ FunctionNodeHelper::kSync);
+ switch (function_node_helper.dart_async_marker_) {
+ case FunctionNodeHelper::kSyncStar:
+ function.set_modifier(FunctionLayout::kSyncGen);
+ break;
+ case FunctionNodeHelper::kAsync:
+ function.set_modifier(FunctionLayout::kAsync);
+ function.set_is_inlinable(!FLAG_causal_async_stacks);
+ break;
+ case FunctionNodeHelper::kAsyncStar:
+ function.set_modifier(FunctionLayout::kAsyncGen);
+ function.set_is_inlinable(!FLAG_causal_async_stacks);
+ break;
+ default:
+ // no special modifier
+ break;
+ }
+ function.set_is_generated_body(function_node_helper.async_marker_ ==
+ FunctionNodeHelper::kSyncYielding);
+ // sync* functions contain two nested synthetic functions, the first of
+ // which (sync_op_gen) is a regular sync function so we need to manually
+ // label it generated:
+ if (function.parent_function() != Function::null()) {
+ const auto& parent = Function::Handle(function.parent_function());
+ if (parent.IsSyncGenerator()) {
+ function.set_is_generated_body(true);
+ }
+ }
+ // Note: Is..() methods use the modifiers set above, so order matters.
+ if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) {
+ function.set_is_inlinable(!FLAG_causal_async_stacks &&
+ !FLAG_lazy_async_stacks);
+ }
+
+ function.set_end_token_pos(function_node_helper.end_position_);
+ LocalScope* scope = scopes()->function_scopes[i].scope;
+ const ContextScope& context_scope = ContextScope::Handle(
+ Z, scope->PreserveOuterScope(flow_graph_builder_->context_depth_));
+ function.set_context_scope(context_scope);
+ function.set_kernel_offset(offset);
+ type_translator_.SetupFunctionParameters(Class::Handle(Z), function,
+ false, // is_method
+ true, // is_closure
+ &function_node_helper);
+ // type_translator_.SetupUnboxingInfoMetadata is not called here at the
+ // moment because closures do not have unboxed parameters and return
+ // value
+ function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd);
+
+ // Finalize function type.
+ Type& signature_type = Type::Handle(Z, function.SignatureType());
+ signature_type ^= ClassFinalizer::FinalizeType(signature_type);
+ function.SetSignatureType(signature_type);
+
+ I->AddClosureFunction(function);
+ break;
}
- // Note: Is..() methods use the modifiers set above, so order matters.
- if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) {
- function.set_is_inlinable(!FLAG_causal_async_stacks &&
- !FLAG_lazy_async_stacks);
- }
-
- function.set_end_token_pos(function_node_helper.end_position_);
- LocalScope* scope = scopes()->function_scopes[i].scope;
- const ContextScope& context_scope = ContextScope::Handle(
- Z, scope->PreserveOuterScope(flow_graph_builder_->context_depth_));
- function.set_context_scope(context_scope);
- function.set_kernel_offset(offset);
- type_translator_.SetupFunctionParameters(Class::Handle(Z), function,
- false, // is_method
- true, // is_closure
- &function_node_helper);
- // type_translator_.SetupUnboxingInfoMetadata is not called here at the
- // moment because closures do not have unboxed parameters and return value
- function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd);
-
- // Finalize function type.
- Type& signature_type = Type::Handle(Z, function.SignatureType());
- signature_type ^= ClassFinalizer::FinalizeType(signature_type);
- function.SetSignatureType(signature_type);
-
- I->AddClosureFunction(function);
- break;
}
}
diff --git a/tools/VERSION b/tools/VERSION
index e227f33..857b325 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 12
PATCH 0
-PRERELEASE 143
+PRERELEASE 144
PRERELEASE_PATCH 0
\ No newline at end of file