Skip to content

Commit

Permalink
Version 2.12.0-247.0.dev
Browse files Browse the repository at this point in the history
Merge commit '54402fb7e0633e6608ecefa73d04014fed61340a' into 'dev'
  • Loading branch information
Dart CI committed Jan 21, 2021
2 parents 970d74c + 54402fb commit fd72dbb
Show file tree
Hide file tree
Showing 90 changed files with 4,831 additions and 3,419 deletions.
24 changes: 15 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

### Language

**Breaking Change** [Null
Safety](https://dart.dev/null-safety/understanding-null-safety) is now enabled
by default in all packages with a lower sdk constraint of 2.12.0 or greater.
Files that are not subject to language versioning (whether because they are not
contained in a pub package, or because the package that they are contained in
has no lower sdk constraint) are treated as opted into to null safety by default
and may report new errors. Pub packages may be opted out of null safety by
setting a min sdk constraint in pubspec.yaml of 2.9.0 or less. Files may be
opted out of null safety by adding `// @dart=2.9` to the beginning of the file.
* **Breaking Change** [Null
Safety](https://dart.dev/null-safety/understanding-null-safety) is now
enabled by default in all packages with a lower sdk constraint of 2.12.0 or
greater. Files that are not subject to language versioning (whether because
they are not contained in a pub package, or because the package that they
are contained in has no lower sdk constraint) are treated as opted into to
null safety by default and may report new errors. Pub packages may be opted
out of null safety by setting a min sdk constraint in pubspec.yaml of 2.9.0
or less. Files may be opted out of null safety by adding `// @dart=2.9` to
the beginning of the file.

* **Breaking Change** [#44660][]: Fixed an implementation bug where `this`
would sometimes undergo type promotion in extensions.

[#44660]: https://github.com/dart-lang/sdk/issues/44660

### Core libraries

Expand Down
1 change: 1 addition & 0 deletions pkg/analyzer/lib/error/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ const List<ErrorCode> errorCodeValues = [
CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME,
CompileTimeErrorCode.INVALID_EXTENSION_ARGUMENT_COUNT,
CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS,
CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE,
CompileTimeErrorCode.INVALID_INLINE_FUNCTION_TYPE,
CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR,
CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER,
Expand Down
17 changes: 17 additions & 0 deletions pkg/analyzer/lib/src/error/codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5890,6 +5890,23 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
"the immediately enclosing class.",
hasPublishedDocs: true);

/**
* Parameters:
* 0: the name of the declared member that is not a valid override.
* 1: the name of the interface that declares the member.
* 2: the type of the declared member in the interface.
* 3. the name of the interface with the overridden member.
* 4. the type of the overridden member.
*
* These parameters must be kept in sync with those of
* [CompileTimeErrorCode.INVALID_OVERRIDE].
*/
static const CompileTimeErrorCode INVALID_IMPLEMENTATION_OVERRIDE =
CompileTimeErrorCode(
'INVALID_IMPLEMENTATION_OVERRIDE',
"'{1}.{0}' ('{2}') isn't a valid concrete implementation of "
"'{3}.{0}' ('{4}').");

/**
* No parameters.
*/
Expand Down
4 changes: 3 additions & 1 deletion pkg/analyzer/lib/src/error/correct_override.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/analysis/session.dart';
import 'package:analyzer/src/dart/element/element.dart';
Expand Down Expand Up @@ -48,11 +49,12 @@ class CorrectOverrideHelper {
@required ExecutableElement superMember,
@required ErrorReporter errorReporter,
@required AstNode errorNode,
ErrorCode errorCode,
}) {
var isCorrect = isCorrectOverrideOf(superMember: superMember);
if (!isCorrect) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.INVALID_OVERRIDE,
errorCode ?? CompileTimeErrorCode.INVALID_OVERRIDE,
errorNode,
[
_thisMember.name,
Expand Down
1 change: 1 addition & 0 deletions pkg/analyzer/lib/src/error/inheritance_override.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class _ClassVerifier {
superMember: interfaceElement,
errorReporter: reporter,
errorNode: classNameNode,
errorCode: CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE,
);
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/test/generated/static_warning_code_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ abstract class D {
foo(x, [y]);
}
class E extends C implements D {}''', [
error(CompileTimeErrorCode.INVALID_OVERRIDE, 73, 1),
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 73, 1),
]);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright (c) 2021, 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.

import 'package:analyzer/src/error/codes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';

import '../dart/resolution/context_collection_resolution.dart';

main() {
defineReflectiveSuite(() {
defineReflectiveTests(InvalidImplementationOverrideTest);
defineReflectiveTests(InvalidImplementationOverrideWithNullSafetyTest);
});
}

@reflectiveTest
class InvalidImplementationOverrideTest extends PubPackageResolutionTest {
test_getter_abstractOverridesConcrete() async {
await assertErrorsInCode('''
class A {
num get g => 7;
}
class B extends A {
int get g;
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 36, 1),
]);
}

test_method_abstractOverridesConcrete() async {
await assertErrorsInCode('''
class A {
int add(int a, int b) => a + b;
}
class B extends A {
int add();
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 52, 1),
error(CompileTimeErrorCode.INVALID_OVERRIDE, 72, 3),
]);
}

test_method_abstractOverridesConcrete_expandedParameterType() async {
await assertErrorsInCode('''
class A {
int add(int a) => a;
}
class B extends A {
int add(num a);
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 41, 1),
]);
}

test_method_abstractOverridesConcrete_expandedParameterType_covariant() async {
await assertNoErrorsInCode('''
class A {
int add(covariant int a) => a;
}
class B extends A {
int add(num a);
}
''');
}

test_method_abstractOverridesConcrete_withOptional() async {
await assertErrorsInCode('''
class A {
int add() => 7;
}
class B extends A {
int add([int a = 0, int b = 0]);
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 36, 1),
]);
}

test_method_abstractOverridesConcreteInMixin() async {
await assertErrorsInCode('''
mixin M {
int add(int a, int b) => a + b;
}
class A with M {
int add();
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 52, 1),
error(CompileTimeErrorCode.INVALID_OVERRIDE, 69, 3),
]);
}

