Skip to content

Commit

Permalink
Version 3.2.0-29.0.dev
Browse files Browse the repository at this point in the history
Merge 95474f4 into dev
  • Loading branch information
Dart CI committed Aug 2, 2023
2 parents 87df1bb + 95474f4 commit d67c0e8
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 18 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ vars = {
"string_scanner_rev": "413b57a3b14fa273e8ed52578edfbe0446084795",
"sync_http_rev": "c3d6ad48ec997c56b7f076bc9f8b4134c4a9225c",
"term_glyph_rev": "423700a3c019dc67f93d2bd6578016a1402506f7",
"test_rev": "7f81deeac294a1120917aeaa35d5b670146c4529",
"test_rev": "92eb0f7c3df8f3f089eb3962b46d55b00cf0e51c",
"test_descriptor_rev": "36d8617fafccbe36dfcf74ad4921c61911a6a411",
"test_process_rev": "b360784a9149b15888aed8d7cf167bb46fe733d5",
"test_reflective_loader_rev": "0bfaad91ed308ce9da11b48395c8210d7542c16b",
Expand Down
7 changes: 1 addition & 6 deletions pkg/analyzer/lib/src/fasta/ast_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -675,12 +675,7 @@ class AstBuilder extends StackListener {
} else if (left is SimpleIdentifierImpl) {
fieldName = left;
} else {
// Recovery:
// Parser has reported invalid assignment.
var superExpression = left as SuperExpressionImpl;
fieldName = SimpleIdentifierImpl(
superExpression.superKeyword,
);
return null;
}
return ConstructorFieldInitializerImpl(
thisKeyword: thisKeyword,
Expand Down
6 changes: 4 additions & 2 deletions pkg/analyzer/test/generated/error_parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1522,8 +1522,10 @@ class Wrong<T> {
createParser("C() : super = 42;");
ClassMember member = parser.parseClassMember('C');
expectNotNullIfNoErrors(member);
listener.assertErrors(
[expectedError(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, 6, 5)]);
listener.assertErrors([
error(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, 6, 5),
error(ParserErrorCode.INVALID_INITIALIZER, 6, 10),
]);
}

void test_invalidConstructorSuperFieldAssignment() {
Expand Down
25 changes: 25 additions & 0 deletions pkg/analyzer/test/src/fasta/ast_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,31 @@ ConstructorDeclaration
''');
}

void test_constructor_initilizer_assignmentWithSuperCallAsTarget() {
var parseResult = parseStringWithErrors(r'''
class A {
A() : super() = 0;
}
''');
parseResult.assertErrors([
error(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, 18, 7),
error(ParserErrorCode.INVALID_INITIALIZER, 18, 11),
]);

var node = parseResult.findNode.constructor('A()');
assertParsedNodeText(node, r'''
ConstructorDeclaration
returnType: SimpleIdentifier
token: A
parameters: FormalParameterList
leftParenthesis: (
rightParenthesis: )
separator: :
body: EmptyFunctionBody
semicolon: ;
''');
}

void test_constructor_superParamAndSuperInitializer() {
var parseResult = parseStringWithErrors(r'''
abstract class A {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ClassHierarchyBuilder
getNodeFromClassBuilder(loader.computeClassBuilderFromTargetClass(cls));
}

ExtensionTypeHierarchyNode getNodeFromExtensionTypeBuilder(
ExtensionTypeHierarchyNode getNodeFromExtensionDeclarationTypeBuilder(
ExtensionTypeDeclarationBuilder extensionTypeBuilder) {
return extensionTypeNodes[extensionTypeBuilder.extensionTypeDeclaration] ??=
new ExtensionTypeHierarchyNodeBuilder(this, extensionTypeBuilder)
Expand All @@ -74,7 +74,7 @@ class ClassHierarchyBuilder
ExtensionTypeHierarchyNode getNodeFromExtensionType(
ExtensionTypeDeclaration extensionType) {
return extensionTypeNodes[extensionType] ??
getNodeFromExtensionTypeBuilder(loader
getNodeFromExtensionDeclarationTypeBuilder(loader
.computeExtensionTypeBuilderFromTargetExtensionType(extensionType));
}

Expand Down
21 changes: 21 additions & 0 deletions pkg/front_end/lib/src/testing/id_extractor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ abstract class DataExtractor<T> extends Visitor<void>
/// If `null` is returned, [cls] has no associated data.
T? computeClassValue(Id id, Class cls) => null;

/// Implement this to compute the data corresponding to
/// [extensionTypeDeclaration].
///
/// If `null` is returned, [extensionTypeDeclaration] has no associated data.
T? computeExtensionTypeDeclarationValue(
Id id, ExtensionTypeDeclaration extensionTypeDeclaration) =>
null;

/// Implement this to compute the data corresponding to [extension].
///
/// If `null` is returned, [extension] has no associated data.
Expand Down Expand Up @@ -81,6 +89,19 @@ abstract class DataExtractor<T> extends Visitor<void>
extension.fileUri, extension.fileOffset, id, value, extension);
}

void computeForExtensionTypeDeclaration(
ExtensionTypeDeclaration extensionTypeDeclaration) {
ClassId id = new ClassId(extensionTypeDeclaration.name);
T? value =
computeExtensionTypeDeclarationValue(id, extensionTypeDeclaration);
registerValue(
extensionTypeDeclaration.fileUri,
extensionTypeDeclaration.fileOffset,
id,
value,
extensionTypeDeclaration);
}

void computeForMember(Member member) {
MemberId id = computeMemberId(member);
T? value = computeMemberValue(id, member);
Expand Down
22 changes: 22 additions & 0 deletions pkg/front_end/lib/src/testing/id_testing_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ abstract class DataComputer<T> {
Map<Id, ActualData<T>> actualMap,
{bool? verbose}) {}

/// Function that computes a data mapping for [extensionTypeDeclaration].
///
/// Fills [actualMap] with the data.
void computeExtensionTypeDeclarationData(
TestResultData testResultData,
ExtensionTypeDeclaration extensionTypeDeclaration,
Map<Id, ActualData<T>> actualMap,
{bool? verbose}) {}

/// Function that computes a data mapping for [library].
///
/// Fills [actualMap] with the data.
Expand Down Expand Up @@ -474,6 +483,14 @@ Future<TestResult<T>> runTestForConfig<T>(MarkerOptions markerOptions,
verbose: verbose);
}

void processExtensionTypeDeclaration(
ExtensionTypeDeclaration extensionTypeDeclaration,
Map<Id, ActualData<T>> actualMap) {
dataComputer.computeExtensionTypeDeclarationData(
testResultData, extensionTypeDeclaration, actualMap,
verbose: verbose);
}

bool excludeLibrary(Library library) {
return forUserLibrariesOnly &&
(library.importUri.isScheme('dart') ||
Expand Down Expand Up @@ -501,6 +518,11 @@ Future<TestResult<T>> runTestForConfig<T>(MarkerOptions markerOptions,
for (Extension extension in library.extensions) {
processExtension(extension, actualMapFor(extension));
}
for (ExtensionTypeDeclaration extensionTypeDeclaration
in library.extensionTypeDeclarations) {
processExtensionTypeDeclaration(
extensionTypeDeclaration, actualMapFor(extensionTypeDeclaration));
}
}

List<Uri> globalLibraries = <Uri>[
Expand Down
40 changes: 38 additions & 2 deletions pkg/front_end/test/class_hierarchy/class_hierarchy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:io' show Directory, Platform;
import 'package:_fe_analyzer_shared/src/testing/features.dart';
import 'package:_fe_analyzer_shared/src/testing/id.dart';
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart';
import 'package:front_end/src/api_prototype/experimental_flags.dart';
import 'package:front_end/src/testing/id_testing_helper.dart';
import 'package:front_end/src/testing/id_testing_utils.dart';
import 'package:front_end/src/fasta/kernel/hierarchy/class_member.dart';
Expand All @@ -23,8 +24,12 @@ Future<void> main(List<String> args) async {
args: args,
createUriForFileName: createUriForFileName,
onFailure: onFailure,
runTest: runTestFor(
const ClassHierarchyDataComputer(), [cfeNonNullableConfig]));
runTest: runTestFor(const ClassHierarchyDataComputer(), [
const TestConfig(cfeWithNnbdMarker, 'cfe',
explicitExperimentalFlags: const {
ExperimentalFlag.inlineClass: true
})
]));
}

class ClassHierarchyDataComputer extends DataComputer<Features> {
Expand All @@ -49,6 +54,16 @@ class ClassHierarchyDataComputer extends DataComputer<Features> {
.computeForClass(cls);
}

@override
void computeExtensionTypeDeclarationData(
TestResultData testResultData,
ExtensionTypeDeclaration extensionTypeDeclaration,
Map<Id, ActualData<Features>> actualMap,
{bool? verbose}) {
new InheritanceDataExtractor(testResultData.compilerResult, actualMap)
.computeForExtensionTypeDeclaration(extensionTypeDeclaration);
}

@override
bool get supportsErrors => true;

Expand Down Expand Up @@ -85,6 +100,7 @@ class Tag {
static const String stubTarget = 'stubTarget';
static const String type = 'type';
static const String covariance = 'covariance';
static const String superExtensionTypes = 'superExtensionTypes';
}

class InheritanceDataExtractor extends CfeDataExtractor<Features> {
Expand Down Expand Up @@ -262,6 +278,26 @@ class InheritanceDataExtractor extends CfeDataExtractor<Features> {
}
return features;
}

@override
Features computeExtensionTypeDeclarationValue(
Id id, ExtensionTypeDeclaration node) {
Features features = new Features();
ExtensionTypeHierarchyNode extensionTypeDeclarationHierarchyNode =
_classHierarchyBuilder.getNodeFromExtensionType(node);
extensionTypeDeclarationHierarchyNode.superclasses
.forEach((Supertype supertype) {
features.addElement(Tag.superExtensionTypes, supertypeToText(supertype));
});
extensionTypeDeclarationHierarchyNode.superExtensionTypes
.forEach((ExtensionType superExtensionType) {
features.addElement(
Tag.superExtensionTypes,
typeToText(superExtensionType,
TypeRepresentation.analyzerNonNullableByDefault));
});
return features;
}
}

String classMemberName(ClassMember classMember) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2023, 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.

/*class: Class:
maxInheritancePath=1,
superclasses=[Object]
*/
class Class {}

extension type ExtensionType1(Class c) {}

/*class: ExtensionType2:superExtensionTypes=[
Class,
ExtensionType1,
Object]*/
extension type ExtensionType2(Class c) implements Class, ExtensionType1 {}
39 changes: 35 additions & 4 deletions runtime/vm/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4567,14 +4567,44 @@ static void AddVMMappings(JSONArray* rss_children) {
}

MallocGrowableArray<VMMapping> mappings(10);
char line[256];
char* line = nullptr;
size_t line_buffer_size = 0;
char path[256];
char property[32];
size_t start, end, size;
while (fgets(line, sizeof(line), fp) != nullptr) {
while (getline(&line, &line_buffer_size, fp) > 0) {
if (sscanf(line, "%zx-%zx", &start, &end) == 2) {
// Mapping line.
strncpy(path, strrchr(line, ' ') + 1, sizeof(path) - 1);
// Each line has the following format:
//
// start-end flags offset dev inode path
//
// We want to skip 4 fields and get to the last one (path).
// Note that we can't scan backwards because path might contain white
// space.
const intptr_t kPathFieldIndex = 5;

char* path_start = line;
intptr_t current_field = 0;
while (*path_start != '\0') {
// Field separator.
if (*path_start == ' ') {
// Skip to the first non-space.
while (*path_start == ' ') {
path_start++;
}
current_field++;
if (current_field == kPathFieldIndex) {
break;
}
continue;
}
path_start++;
}
if (current_field != kPathFieldIndex) {
continue; // Malformed input.
}

strncpy(path, path_start, sizeof(path) - 1);
int len = strlen(path);
if ((len > 0) && path[len - 1] == '\n') {
path[len - 1] = 0;
Expand Down Expand Up @@ -4611,6 +4641,7 @@ static void AddVMMappings(JSONArray* rss_children) {
}
}
fclose(fp);
free(line); // Free buffer allocated by getline.

for (intptr_t i = 0; i < mappings.length(); i++) {
JSONObject mapping(rss_children);
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 3
MINOR 2
PATCH 0
PRERELEASE 28
PRERELEASE 29
PRERELEASE_PATCH 0

0 comments on commit d67c0e8

Please sign in to comment.