Version 2.10.0-89.0.dev
Merge commit 'ab16d79af97b837b168672e593b3a3c613ecba41' into 'dev'
diff --git a/DEPS b/DEPS
index a31cd21..2e5429d 100644
--- a/DEPS
+++ b/DEPS
@@ -39,12 +39,12 @@
# Checked-in SDK version. The checked-in SDK is a Dart SDK distribution in a
# cipd package used to run Dart scripts in the build and test infrastructure.
- "sdk_tag": "version:2.10.0-3.0.dev",
+ "sdk_tag": "version:2.10.0-79.0.dev",
# co19 is a cipd package. Use update.sh in tests/co19[_2] to update these
# hashes. It requires access to the dart-build-access group, which EngProd
# has.
- "co19_rev": "12855e59cd7e031d076cc8cece9f5ee08e77ca8c",
+ "co19_rev": "9c07e26d67665de7972ba6f7e87369933a978545",
"co19_2_rev": "e48b3090826cf40b8037648f19d211e8eab1b4b6",
# The internal benchmarks to use. See go/dart-benchmarks-internal
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
index 7e0865d..3cd5e84 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
@@ -6608,6 +6608,27 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Null> codeNonVoidReturnOperator = messageNonVoidReturnOperator;
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const MessageCode messageNonVoidReturnOperator = const MessageCode(
+ "NonVoidReturnOperator",
+ analyzerCodes: <String>["NON_VOID_RETURN_FOR_OPERATOR"],
+ message: r"""The return type of the operator []= must be 'void'.""",
+ tip: r"""Try changing the return type to 'void'.""");
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Null> codeNonVoidReturnSetter = messageNonVoidReturnSetter;
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const MessageCode messageNonVoidReturnSetter = const MessageCode(
+ "NonVoidReturnSetter",
+ analyzerCodes: <String>["NON_VOID_RETURN_FOR_SETTER"],
+ message: r"""The return type of the setter must be 'void' or absent.""",
+ tip:
+ r"""Try removing the return type, or define a method rather than a setter.""");
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeNotAConstantExpression = messageNotAConstantExpression;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
diff --git a/pkg/front_end/lib/src/fasta/builder/builtin_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/builtin_type_declaration_builder.dart
similarity index 85%
rename from pkg/front_end/lib/src/fasta/builder/builtin_type_builder.dart
rename to pkg/front_end/lib/src/fasta/builder/builtin_type_declaration_builder.dart
index be14b32..24d258e 100644
--- a/pkg/front_end/lib/src/fasta/builder/builtin_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/builtin_type_declaration_builder.dart
@@ -12,10 +12,11 @@
import 'type_declaration_builder.dart';
-abstract class BuiltinTypeBuilder extends TypeDeclarationBuilderImpl {
+abstract class BuiltinTypeDeclarationBuilder
+ extends TypeDeclarationBuilderImpl {
final DartType type;
- BuiltinTypeBuilder(
+ BuiltinTypeDeclarationBuilder(
String name, this.type, LibraryBuilder compilationUnit, int charOffset)
: super(null, 0, name, compilationUnit, charOffset);
@@ -30,5 +31,5 @@
return type.withDeclaredNullability(nullability);
}
- String get debugName => "BuiltinTypeBuilder";
+ String get debugName => "BuiltinTypeDeclarationBuilder";
}
diff --git a/pkg/front_end/lib/src/fasta/builder/class_builder.dart b/pkg/front_end/lib/src/fasta/builder/class_builder.dart
index 926b2ff..a189dc1 100644
--- a/pkg/front_end/lib/src/fasta/builder/class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/class_builder.dart
@@ -84,14 +84,14 @@
import 'member_builder.dart';
import 'metadata_builder.dart';
import 'named_type_builder.dart';
-import 'never_type_builder.dart';
+import 'never_type_declaration_builder.dart';
import 'nullability_builder.dart';
import 'procedure_builder.dart';
import 'type_alias_builder.dart';
import 'type_builder.dart';
import 'type_declaration_builder.dart';
import 'type_variable_builder.dart';
-import 'void_type_builder.dart';
+import 'void_type_declaration_builder.dart';
abstract class ClassBuilder implements DeclarationBuilder {
/// The type variables declared on a class, extension or mixin declaration.
@@ -687,9 +687,9 @@
}
// TODO(eernst): Should gather 'restricted supertype' checks in one place,
// e.g., dynamic/int/String/Null and more are checked elsewhere.
- if (decl is VoidTypeBuilder) {
+ if (decl is VoidTypeDeclarationBuilder) {
fail(superClassType, messageExtendsVoid, aliasBuilder);
- } else if (decl is NeverTypeBuilder) {
+ } else if (decl is NeverTypeDeclarationBuilder) {
fail(superClassType, messageExtendsNever, aliasBuilder);
} else if (decl is ClassBuilder) {
superClass = decl;
@@ -737,9 +737,9 @@
}
if (decl != superClass) {
// TODO(eernst): Have all 'restricted supertype' checks in one place.
- if (decl is VoidTypeBuilder) {
+ if (decl is VoidTypeDeclarationBuilder) {
fail(type, messageImplementsVoid, aliasBuilder);
- } else if (decl is NeverTypeBuilder) {
+ } else if (decl is NeverTypeDeclarationBuilder) {
fail(type, messageImplementsNever, aliasBuilder);
}
}
diff --git a/pkg/front_end/lib/src/fasta/builder/dynamic_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/dynamic_type_declaration_builder.dart
similarity index 68%
rename from pkg/front_end/lib/src/fasta/builder/dynamic_type_builder.dart
rename to pkg/front_end/lib/src/fasta/builder/dynamic_type_declaration_builder.dart
index b5c377c..b5e9b80 100644
--- a/pkg/front_end/lib/src/fasta/builder/dynamic_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/dynamic_type_declaration_builder.dart
@@ -6,13 +6,13 @@
import 'package:kernel/ast.dart' show DartType;
-import 'builtin_type_builder.dart';
+import 'builtin_type_declaration_builder.dart';
import 'library_builder.dart';
-class DynamicTypeBuilder extends BuiltinTypeBuilder {
- DynamicTypeBuilder(
+class DynamicTypeDeclarationBuilder extends BuiltinTypeDeclarationBuilder {
+ DynamicTypeDeclarationBuilder(
DartType type, LibraryBuilder compilationUnit, int charOffset)
: super("dynamic", type, compilationUnit, charOffset);
- String get debugName => "DynamicTypeBuilder";
+ String get debugName => "DynamicTypeDeclarationBuilder";
}
diff --git a/pkg/front_end/lib/src/fasta/builder/enum_builder.dart b/pkg/front_end/lib/src/fasta/builder/enum_builder.dart
index 9580da7..cd62848 100644
--- a/pkg/front_end/lib/src/fasta/builder/enum_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/enum_builder.dart
@@ -128,19 +128,39 @@
assert(enumConstantInfos == null || enumConstantInfos.isNotEmpty);
// TODO(ahe): These types shouldn't be looked up in scope, they come
// directly from dart:core.
- TypeBuilder intType =
- new NamedTypeBuilder("int", const NullabilityBuilder.omitted(), null);
+ TypeBuilder intType = new NamedTypeBuilder(
+ "int",
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
TypeBuilder stringType = new NamedTypeBuilder(
- "String", const NullabilityBuilder.omitted(), null);
+ "String",
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
NamedTypeBuilder objectType = new NamedTypeBuilder(
- "Object", const NullabilityBuilder.omitted(), null);
+ "Object",
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
Class cls = new Class(name: name, reference: referencesFrom?.reference);
Map<String, MemberBuilder> members = <String, MemberBuilder>{};
Map<String, MemberBuilder> constructors = <String, MemberBuilder>{};
- NamedTypeBuilder selfType =
- new NamedTypeBuilder(name, const NullabilityBuilder.omitted(), null);
+ NamedTypeBuilder selfType = new NamedTypeBuilder(
+ name,
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
TypeBuilder listType = new NamedTypeBuilder(
- "List", const NullabilityBuilder.omitted(), <TypeBuilder>[selfType]);
+ "List",
+ const NullabilityBuilder.omitted(),
+ <TypeBuilder>[selfType],
+ /* fileUri = */ null,
+ /* charOffset = */ null);
/// metadata class E {
/// final int index;
diff --git a/pkg/front_end/lib/src/fasta/builder/fixed_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/fixed_type_builder.dart
index 7675648..d6eb954 100644
--- a/pkg/front_end/lib/src/fasta/builder/fixed_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/fixed_type_builder.dart
@@ -11,8 +11,10 @@
class FixedTypeBuilder extends TypeBuilder {
final DartType type;
+ final Uri fileUri;
+ final int charOffset;
- const FixedTypeBuilder(this.type);
+ const FixedTypeBuilder(this.type, this.fileUri, this.charOffset);
TypeBuilder clone(List<TypeBuilder> newTypes) => this;
@@ -23,6 +25,8 @@
String get debugName => 'FixedTypeBuilder';
+ bool get isVoidType => type is VoidType;
+
StringBuffer printOn(StringBuffer buffer) {
buffer.write('type=${type}');
return buffer;
diff --git a/pkg/front_end/lib/src/fasta/builder/function_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/function_type_builder.dart
index 027d8c3..f56ac53 100644
--- a/pkg/front_end/lib/src/fasta/builder/function_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/function_type_builder.dart
@@ -27,9 +27,11 @@
final List<TypeVariableBuilder> typeVariables;
final List<FormalParameterBuilder> formals;
final NullabilityBuilder nullabilityBuilder;
+ final Uri fileUri;
+ final int charOffset;
FunctionTypeBuilder(this.returnType, this.typeVariables, this.formals,
- this.nullabilityBuilder);
+ this.nullabilityBuilder, this.fileUri, this.charOffset);
@override
String get name => null;
@@ -37,6 +39,8 @@
@override
String get debugName => "Function";
+ bool get isVoidType => false;
+
@override
StringBuffer printOn(StringBuffer buffer) {
if (typeVariables != null) {
@@ -143,14 +147,16 @@
returnType?.clone(newTypes),
clonedTypeVariables,
clonedFormals,
- nullabilityBuilder);
+ nullabilityBuilder,
+ fileUri,
+ charOffset);
newTypes.add(newType);
return newType;
}
FunctionTypeBuilder withNullabilityBuilder(
NullabilityBuilder nullabilityBuilder) {
- return new FunctionTypeBuilder(
- returnType, typeVariables, formals, nullabilityBuilder);
+ return new FunctionTypeBuilder(returnType, typeVariables, formals,
+ nullabilityBuilder, fileUri, charOffset);
}
}
diff --git a/pkg/front_end/lib/src/fasta/builder/future_or_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/future_or_type_declaration_builder.dart
similarity index 82%
rename from pkg/front_end/lib/src/fasta/builder/future_or_type_builder.dart
rename to pkg/front_end/lib/src/fasta/builder/future_or_type_declaration_builder.dart
index fc823fc..bc3c296 100644
--- a/pkg/front_end/lib/src/fasta/builder/future_or_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/future_or_type_declaration_builder.dart
@@ -6,17 +6,17 @@
import 'package:kernel/ast.dart' show DartType, FutureOrType, Nullability;
-import 'builtin_type_builder.dart';
+import 'builtin_type_declaration_builder.dart';
import 'library_builder.dart';
import 'nullability_builder.dart';
import 'type_builder.dart';
-class FutureOrTypeBuilder extends BuiltinTypeBuilder {
- FutureOrTypeBuilder(
+class FutureOrTypeDeclarationBuilder extends BuiltinTypeDeclarationBuilder {
+ FutureOrTypeDeclarationBuilder(
DartType type, LibraryBuilder compilationUnit, int charOffset)
: super("FutureOr", type, compilationUnit, charOffset);
- String get debugName => "FutureOrTypeBuilder";
+ String get debugName => "FutureOrTypeDeclarationBuilder";
DartType buildType(LibraryBuilder library,
NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
diff --git a/pkg/front_end/lib/src/fasta/builder/mixin_application_builder.dart b/pkg/front_end/lib/src/fasta/builder/mixin_application_builder.dart
index 1991aed..e78679d 100644
--- a/pkg/front_end/lib/src/fasta/builder/mixin_application_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/mixin_application_builder.dart
@@ -16,11 +16,14 @@
class MixinApplicationBuilder extends TypeBuilder {
final TypeBuilder supertype;
final List<TypeBuilder> mixins;
+ final Uri fileUri;
+ final int charOffset;
Supertype builtType;
List<TypeVariableBuilder> typeVariables;
- MixinApplicationBuilder(this.supertype, this.mixins);
+ MixinApplicationBuilder(
+ this.supertype, this.mixins, this.fileUri, this.charOffset);
String get name => null;
@@ -30,6 +33,8 @@
String get debugName => "MixinApplicationBuilder";
+ bool get isVoidType => false;
+
StringBuffer printOn(StringBuffer buffer) {
buffer.write(supertype);
buffer.write(" with ");
diff --git a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
index 0ab1b7f..dec0428 100644
--- a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
@@ -47,7 +47,7 @@
import '../scope.dart';
import 'builder.dart';
-import 'builtin_type_builder.dart';
+import 'builtin_type_declaration_builder.dart';
import 'class_builder.dart';
import 'invalid_type_declaration_builder.dart';
import 'library_builder.dart';
@@ -57,6 +57,7 @@
import 'type_builder.dart';
import 'type_declaration_builder.dart';
import 'type_variable_builder.dart';
+import 'void_type_declaration_builder.dart';
class NamedTypeBuilder extends TypeBuilder {
final Object name;
@@ -65,20 +66,25 @@
final NullabilityBuilder nullabilityBuilder;
+ @override
final Uri fileUri;
+
+ @override
final int charOffset;
@override
TypeDeclarationBuilder declaration;
NamedTypeBuilder(this.name, this.nullabilityBuilder, this.arguments,
- [this.fileUri, this.charOffset]);
+ this.fileUri, this.charOffset);
NamedTypeBuilder.fromTypeDeclarationBuilder(
this.declaration, this.nullabilityBuilder,
[this.arguments, this.fileUri, this.charOffset])
: this.name = declaration.name;
+ bool get isVoidType => declaration is VoidTypeDeclarationBuilder;
+
@override
void bind(TypeDeclarationBuilder declaration) {
this.declaration = declaration?.origin;
@@ -344,8 +350,8 @@
i++;
}
if (arguments != null) {
- NamedTypeBuilder result =
- new NamedTypeBuilder(name, nullabilityBuilder, arguments);
+ NamedTypeBuilder result = new NamedTypeBuilder(
+ name, nullabilityBuilder, arguments, fileUri, charOffset);
if (declaration != null) {
result.bind(declaration);
} else {
@@ -365,9 +371,9 @@
clonedArguments[i] = arguments[i].clone(newTypes);
}
}
- NamedTypeBuilder newType =
- new NamedTypeBuilder(name, nullabilityBuilder, clonedArguments);
- if (declaration is BuiltinTypeBuilder) {
+ NamedTypeBuilder newType = new NamedTypeBuilder(
+ name, nullabilityBuilder, clonedArguments, fileUri, charOffset);
+ if (declaration is BuiltinTypeDeclarationBuilder) {
newType.declaration = declaration;
} else {
newTypes.add(newType);
@@ -377,7 +383,8 @@
NamedTypeBuilder withNullabilityBuilder(
NullabilityBuilder nullabilityBuilder) {
- return new NamedTypeBuilder(name, nullabilityBuilder, arguments)
+ return new NamedTypeBuilder(
+ name, nullabilityBuilder, arguments, fileUri, charOffset)
..bind(declaration);
}
}
diff --git a/pkg/front_end/lib/src/fasta/builder/never_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/never_type_declaration_builder.dart
similarity index 81%
rename from pkg/front_end/lib/src/fasta/builder/never_type_builder.dart
rename to pkg/front_end/lib/src/fasta/builder/never_type_declaration_builder.dart
index 49a9dc0..d91935f 100644
--- a/pkg/front_end/lib/src/fasta/builder/never_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/never_type_declaration_builder.dart
@@ -6,17 +6,17 @@
import 'package:kernel/ast.dart' show DartType, Nullability;
-import 'builtin_type_builder.dart';
+import 'builtin_type_declaration_builder.dart';
import 'library_builder.dart';
import 'nullability_builder.dart';
import 'type_builder.dart';
-class NeverTypeBuilder extends BuiltinTypeBuilder {
- NeverTypeBuilder(
+class NeverTypeDeclarationBuilder extends BuiltinTypeDeclarationBuilder {
+ NeverTypeDeclarationBuilder(
DartType type, LibraryBuilder compilationUnit, int charOffset)
: super("Never", type, compilationUnit, charOffset);
- String get debugName => "NeverTypeBuilder";
+ String get debugName => "NeverTypeDeclarationBuilder";
DartType buildType(LibraryBuilder library,
NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
diff --git a/pkg/front_end/lib/src/fasta/builder/type_builder.dart b/pkg/front_end/lib/src/fasta/builder/type_builder.dart
index 01d5a33..d1ff518 100644
--- a/pkg/front_end/lib/src/fasta/builder/type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/type_builder.dart
@@ -17,6 +17,14 @@
TypeDeclarationBuilder get declaration => null;
+ /// Returns the Uri for the file in which this type annotation occurred, or
+ /// `null` if the type was synthesized.
+ Uri get fileUri;
+
+ /// Returns the character offset with [fileUri] at which this type annotation
+ /// occurred, or `null` if the type was synthesized.
+ int get charOffset;
+
void resolveIn(
Scope scope, int charOffset, Uri fileUri, LibraryBuilder library) {}
@@ -64,4 +72,6 @@
LibraryBuilder library, int charOffset, Uri fileUri);
TypeBuilder withNullabilityBuilder(NullabilityBuilder nullabilityBuilder);
+
+ bool get isVoidType;
}
diff --git a/pkg/front_end/lib/src/fasta/builder/void_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/void_type_builder.dart
deleted file mode 100644
index 9d0478d..0000000
--- a/pkg/front_end/lib/src/fasta/builder/void_type_builder.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2017, 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.
-
-library fasta.void_type_builder;
-
-import 'package:kernel/ast.dart' show DartType;
-
-import 'builtin_type_builder.dart';
-import 'library_builder.dart';
-
-class VoidTypeBuilder extends BuiltinTypeBuilder {
- VoidTypeBuilder(DartType type, LibraryBuilder compilationUnit, int charOffset)
- : super("void", type, compilationUnit, charOffset);
-
- String get debugName => "VoidTypeBuilder";
-}
diff --git a/pkg/front_end/lib/src/fasta/builder/void_type_declaration_builder.dart b/pkg/front_end/lib/src/fasta/builder/void_type_declaration_builder.dart
new file mode 100644
index 0000000..25c6760
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/builder/void_type_declaration_builder.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2017, 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.
+
+library fasta.void_type_builder;
+
+import 'package:kernel/ast.dart' show DartType;
+
+import 'builtin_type_declaration_builder.dart';
+import 'library_builder.dart';
+
+class VoidTypeDeclarationBuilder extends BuiltinTypeDeclarationBuilder {
+ VoidTypeDeclarationBuilder(
+ DartType type, LibraryBuilder compilationUnit, int charOffset)
+ : super("void", type, compilationUnit, charOffset);
+
+ String get debugName => "VoidTypeDeclarationBuilder";
+}
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
index be09ade..07ed03c 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
@@ -31,10 +31,10 @@
import '../builder/builder.dart';
import '../builder/class_builder.dart';
-import '../builder/dynamic_type_builder.dart';
+import '../builder/dynamic_type_declaration_builder.dart';
import '../builder/extension_builder.dart';
import '../builder/modifier_builder.dart';
-import '../builder/never_type_builder.dart';
+import '../builder/never_type_declaration_builder.dart';
import '../builder/invalid_type_declaration_builder.dart';
import '../builder/library_builder.dart';
import '../builder/member_builder.dart';
@@ -151,14 +151,14 @@
String get name => library.name;
void addSyntheticDeclarationOfDynamic() {
- addBuilder(
- "dynamic", new DynamicTypeBuilder(const DynamicType(), this, -1), -1);
+ addBuilder("dynamic",
+ new DynamicTypeDeclarationBuilder(const DynamicType(), this, -1), -1);
}
void addSyntheticDeclarationOfNever() {
addBuilder(
"Never",
- new NeverTypeBuilder(
+ new NeverTypeDeclarationBuilder(
const NeverType(Nullability.nonNullable), this, -1),
-1);
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index bf1173b..8558d1f 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -67,7 +67,7 @@
import '../builder/type_variable_builder.dart';
import '../builder/unresolved_type.dart';
import '../builder/variable_builder.dart';
-import '../builder/void_type_builder.dart';
+import '../builder/void_type_declaration_builder.dart';
import '../constant_context.dart' show ConstantContext;
@@ -3248,8 +3248,12 @@
// TODO(ahe): Arguments could be passed here.
libraryBuilder.addProblem(
name.message, name.charOffset, name.name.length, name.fileUri);
- result = new NamedTypeBuilder(name.name,
- libraryBuilder.nullableBuilderIfTrue(isMarkedAsNullable), null)
+ result = new NamedTypeBuilder(
+ name.name,
+ libraryBuilder.nullableBuilderIfTrue(isMarkedAsNullable),
+ /* arguments = */ null,
+ name.fileUri,
+ name.charOffset)
..bind(new InvalidTypeDeclarationBuilder(
name.name,
name.message.withLocation(
@@ -3318,7 +3322,8 @@
push(new UnresolvedType(
new NamedTypeBuilder(
"void", const NullabilityBuilder.nullable(), null, uri, offset)
- ..bind(new VoidTypeBuilder(const VoidType(), libraryBuilder, offset)),
+ ..bind(new VoidTypeDeclarationBuilder(
+ const VoidType(), libraryBuilder, offset)),
offset,
uri));
}
@@ -6036,7 +6041,11 @@
if (message == null) return unresolved;
return new UnresolvedType(
new NamedTypeBuilder(
- typeParameter.name, builder.nullabilityBuilder, null)
+ typeParameter.name,
+ builder.nullabilityBuilder,
+ /* arguments = */ null,
+ unresolved.fileUri,
+ unresolved.charOffset)
..bind(
new InvalidTypeDeclarationBuilder(typeParameter.name, message)),
unresolved.charOffset,
@@ -6508,7 +6517,7 @@
[List<TypeVariableBuilder> typeParameters]) {
return new UnresolvedType(
new FunctionTypeBuilder(returnType?.builder, typeParameters, parameters,
- nullabilityBuilder),
+ nullabilityBuilder, uri, charOffset),
charOffset,
uri);
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
index b392aab..ec809d6 100644
--- a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
@@ -272,8 +272,13 @@
/// create a [TypeBuilder] for a valid type.
TypeBuilder buildTypeWithResolvedArguments(
NullabilityBuilder nullabilityBuilder, List<UnresolvedType> arguments) {
- NamedTypeBuilder result =
- new NamedTypeBuilder(token.lexeme, nullabilityBuilder, null);
+ // TODO(johnniwinther): Could we use a FixedTypeBuilder(InvalidType()) here?
+ NamedTypeBuilder result = new NamedTypeBuilder(
+ token.lexeme,
+ nullabilityBuilder,
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
Message message = templateNotAType.withArguments(token.lexeme);
_helper.libraryBuilder
.addProblem(message, fileOffset, lengthForToken(token), _uri);
@@ -2858,8 +2863,13 @@
.withLocation(
_uri, charOffset, lengthOfSpan(prefixGenerator.token, token));
}
- NamedTypeBuilder result =
- new NamedTypeBuilder(name, nullabilityBuilder, null);
+ // TODO(johnniwinther): Could we use a FixedTypeBuilder(InvalidType()) here?
+ NamedTypeBuilder result = new NamedTypeBuilder(
+ name,
+ nullabilityBuilder,
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
_helper.libraryBuilder.addProblem(
message.messageObject, message.charOffset, message.length, message.uri);
result.bind(result.buildInvalidTypeDeclarationBuilder(message));
@@ -3896,8 +3906,13 @@
Template<Message Function(String, String)> template = isUnresolved
? templateUnresolvedPrefixInTypeAnnotation
: templateNotAPrefixInTypeAnnotation;
- NamedTypeBuilder result =
- new NamedTypeBuilder(_plainNameForRead, nullabilityBuilder, null);
+ // TODO(johnniwinther): Could we use a FixedTypeBuilder(InvalidType()) here?
+ NamedTypeBuilder result = new NamedTypeBuilder(
+ _plainNameForRead,
+ nullabilityBuilder,
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
Message message =
template.withArguments(prefixGenerator.token.lexeme, token.lexeme);
_helper.libraryBuilder.addProblem(
@@ -3998,8 +4013,13 @@
TypeBuilder buildTypeWithResolvedArguments(
NullabilityBuilder nullabilityBuilder, List<UnresolvedType> arguments) {
- NamedTypeBuilder result =
- new NamedTypeBuilder(token.lexeme, nullabilityBuilder, null);
+ // TODO(johnniwinther): Could we use a FixedTypeBuilder(InvalidType()) here?
+ NamedTypeBuilder result = new NamedTypeBuilder(
+ token.lexeme,
+ nullabilityBuilder,
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
_helper.libraryBuilder.addProblem(message, fileOffset, noLength, _uri);
result.bind(result.buildInvalidTypeDeclarationBuilder(
message.withLocation(_uri, fileOffset, noLength)));
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index 3a5f05f..a7d6a2a 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -65,19 +65,19 @@
import '../builder/builder.dart';
import '../builder/class_builder.dart';
import '../builder/constructor_builder.dart';
-import '../builder/dynamic_type_builder.dart';
+import '../builder/dynamic_type_declaration_builder.dart';
import '../builder/field_builder.dart';
import '../builder/invalid_type_declaration_builder.dart';
import '../builder/library_builder.dart';
import '../builder/named_type_builder.dart';
-import '../builder/never_type_builder.dart';
+import '../builder/never_type_declaration_builder.dart';
import '../builder/nullability_builder.dart';
import '../builder/procedure_builder.dart';
import '../builder/type_alias_builder.dart';
import '../builder/type_builder.dart';
import '../builder/type_declaration_builder.dart';
import '../builder/type_variable_builder.dart';
-import '../builder/void_type_builder.dart';
+import '../builder/void_type_declaration_builder.dart';
import '../compiler_context.dart' show CompilerContext;
@@ -148,18 +148,38 @@
Component component;
// 'dynamic' is always nullable.
+ // TODO(johnniwinther): Why isn't this using a FixedTypeBuilder?
final TypeBuilder dynamicType = new NamedTypeBuilder(
- "dynamic", const NullabilityBuilder.nullable(), null);
+ "dynamic",
+ const NullabilityBuilder.nullable(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
- final NamedTypeBuilder objectType =
- new NamedTypeBuilder("Object", const NullabilityBuilder.omitted(), null);
+ final NamedTypeBuilder objectType = new NamedTypeBuilder(
+ "Object",
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
// Null is always nullable.
- final TypeBuilder nullType =
- new NamedTypeBuilder("Null", const NullabilityBuilder.nullable(), null);
+ // TODO(johnniwinther): This could (maybe) use a FixedTypeBuilder when we
+ // have NullType?
+ final TypeBuilder nullType = new NamedTypeBuilder(
+ "Null",
+ const NullabilityBuilder.nullable(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
- final TypeBuilder bottomType =
- new NamedTypeBuilder("Never", const NullabilityBuilder.omitted(), null);
+ // TODO(johnniwinther): Why isn't this using a FixedTypeBuilder?
+ final TypeBuilder bottomType = new NamedTypeBuilder(
+ "Never",
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null);
final bool excludeSource = !CompilerContext.current.options.embedSourceText;
@@ -289,9 +309,13 @@
cls.implementedTypes.clear();
cls.supertype = null;
cls.mixedInType = null;
- builder.supertypeBuilder =
- new NamedTypeBuilder("Object", const NullabilityBuilder.omitted(), null)
- ..bind(objectClassBuilder);
+ builder.supertypeBuilder = new NamedTypeBuilder(
+ "Object",
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null)
+ ..bind(objectClassBuilder);
builder.interfaceBuilders = null;
builder.mixedInTypeBuilder = null;
}
@@ -456,7 +480,11 @@
if (cls != objectClass) {
cls.supertype ??= objectClass.asRawSupertype;
declaration.supertypeBuilder ??= new NamedTypeBuilder(
- "Object", const NullabilityBuilder.omitted(), null)
+ "Object",
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null)
..bind(objectClassBuilder);
}
if (declaration.isMixinApplication) {
@@ -593,9 +621,9 @@
}
} else if (supertype is InvalidTypeDeclarationBuilder ||
supertype is TypeVariableBuilder ||
- supertype is DynamicTypeBuilder ||
- supertype is VoidTypeBuilder ||
- supertype is NeverTypeBuilder) {
+ supertype is DynamicTypeDeclarationBuilder ||
+ supertype is VoidTypeDeclarationBuilder ||
+ supertype is NeverTypeDeclarationBuilder) {
builder.addSyntheticConstructor(
makeDefaultConstructor(builder.cls, referenceFrom));
} else {
diff --git a/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart b/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart
index 3716204..9143dcb 100644
--- a/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart
@@ -279,8 +279,8 @@
assert(false, "Unexpected named type builder declaration: $declaration.");
}
if (arguments != null) {
- NamedTypeBuilder newTypeBuilder =
- new NamedTypeBuilder(type.name, type.nullabilityBuilder, arguments);
+ NamedTypeBuilder newTypeBuilder = new NamedTypeBuilder(type.name,
+ type.nullabilityBuilder, arguments, type.fileUri, type.charOffset);
if (declaration != null) {
newTypeBuilder.bind(declaration);
} else {
@@ -365,8 +365,8 @@
changed = changed || returnType != type.returnType;
if (changed) {
- return new FunctionTypeBuilder(
- returnType, variables, formals, type.nullabilityBuilder);
+ return new FunctionTypeBuilder(returnType, variables, formals,
+ type.nullabilityBuilder, type.fileUri, type.charOffset);
}
return type;
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/type_builder_computer.dart b/pkg/front_end/lib/src/fasta/kernel/type_builder_computer.dart
index 239e403..0aea072 100644
--- a/pkg/front_end/lib/src/fasta/kernel/type_builder_computer.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/type_builder_computer.dart
@@ -29,17 +29,17 @@
VoidType;
import '../builder/class_builder.dart';
-import '../builder/dynamic_type_builder.dart';
+import '../builder/dynamic_type_declaration_builder.dart';
import '../builder/formal_parameter_builder.dart';
import '../builder/function_type_builder.dart';
-import '../builder/future_or_type_builder.dart';
+import '../builder/future_or_type_declaration_builder.dart';
import '../builder/library_builder.dart';
import '../builder/named_type_builder.dart';
-import '../builder/never_type_builder.dart';
+import '../builder/never_type_declaration_builder.dart';
import '../builder/nullability_builder.dart';
import '../builder/type_builder.dart';
import '../builder/type_variable_builder.dart';
-import '../builder/void_type_builder.dart';
+import '../builder/void_type_declaration_builder.dart';
import '../loader.dart' show Loader;
@@ -62,17 +62,26 @@
TypeBuilder visitDynamicType(DynamicType node) {
// 'dynamic' is always nullable.
return new NamedTypeBuilder(
- "dynamic", const NullabilityBuilder.nullable(), null)
- ..bind(
- new DynamicTypeBuilder(const DynamicType(), loader.coreLibrary, -1));
+ "dynamic",
+ const NullabilityBuilder.nullable(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null)
+ ..bind(new DynamicTypeDeclarationBuilder(
+ const DynamicType(), loader.coreLibrary, -1));
}
@override
TypeBuilder visitVoidType(VoidType node) {
// 'void' is always nullable.
return new NamedTypeBuilder(
- "void", const NullabilityBuilder.nullable(), null)
- ..bind(new VoidTypeBuilder(const VoidType(), loader.coreLibrary, -1));
+ "void",
+ const NullabilityBuilder.nullable(),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null)
+ ..bind(new VoidTypeDeclarationBuilder(
+ const VoidType(), loader.coreLibrary, -1));
}
@override
@@ -83,8 +92,12 @@
@override
TypeBuilder visitNeverType(NeverType node) {
return new NamedTypeBuilder(
- "Never", new NullabilityBuilder.fromNullability(node.nullability), null)
- ..bind(new NeverTypeBuilder(node, loader.coreLibrary, -1));
+ "Never",
+ new NullabilityBuilder.fromNullability(node.nullability),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null)
+ ..bind(new NeverTypeDeclarationBuilder(node, loader.coreLibrary, -1));
}
@override
@@ -99,17 +112,25 @@
arguments[i] = kernelArguments[i].accept(this);
}
}
- return new NamedTypeBuilder(cls.name,
- new NullabilityBuilder.fromNullability(node.nullability), arguments)
+ return new NamedTypeBuilder(
+ cls.name,
+ new NullabilityBuilder.fromNullability(node.nullability),
+ arguments,
+ /* fileUri = */ null,
+ /* charOffset = */ null)
..bind(cls);
}
@override
TypeBuilder visitFutureOrType(FutureOrType node) {
TypeBuilder argument = node.typeArgument.accept(this);
- return new NamedTypeBuilder("FutureOr",
- new NullabilityBuilder.fromNullability(node.nullability), [argument])
- ..bind(new FutureOrTypeBuilder(node, loader.coreLibrary, -1));
+ return new NamedTypeBuilder(
+ "FutureOr",
+ new NullabilityBuilder.fromNullability(node.nullability),
+ [argument],
+ /* fileUri = */ null,
+ /* charOffset = */ null)
+ ..bind(new FutureOrTypeDeclarationBuilder(node, loader.coreLibrary, -1));
}
@override
@@ -139,8 +160,13 @@
null, 0, type, parameter.name, null, -1, null)
..kind = FormalParameterKind.optionalNamed;
}
- return new FunctionTypeBuilder(returnType, typeVariables, formals,
- new NullabilityBuilder.fromNullability(node.nullability));
+ return new FunctionTypeBuilder(
+ returnType,
+ typeVariables,
+ formals,
+ new NullabilityBuilder.fromNullability(node.nullability),
+ /* fileUri = */ null,
+ /* charOffset = */ null);
}
TypeBuilder visitTypeParameterType(TypeParameterType node) {
@@ -153,8 +179,12 @@
kernelLibrary = kernelClassOrTypeDef.enclosingLibrary;
}
LibraryBuilder library = loader.builders[kernelLibrary.importUri];
- return new NamedTypeBuilder(parameter.name,
- new NullabilityBuilder.fromNullability(node.nullability), null)
+ return new NamedTypeBuilder(
+ parameter.name,
+ new NullabilityBuilder.fromNullability(node.nullability),
+ /* arguments = */ null,
+ /* fileUri = */ null,
+ /* charOffset = */ null)
..bind(new TypeVariableBuilder.fromKernel(parameter, library));
}
diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
index 5731350..f8b81ce 100644
--- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
@@ -673,7 +673,10 @@
supertype = supertypeConstraints.first;
} else {
supertype = new MixinApplicationBuilder(
- supertypeConstraints.first, supertypeConstraints.skip(1).toList());
+ supertypeConstraints.first,
+ supertypeConstraints.skip(1).toList(),
+ supertypeConstraints.first.fileUri,
+ supertypeConstraints.first.charOffset);
}
}
@@ -761,7 +764,9 @@
String documentationComment = getDocumentationComment(extensionKeyword);
Object onType = pop();
if (onType is ParserRecovery) {
- onType = new FixedTypeBuilder(const InvalidType());
+ ParserRecovery parserRecovery = onType;
+ onType = new FixedTypeBuilder(
+ const InvalidType(), uri, parserRecovery.charOffset);
}
List<TypeVariableBuilder> typeVariables = pop(NullValue.TypeVariables);
int nameOffset = pop();
@@ -822,6 +827,11 @@
// [BodyBuilder.finishFunction].
isAbstract = false;
}
+ if (returnType != null && !returnType.isVoidType) {
+ addProblem(messageNonVoidReturnSetter, beginToken.charOffset, noLength);
+ // Use implicit void as recovery.
+ returnType = null;
+ }
}
int modifiers = pop();
modifiers = Modifier.addAbstractMask(modifiers, isAbstract: isAbstract);
@@ -1067,6 +1077,20 @@
// [BodyBuilder.finishFunction].
isAbstract = false;
}
+ if (returnType != null && !returnType.isVoidType) {
+ addProblem(messageNonVoidReturnSetter,
+ returnType.charOffset ?? beginToken.charOffset, noLength);
+ // Use implicit void as recovery.
+ returnType = null;
+ }
+ }
+ if (nameOrOperator == Operator.indexSet &&
+ returnType != null &&
+ !returnType.isVoidType) {
+ addProblem(messageNonVoidReturnOperator,
+ returnType.charOffset ?? beginToken.offset, noLength);
+ // Use implicit void as recovery.
+ returnType = null;
}
int modifiers = Modifier.toMask(pop());
modifiers = Modifier.addAbstractMask(modifiers, isAbstract: isAbstract);
@@ -1148,9 +1172,8 @@
modifiers &= ~constMask;
}
if (returnType != null) {
- // TODO(danrubel): Report this error on the return type
- handleRecoverableError(
- messageConstructorWithReturnType, beginToken, beginToken);
+ addProblem(messageConstructorWithReturnType,
+ returnType.charOffset ?? beginToken.offset, noLength);
returnType = null;
}
final int startCharOffset =
diff --git a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
index 7418ddc..53b4d1b 100644
--- a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
@@ -308,7 +308,11 @@
}
if (message != null) {
return new NamedTypeBuilder(
- supertype.name, const NullabilityBuilder.omitted(), null)
+ supertype.name,
+ const NullabilityBuilder.omitted(),
+ /* arguments = */ null,
+ fileUri,
+ charOffset)
..bind(new InvalidTypeDeclarationBuilder(supertype.name,
message.withLocation(fileUri, charOffset, noLength)));
}
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index e471194..08bf137 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -76,11 +76,11 @@
import '../../base/nnbd_mode.dart';
import '../builder/builder.dart';
-import '../builder/builtin_type_builder.dart';
+import '../builder/builtin_type_declaration_builder.dart';
import '../builder/class_builder.dart';
import '../builder/constructor_builder.dart';
import '../builder/constructor_reference_builder.dart';
-import '../builder/dynamic_type_builder.dart';
+import '../builder/dynamic_type_declaration_builder.dart';
import '../builder/enum_builder.dart';
import '../builder/extension_builder.dart';
import '../builder/field_builder.dart';
@@ -94,7 +94,7 @@
import '../builder/mixin_application_builder.dart';
import '../builder/name_iterator.dart';
import '../builder/named_type_builder.dart';
-import '../builder/never_type_builder.dart';
+import '../builder/never_type_declaration_builder.dart';
import '../builder/nullability_builder.dart';
import '../builder/prefix_builder.dart';
import '../builder/procedure_builder.dart';
@@ -103,7 +103,7 @@
import '../builder/type_declaration_builder.dart';
import '../builder/type_variable_builder.dart';
import '../builder/unresolved_type.dart';
-import '../builder/void_type_builder.dart';
+import '../builder/void_type_declaration_builder.dart';
import '../combinator.dart' show Combinator;
@@ -1324,14 +1324,14 @@
Uri get importUri => library.importUri;
void addSyntheticDeclarationOfDynamic() {
- addBuilder(
- "dynamic", new DynamicTypeBuilder(const DynamicType(), this, -1), -1);
+ addBuilder("dynamic",
+ new DynamicTypeDeclarationBuilder(const DynamicType(), this, -1), -1);
}
void addSyntheticDeclarationOfNever() {
addBuilder(
"Never",
- new NeverTypeBuilder(
+ new NeverTypeDeclarationBuilder(
const NeverType(Nullability.nonNullable), this, -1),
-1);
}
@@ -1346,14 +1346,17 @@
TypeBuilder addMixinApplication(
TypeBuilder supertype, List<TypeBuilder> mixins, int charOffset) {
- return addType(new MixinApplicationBuilder(supertype, mixins), charOffset);
+ return addType(
+ new MixinApplicationBuilder(supertype, mixins, fileUri, charOffset),
+ charOffset);
}
TypeBuilder addVoidType(int charOffset) {
// 'void' is always nullable.
return addNamedType(
"void", const NullabilityBuilder.nullable(), null, charOffset)
- ..bind(new VoidTypeBuilder(const VoidType(), this, charOffset));
+ ..bind(
+ new VoidTypeDeclarationBuilder(const VoidType(), this, charOffset));
}
/// Add a problem that might not be reported immediately.
@@ -2404,8 +2407,8 @@
List<FormalParameterBuilder> formals,
NullabilityBuilder nullabilityBuilder,
int charOffset) {
- FunctionTypeBuilder builder = new FunctionTypeBuilder(
- returnType, typeVariables, formals, nullabilityBuilder);
+ FunctionTypeBuilder builder = new FunctionTypeBuilder(returnType,
+ typeVariables, formals, nullabilityBuilder, fileUri, charOffset);
checkTypeVariables(typeVariables, null);
// Nested declaration began in `OutlineBuilder.beginFunctionType` or
// `OutlineBuilder.beginFunctionTypedFormalParameter`.
@@ -2497,7 +2500,7 @@
} else if (declaration is PrefixBuilder) {
// Ignored. Kernel doesn't represent prefixes.
return;
- } else if (declaration is BuiltinTypeBuilder) {
+ } else if (declaration is BuiltinTypeDeclarationBuilder) {
// Nothing needed.
return;
} else {
@@ -2929,8 +2932,8 @@
assert(
declaration is FieldBuilder ||
declaration is PrefixBuilder ||
- declaration is DynamicTypeBuilder ||
- declaration is NeverTypeBuilder,
+ declaration is DynamicTypeDeclarationBuilder ||
+ declaration is NeverTypeDeclarationBuilder,
"Unexpected top level member $declaration "
"(${declaration.runtimeType}).");
}
diff --git a/pkg/front_end/lib/src/fasta/source/value_kinds.dart b/pkg/front_end/lib/src/fasta/source/value_kinds.dart
index b7d80dc..c16e23d 100644
--- a/pkg/front_end/lib/src/fasta/source/value_kinds.dart
+++ b/pkg/front_end/lib/src/fasta/source/value_kinds.dart
@@ -15,10 +15,10 @@
import 'package:kernel/ast.dart' as type;
import '../builder/builder.dart' as type;
-import '../builder/builtin_type_builder.dart' as type;
+import '../builder/builtin_type_declaration_builder.dart' as type;
import '../builder/class_builder.dart' as type;
import '../builder/constructor_reference_builder.dart' as type;
-import '../builder/dynamic_type_builder.dart' as type;
+import '../builder/dynamic_type_declaration_builder.dart' as type;
import '../builder/enum_builder.dart' as type;
import '../builder/field_builder.dart' as type;
import '../builder/formal_parameter_builder.dart' as type;
@@ -39,7 +39,7 @@
import '../builder/type_declaration_builder.dart' as type;
import '../builder/type_variable_builder.dart' as type;
import '../builder/unresolved_type.dart' as type;
-import '../builder/void_type_builder.dart' as type;
+import '../builder/void_type_declaration_builder.dart' as type;
import '../identifiers.dart' as type;
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index 04dd919..b3ccbbe 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -4240,3 +4240,19 @@
main() {
Object = String;
}
+
+NonVoidReturnOperator:
+ template: "The return type of the operator []= must be 'void'."
+ tip: "Try changing the return type to 'void'."
+ analyzerCode: NON_VOID_RETURN_FOR_OPERATOR
+ script:
+ - class Class { int operator[]=(a, b) {} }
+ - class Class { dynamic operator[]=(a, b) {} }
+
+NonVoidReturnSetter:
+ template: "The return type of the setter must be 'void' or absent."
+ tip: "Try removing the return type, or define a method rather than a setter."
+ analyzerCode: NON_VOID_RETURN_FOR_SETTER
+ script:
+ - int set setter(_) {}
+ - dynamic set setter(_) {}
diff --git a/pkg/front_end/testcases/general/invalid_setter_return_type.dart b/pkg/front_end/testcases/general/invalid_setter_return_type.dart
new file mode 100644
index 0000000..7bf0d86
--- /dev/null
+++ b/pkg/front_end/testcases/general/invalid_setter_return_type.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+int set setter1(_) {} // error
+dynamic set setter2(_) {} // error
+void set setter3(_) {} // ok
+set setter4(_) {} // ok
+
+class Class1 {
+ int set setter1(_) {} // error
+ int operator []=(a, b) {} // error
+}
+
+class Class2 {
+ dynamic set setter2(_) {} // error
+ dynamic operator []=(a, b) {} // error
+}
+
+class Class3 {
+ void set setter3(_) {} // ok
+ void operator []=(a, b) {} // ok
+}
+
+class Class4 {
+ set setter4(_) {} // ok
+ operator []=(a, b) {} // ok
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/invalid_setter_return_type.dart.outline.expect b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.outline.expect
new file mode 100644
index 0000000..fa52301
--- /dev/null
+++ b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.outline.expect
@@ -0,0 +1,119 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:5:1: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// int set setter1(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:6:1: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// dynamic set setter2(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:11:3: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// int set setter1(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:12:3: Error: The return type of the operator []= must be 'void'.
+// Try changing the return type to 'void'.
+// int operator []=(a, b) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:16:3: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// dynamic set setter2(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:17:3: Error: The return type of the operator []= must be 'void'.
+// Try changing the return type to 'void'.
+// dynamic operator []=(a, b) {} // error
+// ^
+//
+import self as self;
+import "dart:core" as core;
+
+class Class1 extends core::Object {
+ synthetic constructor •() → self::Class1*
+ ;
+ set setter1(dynamic _) → void
+ ;
+ operator []=(dynamic a, dynamic b) → void
+ ;
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class2 extends core::Object {
+ synthetic constructor •() → self::Class2*
+ ;
+ set setter2(dynamic _) → void
+ ;
+ operator []=(dynamic a, dynamic b) → void
+ ;
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class3 extends core::Object {
+ synthetic constructor •() → self::Class3*
+ ;
+ set setter3(dynamic _) → void
+ ;
+ operator []=(dynamic a, dynamic b) → void
+ ;
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class4 extends core::Object {
+ synthetic constructor •() → self::Class4*
+ ;
+ set setter4(dynamic _) → void
+ ;
+ operator []=(dynamic a, dynamic b) → void
+ ;
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+static set setter1(dynamic _) → void
+ ;
+static set setter2(dynamic _) → void
+ ;
+static set setter3(dynamic _) → void
+ ;
+static set setter4(dynamic _) → void
+ ;
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/general/invalid_setter_return_type.dart.strong.expect b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.strong.expect
new file mode 100644
index 0000000..096efed
--- /dev/null
+++ b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.strong.expect
@@ -0,0 +1,110 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:5:1: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// int set setter1(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:6:1: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// dynamic set setter2(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:11:3: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// int set setter1(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:12:3: Error: The return type of the operator []= must be 'void'.
+// Try changing the return type to 'void'.
+// int operator []=(a, b) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:16:3: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// dynamic set setter2(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:17:3: Error: The return type of the operator []= must be 'void'.
+// Try changing the return type to 'void'.
+// dynamic operator []=(a, b) {} // error
+// ^
+//
+import self as self;
+import "dart:core" as core;
+
+class Class1 extends core::Object {
+ synthetic constructor •() → self::Class1*
+ : super core::Object::•()
+ ;
+ set setter1(dynamic _) → void {}
+ operator []=(dynamic a, dynamic b) → void {}
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class2 extends core::Object {
+ synthetic constructor •() → self::Class2*
+ : super core::Object::•()
+ ;
+ set setter2(dynamic _) → void {}
+ operator []=(dynamic a, dynamic b) → void {}
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class3 extends core::Object {
+ synthetic constructor •() → self::Class3*
+ : super core::Object::•()
+ ;
+ set setter3(dynamic _) → void {}
+ operator []=(dynamic a, dynamic b) → void {}
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class4 extends core::Object {
+ synthetic constructor •() → self::Class4*
+ : super core::Object::•()
+ ;
+ set setter4(dynamic _) → void {}
+ operator []=(dynamic a, dynamic b) → void {}
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+static set setter1(dynamic _) → void {}
+static set setter2(dynamic _) → void {}
+static set setter3(dynamic _) → void {}
+static set setter4(dynamic _) → void {}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/invalid_setter_return_type.dart.strong.transformed.expect b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.strong.transformed.expect
new file mode 100644
index 0000000..096efed
--- /dev/null
+++ b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.strong.transformed.expect
@@ -0,0 +1,110 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:5:1: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// int set setter1(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:6:1: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// dynamic set setter2(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:11:3: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// int set setter1(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:12:3: Error: The return type of the operator []= must be 'void'.
+// Try changing the return type to 'void'.
+// int operator []=(a, b) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:16:3: Error: The return type of the setter must be 'void' or absent.
+// Try removing the return type, or define a method rather than a setter.
+// dynamic set setter2(_) {} // error
+// ^
+//
+// pkg/front_end/testcases/general/invalid_setter_return_type.dart:17:3: Error: The return type of the operator []= must be 'void'.
+// Try changing the return type to 'void'.
+// dynamic operator []=(a, b) {} // error
+// ^
+//
+import self as self;
+import "dart:core" as core;
+
+class Class1 extends core::Object {
+ synthetic constructor •() → self::Class1*
+ : super core::Object::•()
+ ;
+ set setter1(dynamic _) → void {}
+ operator []=(dynamic a, dynamic b) → void {}
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class2 extends core::Object {
+ synthetic constructor •() → self::Class2*
+ : super core::Object::•()
+ ;
+ set setter2(dynamic _) → void {}
+ operator []=(dynamic a, dynamic b) → void {}
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class3 extends core::Object {
+ synthetic constructor •() → self::Class3*
+ : super core::Object::•()
+ ;
+ set setter3(dynamic _) → void {}
+ operator []=(dynamic a, dynamic b) → void {}
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+class Class4 extends core::Object {
+ synthetic constructor •() → self::Class4*
+ : super core::Object::•()
+ ;
+ set setter4(dynamic _) → void {}
+ operator []=(dynamic a, dynamic b) → void {}
+ abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
+ abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
+ abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
+ abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
+ abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
+ abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
+ abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
+ abstract member-signature method toString() → core::String*; -> core::Object::toString
+ abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
+ abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
+}
+static set setter1(dynamic _) → void {}
+static set setter2(dynamic _) → void {}
+static set setter3(dynamic _) → void {}
+static set setter4(dynamic _) → void {}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/invalid_setter_return_type.dart.textual_outline.expect b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.textual_outline.expect
new file mode 100644
index 0000000..5009b26
--- /dev/null
+++ b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.textual_outline.expect
@@ -0,0 +1,26 @@
+int set setter1(_) {}
+dynamic set setter2(_) {}
+void set setter3(_) {}
+set setter4(_) {}
+
+class Class1 {
+ int set setter1(_) {}
+ int operator []=(a, b) {}
+}
+
+class Class2 {
+ dynamic set setter2(_) {}
+ dynamic operator []=(a, b) {}
+}
+
+class Class3 {
+ void set setter3(_) {}
+ void operator []=(a, b) {}
+}
+
+class Class4 {
+ set setter4(_) {}
+ operator []=(a, b) {}
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/invalid_setter_return_type.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..721e925
--- /dev/null
+++ b/pkg/front_end/testcases/general/invalid_setter_return_type.dart.textual_outline_modelled.expect
@@ -0,0 +1,25 @@
+class Class1 {
+ int operator []=(a, b) {}
+ int set setter1(_) {}
+}
+
+class Class2 {
+ dynamic operator []=(a, b) {}
+ dynamic set setter2(_) {}
+}
+
+class Class3 {
+ void operator []=(a, b) {}
+ void set setter3(_) {}
+}
+
+class Class4 {
+ operator []=(a, b) {}
+ set setter4(_) {}
+}
+
+dynamic set setter2(_) {}
+int set setter1(_) {}
+main() {}
+set setter4(_) {}
+void set setter3(_) {}
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart
index 47099c8..76224c4 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart
@@ -6,7 +6,7 @@
library test;
class C {
- dynamic operator []=(dynamic index, dynamic value) {}
+ operator []=(dynamic index, dynamic value) {}
}
abstract class I {
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.outline.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.outline.expect
index 0a778ace..cd6595c 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.outline.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.outline.expect
@@ -5,7 +5,7 @@
class C extends core::Object {
synthetic constructor •() → self::C*
;
- operator []=(dynamic index, dynamic value) → dynamic
+ operator []=(dynamic index, dynamic value) → void
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.strong.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.strong.expect
index 08a009b..d7facc2 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.strong.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.strong.expect
@@ -6,7 +6,7 @@
synthetic constructor •() → self::C*
: super core::Object::•()
;
- operator []=(dynamic index, dynamic value) → dynamic {}
+ operator []=(dynamic index, dynamic value) → void {}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.strong.transformed.expect
index 08a009b..d7facc2 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.strong.transformed.expect
@@ -6,7 +6,7 @@
synthetic constructor •() → self::C*
: super core::Object::•()
;
- operator []=(dynamic index, dynamic value) → dynamic {}
+ operator []=(dynamic index, dynamic value) → void {}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.textual_outline.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.textual_outline.expect
index 71f35b9..2eac7bf 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.textual_outline.expect
@@ -1,7 +1,7 @@
library test;
class C {
- dynamic operator []=(dynamic index, dynamic value) {}
+ operator []=(dynamic index, dynamic value) {}
}
abstract class I {
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.textual_outline_modelled.expect
index d950bce..04312eb 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type.dart.textual_outline_modelled.expect
@@ -5,7 +5,7 @@
}
class C {
- dynamic operator []=(dynamic index, dynamic value) {}
+ operator []=(dynamic index, dynamic value) {}
}
class D extends C implements I {
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart
index 84362ad..8ca0f2e 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart
@@ -6,7 +6,7 @@
library test;
class C {
- dynamic operator []=(int index, dynamic value) {}
+ operator []=(int index, dynamic value) {}
}
abstract class I {
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.outline.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.outline.expect
index 4d3da34..13c3679 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.outline.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.outline.expect
@@ -5,7 +5,7 @@
class C extends core::Object {
synthetic constructor •() → self::C*
;
- operator []=(core::int* index, dynamic value) → dynamic
+ operator []=(core::int* index, dynamic value) → void
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.strong.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.strong.expect
index 697545a..9cecf38 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.strong.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.strong.expect
@@ -6,7 +6,7 @@
synthetic constructor •() → self::C*
: super core::Object::•()
;
- operator []=(core::int* index, dynamic value) → dynamic {}
+ operator []=(core::int* index, dynamic value) → void {}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.strong.transformed.expect
index 697545a..9cecf38 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.strong.transformed.expect
@@ -6,7 +6,7 @@
synthetic constructor •() → self::C*
: super core::Object::•()
;
- operator []=(core::int* index, dynamic value) → dynamic {}
+ operator []=(core::int* index, dynamic value) → void {}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.textual_outline.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.textual_outline.expect
index 5b865ba..65369b6 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.textual_outline.expect
@@ -1,7 +1,7 @@
library test;
class C {
- dynamic operator []=(int index, dynamic value) {}
+ operator []=(int index, dynamic value) {}
}
abstract class I {
diff --git a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.textual_outline_modelled.expect
index 700f73a..7202539 100644
--- a/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/inference/index_assign_operator_return_type_2.dart.textual_outline_modelled.expect
@@ -5,7 +5,7 @@
}
class C {
- dynamic operator []=(int index, dynamic value) {}
+ operator []=(int index, dynamic value) {}
}
class D extends C implements I {
diff --git a/pkg/front_end/testcases/inference/setter_return_type.dart b/pkg/front_end/testcases/inference/setter_return_type.dart
index 7ea8bea..62c1657 100644
--- a/pkg/front_end/testcases/inference/setter_return_type.dart
+++ b/pkg/front_end/testcases/inference/setter_return_type.dart
@@ -6,7 +6,7 @@
library test;
class C {
- dynamic set x(int value) {}
+ set x(int value) {}
}
abstract class I {
diff --git a/pkg/front_end/testcases/inference/setter_return_type.dart.outline.expect b/pkg/front_end/testcases/inference/setter_return_type.dart.outline.expect
index 9c92f49..a846937 100644
--- a/pkg/front_end/testcases/inference/setter_return_type.dart.outline.expect
+++ b/pkg/front_end/testcases/inference/setter_return_type.dart.outline.expect
@@ -5,7 +5,7 @@
class C extends core::Object {
synthetic constructor •() → self::C*
;
- set x(core::int* value) → dynamic
+ set x(core::int* value) → void
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
diff --git a/pkg/front_end/testcases/inference/setter_return_type.dart.strong.expect b/pkg/front_end/testcases/inference/setter_return_type.dart.strong.expect
index 43b7fff..b816e0d 100644
--- a/pkg/front_end/testcases/inference/setter_return_type.dart.strong.expect
+++ b/pkg/front_end/testcases/inference/setter_return_type.dart.strong.expect
@@ -6,7 +6,7 @@
synthetic constructor •() → self::C*
: super core::Object::•()
;
- set x(core::int* value) → dynamic {}
+ set x(core::int* value) → void {}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
diff --git a/pkg/front_end/testcases/inference/setter_return_type.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/setter_return_type.dart.strong.transformed.expect
index 43b7fff..b816e0d 100644
--- a/pkg/front_end/testcases/inference/setter_return_type.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/setter_return_type.dart.strong.transformed.expect
@@ -6,7 +6,7 @@
synthetic constructor •() → self::C*
: super core::Object::•()
;
- set x(core::int* value) → dynamic {}
+ set x(core::int* value) → void {}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
diff --git a/pkg/front_end/testcases/inference/setter_return_type.dart.textual_outline.expect b/pkg/front_end/testcases/inference/setter_return_type.dart.textual_outline.expect
index f9485e8..9143a0a 100644
--- a/pkg/front_end/testcases/inference/setter_return_type.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/inference/setter_return_type.dart.textual_outline.expect
@@ -1,7 +1,7 @@
library test;
class C {
- dynamic set x(int value) {}
+ set x(int value) {}
}
abstract class I {
diff --git a/pkg/front_end/testcases/inference/setter_return_type.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/inference/setter_return_type.dart.textual_outline_modelled.expect
index 001950d..3f4534d 100644
--- a/pkg/front_end/testcases/inference/setter_return_type.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/inference/setter_return_type.dart.textual_outline_modelled.expect
@@ -5,7 +5,7 @@
}
class C {
- dynamic set x(int value) {}
+ set x(int value) {}
}
class D extends C implements I {
diff --git a/runtime/vm/datastream.h b/runtime/vm/datastream.h
index 6e0547b..a844493 100644
--- a/runtime/vm/datastream.h
+++ b/runtime/vm/datastream.h
@@ -15,13 +15,13 @@
namespace dart {
-// (S)LEB128 encodes 7 bits of data per byte (hence 128).
-static constexpr uint8_t kDataBitsPerByte = 7;
-static constexpr uint8_t kDataByteMask = (1 << kDataBitsPerByte) - 1;
-// If more data follows a given data byte, the high bit is set.
-static constexpr uint8_t kMoreDataMask = (1 << kDataBitsPerByte);
-// For SLEB128, the high bit in the data of the last byte is the sign bit.
-static constexpr uint8_t kSignMask = (1 << (kDataBitsPerByte - 1));
+static const int8_t kDataBitsPerByte = 7;
+static const int8_t kByteMask = (1 << kDataBitsPerByte) - 1;
+static const int8_t kMaxUnsignedDataPerByte = kByteMask;
+static const int8_t kMinDataPerByte = -(1 << (kDataBitsPerByte - 1));
+static const int8_t kMaxDataPerByte = (~kMinDataPerByte & kByteMask); // NOLINT
+static const uint8_t kEndByteMarker = (255 - kMaxDataPerByte);
+static const uint8_t kEndUnsignedByteMarker = (255 - kMaxUnsignedDataPerByte);
typedef uint8_t* (*ReAlloc)(uint8_t* ptr, intptr_t old_size, intptr_t new_size);
typedef void (*DeAlloc)(uint8_t* ptr);
@@ -50,19 +50,19 @@
template <typename T>
class Raw<2, T> {
public:
- static T Read(ReadStream* st) { return bit_cast<T>(st->Read16<int16_t>()); }
+ static T Read(ReadStream* st) { return bit_cast<T>(st->Read16()); }
};
template <typename T>
class Raw<4, T> {
public:
- static T Read(ReadStream* st) { return bit_cast<T>(st->Read32<int32_t>()); }
+ static T Read(ReadStream* st) { return bit_cast<T>(st->Read32()); }
};
template <typename T>
class Raw<8, T> {
public:
- static T Read(ReadStream* st) { return bit_cast<T>(st->Read64<int64_t>()); }
+ static T Read(ReadStream* st) { return bit_cast<T>(st->Read64()); }
};
// Reads 'len' bytes from the stream.
@@ -74,15 +74,9 @@
current_ += len;
}
- // Reads a value of type [T] assuming an encoding of LEB128 (whether or not
- // the type itself is unsigned).
template <typename T = intptr_t>
T ReadUnsigned() {
- if (std::is_unsigned<T>::value) {
- return ReadInternal<T>();
- } else {
- return bit_cast<T>(ReadUnsigned<typename std::make_unsigned<T>::type>());
- }
+ return Read<T>(kEndUnsignedByteMarker);
}
intptr_t Position() const { return current_ - buffer_; }
@@ -109,15 +103,9 @@
return (end_ - current_);
}
- // Reads a value of type [T] assuming an encoding of SLEB128 (whether or not
- // the type itself is signed).
template <typename T>
T Read() {
- if (std::is_signed<T>::value) {
- return ReadInternal<T>();
- } else {
- return bit_cast<T>(Read<typename std::make_signed<T>::type>());
- }
+ return Read<T>(kEndByteMarker);
}
uword ReadWordWith32BitReads() {
@@ -134,112 +122,179 @@
}
private:
+ uint16_t Read16() { return Read16(kEndByteMarker); }
+
+ uint32_t Read32() { return Read32(kEndByteMarker); }
+
+ uint64_t Read64() { return Read64(kEndByteMarker); }
+
template <typename T>
- T ReadInternal() {
+ T Read(uint8_t end_byte_marker) {
using Unsigned = typename std::make_unsigned<T>::type;
const uint8_t* c = current_;
- Unsigned r = 0;
+ ASSERT(c < end_);
+ Unsigned b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return b - end_byte_marker;
+ }
+ T r = 0;
uint8_t s = 0;
- uint8_t b;
do {
+ r |= static_cast<Unsigned>(b) << s;
+ s += kDataBitsPerByte;
ASSERT(c < end_);
b = *c++;
- r |= static_cast<Unsigned>(b & kDataByteMask) << s;
- s += kDataBitsPerByte;
- } while ((b & kMoreDataMask) != 0);
+ } while (b <= kMaxUnsignedDataPerByte);
current_ = c;
- // At this point, [s] contains how many data bits have made it into the
- // value. If the type is signed, the value negative, and the count of data
- // bits is less than the size of the value, then we need to extend the sign
- // by setting the remaining (unset) most significant bits (MSBs).
- Unsigned sign_bits = 0;
- const bool is_signed = std::is_signed<T>::value;
- if (is_signed && (b & kSignMask) != 0 && s < (kBitsPerByte * sizeof(T))) {
- // Create a bitmask for the current data bits and invert it.
- sign_bits = ~((static_cast<Unsigned>(1) << s) - 1);
+ return r | (static_cast<Unsigned>(b - end_byte_marker) << s);
+ }
+
+ uint16_t Read16(uint8_t end_byte_marker) {
+ const uint8_t* c = current_;
+ ASSERT(c < end_);
+ uint16_t b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return b - end_byte_marker;
}
- return static_cast<T>(r | sign_bits);
+ uint16_t r = b;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint16_t>(b - end_byte_marker) << 7);
+ }
+
+ r |= b << 7;
+ ASSERT(c < end_);
+ b = *c++;
+ ASSERT(b > kMaxUnsignedDataPerByte);
+ current_ = c;
+ return r | (static_cast<uint16_t>(b - end_byte_marker) << 14);
}
-// Setting up needed variables for the unrolled loop sections below.
-#define UNROLLED_INIT() \
- using Unsigned = typename std::make_unsigned<T>::type; \
- const uint8_t* c = current_; \
- uint8_t b; \
- Unsigned r = 0;
+ uint32_t Read32(uint8_t end_byte_marker) {
+ const uint8_t* c = current_;
+ ASSERT(c < end_);
+ uint32_t b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return b - end_byte_marker;
+ }
-// Part of the unrolled loop where the loop may stop, having read the last part,
-// or continue reading. If stopping, extend the sign for signed values.
-#define UNROLLED_BODY(bit_start) \
- static_assert(bit_start % kDataBitsPerByte == 0, \
- "Bit start must be a multiple of the data bits per byte"); \
- static_assert(bit_start >= 0 && bit_start < kBitsPerByte * sizeof(T), \
- "Starting unrolled body at invalid bit position"); \
- ASSERT(c < end_); \
- b = *c++; \
- r |= static_cast<Unsigned>(b & kDataByteMask) << bit_start; \
- if ((b & kMoreDataMask) == 0) { \
- current_ = c; \
- Unsigned sign_bits = 0; \
- if (std::is_signed<T>::value && (b & kSignMask) != 0) { \
- sign_bits = ~((static_cast<Unsigned>(1) << (bit_start + 7)) - 1); \
- } \
- return static_cast<T>(r | sign_bits); \
+ uint32_t r = b;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint32_t>(b - end_byte_marker) << 7);
+ }
+
+ r |= b << 7;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint32_t>(b - end_byte_marker) << 14);
+ }
+
+ r |= b << 14;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint32_t>(b - end_byte_marker) << 21);
+ }
+
+ r |= b << 21;
+ ASSERT(c < end_);
+ b = *c++;
+ ASSERT(b > kMaxUnsignedDataPerByte);
+ current_ = c;
+ return r | (static_cast<uint32_t>(b - end_byte_marker) << 28);
}
-// If the unrolled end is reached, the last part always includes the original
-// sign bit, so no need to sign extend.
-#define UNROLLED_END(bit_start) \
- static_assert(bit_start % kDataBitsPerByte == 0, \
- "Bit start must be a multiple of the data bits per byte"); \
- static_assert(bit_start >= 0 && bit_start < kBitsPerByte * sizeof(T), \
- "Starting unrolled end at invalid bit position"); \
- static_assert(bit_start + kDataBitsPerByte >= kBitsPerByte * sizeof(T), \
- "Unrolled end does not contain final bits in value"); \
- ASSERT(c < end_); \
- b = *c++; \
- r |= static_cast<Unsigned>(b & kDataByteMask) << bit_start; \
- ASSERT_EQUAL((b & kMoreDataMask), 0); \
- current_ = c; \
- return static_cast<T>(r);
+ uint64_t Read64(uint8_t end_byte_marker) {
+ const uint8_t* c = current_;
+ ASSERT(c < end_);
+ uint64_t b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return b - end_byte_marker;
+ }
+ uint64_t r = b;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 7);
+ }
- template <typename T>
- T Read16() {
- UNROLLED_INIT();
- UNROLLED_BODY(0);
- UNROLLED_BODY(7);
- UNROLLED_END(14);
+ r |= b << 7;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 14);
+ }
+
+ r |= b << 14;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 21);
+ }
+
+ r |= b << 21;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 28);
+ }
+
+ r |= b << 28;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 35);
+ }
+
+ r |= b << 35;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 42);
+ }
+
+ r |= b << 42;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 49);
+ }
+
+ r |= b << 49;
+ ASSERT(c < end_);
+ b = *c++;
+ if (b > kMaxUnsignedDataPerByte) {
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 56);
+ }
+
+ r |= b << 56;
+ ASSERT(c < end_);
+ b = *c++;
+ ASSERT(b > kMaxUnsignedDataPerByte);
+ current_ = c;
+ return r | (static_cast<uint64_t>(b - end_byte_marker) << 63);
}
- template <typename T>
- T Read32() {
- UNROLLED_INIT();
- UNROLLED_BODY(0);
- UNROLLED_BODY(7);
- UNROLLED_BODY(14);
- UNROLLED_BODY(21);
- UNROLLED_END(28);
- }
-
- template <typename T>
- T Read64() {
- UNROLLED_INIT();
- UNROLLED_BODY(0);
- UNROLLED_BODY(7);
- UNROLLED_BODY(14);
- UNROLLED_BODY(21);
- UNROLLED_BODY(28);
- UNROLLED_BODY(35);
- UNROLLED_BODY(42);
- UNROLLED_BODY(49);
- UNROLLED_BODY(56);
- UNROLLED_END(63);
- }
-
-#undef UNROLLED_END
-#undef UNROLLED_BODY
-#undef UNROLLED_INIT
-
uint8_t ReadByte() {
ASSERT(current_ < end_);
return *current_++;
@@ -295,7 +350,7 @@
class Raw<1, T> {
public:
static void Write(WriteStream* st, T value) {
- st->WriteByte(bit_cast<uint8_t>(value));
+ st->WriteByte(bit_cast<int8_t>(value));
}
};
@@ -335,17 +390,14 @@
}
}
- // Writes the LEB128 encoding of [value] to the stream (whether or not the
- // type [T] is unsigned).
template <typename T>
void WriteUnsigned(T value) {
ASSERT(value >= 0);
- if (std::is_unsigned<T>::value) {
- WriteInternal<T>(value);
- } else {
- using Unsigned = typename std::make_unsigned<T>::type;
- WriteUnsigned<Unsigned>(bit_cast<Unsigned>(value));
+ while (value > kMaxUnsignedDataPerByte) {
+ WriteByte(static_cast<uint8_t>(value & kByteMask));
+ value = value >> kDataBitsPerByte;
}
+ WriteByte(static_cast<uint8_t>(value + kEndUnsignedByteMarker));
}
void WriteBytes(const void* addr, intptr_t len) {
@@ -413,16 +465,14 @@
current_ += len; // Not len + 1 to swallow the terminating NUL.
}
- // Writes the SLEB128 encoding of [value] to the stream (whether or not the
- // type [T] is signed).
template <typename T>
void Write(T value) {
- if (std::is_signed<T>::value) {
- WriteInternal<T>(value);
- } else {
- using Signed = typename std::make_signed<T>::type;
- Write<Signed>(bit_cast<Signed>(value));
+ T v = value;
+ while (v < kMinDataPerByte || v > kMaxDataPerByte) {
+ WriteByte(static_cast<uint8_t>(v & kByteMask));
+ v = v >> kDataBitsPerByte;
}
+ WriteByte(static_cast<uint8_t>(v + kEndByteMarker));
}
template <typename T>
@@ -437,33 +487,6 @@
}
private:
- template <typename T>
- void WriteInternal(T value) {
- T remainder = value;
- bool is_last_part;
- do {
- uint8_t part = static_cast<uint8_t>(remainder & kDataByteMask);
- remainder >>= kDataBitsPerByte;
- // For unsigned types, we're done when the remainder has no bits set.
- // For signed types, we're done when either:
- // - the remainder has no bits set and the part's sign bit is unset, or
- // - the remainder has all bits set and the part's sign bit is set.
- // If the remainder matches but the sign bit does not, we need one more
- // part to set the sign bit correctly.
- is_last_part =
- std::is_unsigned<T>::value
- ? remainder == static_cast<T>(0)
- : (remainder == static_cast<T>(0) && (part & kSignMask) == 0) ||
- (remainder == ~static_cast<T>(0) &&
- (part & kSignMask) != 0);
- if (!is_last_part) {
- // Mark this part as having more parts following it.
- part |= kMoreDataMask;
- }
- WriteByte(part);
- } while (!is_last_part);
- }
-
DART_FORCE_INLINE void WriteByte(uint8_t value) {
if (current_ >= end_) {
Resize(1);
@@ -491,6 +514,7 @@
ASSERT(end_ > *buffer_);
}
+ private:
uint8_t** const buffer_;
uint8_t* end_;
uint8_t* current_;
diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc
index cce2eac..606ef61 100644
--- a/runtime/vm/elf.cc
+++ b/runtime/vm/elf.cc
@@ -962,8 +962,35 @@
stream_(ASSERT_NOTNULL(stream)),
address_map_(address_map) {}
- void sleb128(intptr_t value) { stream_->Write(value); }
- void uleb128(uintptr_t value) { stream_->WriteUnsigned(value); }
+ void sleb128(intptr_t value) {
+ bool is_last_part = false;
+ while (!is_last_part) {
+ uint8_t part = value & 0x7F;
+ value >>= 7;
+ if ((value == 0 && (part & 0x40) == 0) ||
+ (value == static_cast<intptr_t>(-1) && (part & 0x40) != 0)) {
+ is_last_part = true;
+ } else {
+ part |= 0x80;
+ }
+ stream_->WriteFixed(part);
+ }
+ }
+
+ void uleb128(uintptr_t value) {
+ bool is_last_part = false;
+ while (!is_last_part) {
+ uint8_t part = value & 0x7F;
+ value >>= 7;
+ if (value == 0) {
+ is_last_part = true;
+ } else {
+ part |= 0x80;
+ }
+ stream_->WriteFixed(part);
+ }
+ }
+
void u1(uint8_t value) { stream_->WriteFixed(value); }
// Can't use WriteFixed for these, as we may not be at aligned positions.
void u2(uint16_t value) { stream_->WriteBytes(&value, sizeof(value)); }
diff --git a/tests/ffi_2/function_very_many_test.dart b/tests/ffi_2/function_very_many_test.dart
new file mode 100644
index 0000000..8056617
--- /dev/null
+++ b/tests/ffi_2/function_very_many_test.dart
@@ -0,0 +1,299 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+// Dart test program for testing dart:ffi calls argument passing.
+//
+// VMOptions=
+// VMOptions=--deterministic --optimization-counter-threshold=10
+// VMOptions=--use-slow-path
+// VMOptions=--use-slow-path --stacktrace-every=100
+// VMOptions=--write-protect-code --no-dual-map-code
+// VMOptions=--write-protect-code --no-dual-map-code --use-slow-path
+// VMOptions=--write-protect-code --no-dual-map-code --stacktrace-every=100
+// SharedObjects=ffi_test_functions
+
+import 'dart:ffi';
+
+import 'dylib_utils.dart';
+
+import "package:expect/expect.dart";
+
+void main() {
+ for (int i = 0; i < 100; ++i) {
+ testSumVeryManySmallInts();
+ testSumVeryManyFloatsDoubles();
+ }
+}
+
+final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
+
+VeryManyIntsOp sumVeryManySmallInts =
+ ffiTestFunctions.lookupFunction<NativeVeryManyIntsOp, VeryManyIntsOp>(
+ "SumVeryManySmallInts");
+// Very many small integers, tests alignment on stack.
+void testSumVeryManySmallInts() {
+ Expect.equals(
+ 40 * 41 / 2,
+ sumVeryManySmallInts(
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12,
+ 13,
+ 14,
+ 15,
+ 16,
+ 17,
+ 18,
+ 19,
+ 20,
+ 21,
+ 22,
+ 23,
+ 24,
+ 25,
+ 26,
+ 27,
+ 28,
+ 29,
+ 30,
+ 31,
+ 32,
+ 33,
+ 34,
+ 35,
+ 36,
+ 37,
+ 38,
+ 39,
+ 40));
+}
+
+VeryManyFloatsDoublesOp sumVeryManyFloatsDoubles = ffiTestFunctions
+ .lookupFunction<NativeVeryManyFloatsDoublesOp, VeryManyFloatsDoublesOp>(
+ "SumVeryManyFloatsDoubles");
+
+// Very many floating points, tests alignment on stack, and packing in
+// floating point registers in hardfp.
+void testSumVeryManyFloatsDoubles() {
+ Expect.approxEquals(
+ 40.0 * 41.0 / 2.0,
+ sumVeryManyFloatsDoubles(
+ 1.0,
+ 2.0,
+ 3.0,
+ 4.0,
+ 5.0,
+ 6.0,
+ 7.0,
+ 8.0,
+ 9.0,
+ 10.0,
+ 11.0,
+ 12.0,
+ 13.0,
+ 14.0,
+ 15.0,
+ 16.0,
+ 17.0,
+ 18.0,
+ 19.0,
+ 20.0,
+ 21.0,
+ 22.0,
+ 23.0,
+ 24.0,
+ 25.0,
+ 26.0,
+ 27.0,
+ 28.0,
+ 29.0,
+ 30.0,
+ 31.0,
+ 32.0,
+ 33.0,
+ 34.0,
+ 35.0,
+ 36.0,
+ 37.0,
+ 38.0,
+ 39.0,
+ 40.0));
+}
+
+typedef NativeVeryManyIntsOp = Int16 Function(
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16,
+ Int8,
+ Int16);
+
+typedef VeryManyIntsOp = int Function(
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int,
+ int);
+
+typedef NativeVeryManyFloatsDoublesOp = Double Function(
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double,
+ Float,
+ Double);
+
+typedef VeryManyFloatsDoublesOp = double Function(
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double,
+ double);
diff --git a/tests/language/getter/syntax_get_set_syntax_test.dart b/tests/language/getter/syntax_get_set_syntax_test.dart
index dbeaa85..ec18cf9 100644
--- a/tests/language/getter/syntax_get_set_syntax_test.dart
+++ b/tests/language/getter/syntax_get_set_syntax_test.dart
@@ -142,6 +142,7 @@
List set d;
//^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
//^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
// ^
@@ -154,6 +155,7 @@
List? set e, f;
//^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
// ^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
// [cfe] A method declaration needs an explicit list of parameters.
@@ -190,6 +192,7 @@
List<int> set d;
//^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
//^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
// ^
@@ -202,6 +205,7 @@
List<int>? set e, f;
//^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
// ^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
// [cfe] A method declaration needs an explicit list of parameters.
diff --git a/tests/language/setter/setter3_test.dart b/tests/language/setter/setter3_test.dart
index 3dedec6..a8212e4 100644
--- a/tests/language/setter/setter3_test.dart
+++ b/tests/language/setter/setter3_test.dart
@@ -12,12 +12,13 @@
dynamic set baz(x) {}
//^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
bool set bob(x) {}
//^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
// ^^^
// [analyzer] COMPILE_TIME_ERROR.BODY_MIGHT_COMPLETE_NORMALLY
-// [cfe] A non-null value must be returned since the return type 'bool' doesn't allow null.
}
main() {
diff --git a/tests/language/unsorted/index_assign_operator_infer_return_type_test.dart b/tests/language/unsorted/index_assign_operator_infer_return_type_test.dart
index 357c281..1ce5912 100644
--- a/tests/language/unsorted/index_assign_operator_infer_return_type_test.dart
+++ b/tests/language/unsorted/index_assign_operator_infer_return_type_test.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
class C {
- dynamic operator []=(dynamic index, dynamic value) {}
+ operator []=(dynamic index, dynamic value) {}
}
abstract class I {
diff --git a/tests/language_2/getter/syntax_get_set_syntax_test.dart b/tests/language_2/getter/syntax_get_set_syntax_test.dart
index 9ccbab1..a275ea8 100644
--- a/tests/language_2/getter/syntax_get_set_syntax_test.dart
+++ b/tests/language_2/getter/syntax_get_set_syntax_test.dart
@@ -142,6 +142,7 @@
List set d;
//^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
//^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
// ^
@@ -154,6 +155,7 @@
List set e, f;
//^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
// ^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
// [cfe] A method declaration needs an explicit list of parameters.
@@ -190,6 +192,7 @@
List<int> set d;
//^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
//^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
// ^
@@ -202,6 +205,7 @@
List<int> set e, f;
//^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
// ^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
// [cfe] A method declaration needs an explicit list of parameters.
diff --git a/tests/language_2/setter/setter3_test.dart b/tests/language_2/setter/setter3_test.dart
index 194ae1c..59a6a7e 100644
--- a/tests/language_2/setter/setter3_test.dart
+++ b/tests/language_2/setter/setter3_test.dart
@@ -12,9 +12,11 @@
dynamic set baz(x) {}
//^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
bool set bob(x) {}
//^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
+// [cfe] The return type of the setter must be 'void' or absent.
}
main() {
diff --git a/tests/language_2/super/setter_test.dart b/tests/language_2/super/setter_test.dart
index f5be400..c2a9567 100644
--- a/tests/language_2/super/setter_test.dart
+++ b/tests/language_2/super/setter_test.dart
@@ -10,7 +10,8 @@
String value_;
String get value { return value_; }
- String set value(String newValue) { //# static warning
+ String //# 01: compile-time error
+ set value(String newValue) {
value_ = 'Base:$newValue';
}
}
@@ -19,7 +20,8 @@
class Derived extends Base {
Derived() : super() {}
- String set value(String newValue) { //# static warning
+ String //# 02: compile-time error
+ set value(String newValue) {
super.value = 'Derived:$newValue';
}
String get value { return super.value; }
diff --git a/tests/language_2/unsorted/index_assign_operator_infer_return_type_test.dart b/tests/language_2/unsorted/index_assign_operator_infer_return_type_test.dart
index 357c281..1ce5912 100644
--- a/tests/language_2/unsorted/index_assign_operator_infer_return_type_test.dart
+++ b/tests/language_2/unsorted/index_assign_operator_infer_return_type_test.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
class C {
- dynamic operator []=(dynamic index, dynamic value) {}
+ operator []=(dynamic index, dynamic value) {}
}
abstract class I {
diff --git a/tools/VERSION b/tools/VERSION
index 2eff400..193d231 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 10
PATCH 0
-PRERELEASE 88
+PRERELEASE 89
PRERELEASE_PATCH 0
\ No newline at end of file