test_method_abstractOverridesConcreteViaMixin() async {
await assertErrorsInCode('''
class A {
int add(int a, int b) => a + b;
}
mixin M {
int add();
}
class B extends A with M {}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 77, 1),
error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1),
]);
}
}

@reflectiveTest
class InvalidImplementationOverrideWithNullSafetyTest
extends PubPackageResolutionTest with WithNullSafetyMixin {}
31 changes: 30 additions & 1 deletion pkg/analyzer/test/src/diagnostics/invalid_override_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,40 @@ class B extends A {
int add();
}
''', [
error(CompileTimeErrorCode.INVALID_OVERRIDE, 52, 1),
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 52, 1),
error(CompileTimeErrorCode.INVALID_OVERRIDE, 72, 3),
]);
}

test_method_abstractOverridesConcreteInMixin() async {
await assertErrorsInCode('''
mixin M {
int add(int a, int b) => a + b;
}
class A with M {
int add();
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 52, 1),
error(CompileTimeErrorCode.INVALID_OVERRIDE, 69, 3),
]);
}

test_method_abstractOverridesConcreteViaMixin() async {
await assertErrorsInCode('''
class A {
int add(int a, int b) => a + b;
}
mixin M {
int add();
}
class B extends A with M {}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 77, 1),
error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1),
]);
}

test_method_covariant_1() async {
await assertNoErrorsInCode(r'''
abstract class A<T> {
Expand Down
3 changes: 3 additions & 0 deletions pkg/analyzer/test/src/diagnostics/test_all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ import 'invalid_factory_name_not_a_class_test.dart'
as invalid_factory_name_not_a_class;
import 'invalid_field_type_in_struct_test.dart' as invalid_field_type_in_struct;
import 'invalid_immutable_annotation_test.dart' as invalid_immutable_annotation;
import 'invalid_implementation_override_test.dart'
as invalid_implementation_override;
import 'invalid_internal_annotation_test.dart' as invalid_internal_annotation;
import 'invalid_language_override_greater_test.dart'
as invalid_language_override_greater;
Expand Down Expand Up @@ -850,6 +852,7 @@ main() {
invalid_factory_name_not_a_class.main();
invalid_field_type_in_struct.main();
invalid_immutable_annotation.main();
invalid_implementation_override.main();
invalid_internal_annotation.main();
invalid_language_override_greater.main();
invalid_language_override.main();
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer/test/src/task/strong/checker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3809,7 +3809,7 @@ class C = Object with B;
class D extends Object with C implements A {}
''', [
error(CompileTimeErrorCode.INVALID_OVERRIDE, 100, 1),
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 100, 1),
]);
}

Expand Down Expand Up @@ -4180,8 +4180,8 @@ class D extends B with X { }
class E extends B implements A { }
''', [
error(CompileTimeErrorCode.INVALID_OVERRIDE, 78, 4),
error(CompileTimeErrorCode.INVALID_OVERRIDE, 159, 1),
error(CompileTimeErrorCode.INVALID_OVERRIDE, 189, 1),
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 159, 1),
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 189, 1),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/js/legacy/dart_library.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ if (!dart_library) {
function reload(clearState) {
// TODO(jmesserly): once we've rolled out `clearState` make it the default,
// and eventually remove the parameter.
if (clearState == null) clearState = false;
if (clearState == null) clearState = true;


// TODO(jmesserly): we may want to change these APIs to use the
Expand Down
9 changes: 2 additions & 7 deletions pkg/dev_compiler/lib/src/kernel/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3101,15 +3101,10 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
_typeTable.typeContainer.incrementalMode = true;

// Emit function with additional information, such as types that are used
// in the expression. Note that typeTable can be null if this function is
// called from the expression compilation service, since we currently do
// not optimize for size of generated javascript in that scenario.
// TODO: figure whether or when optimizing for build time vs JavaScript
// size on expression evaluation is better.
// Issue: https://github.com/dart-lang/sdk/issues/43288
// in the expression.
var fun = _emitFunction(functionNode, name);

var types = _typeTable?.dischargeBoundTypes();
var types = _typeTable.dischargeBoundTypes();
var constants = _dischargeConstTable();

var body = js_ast.Block([...?types, ...?constants, ...fun.body.statements]);
Expand Down
Loading

0 comments on commit fd72dbb

Please sign in to comment.