Skip to content

Commit

Permalink
Version 3.5.0-230.0.dev
Browse files Browse the repository at this point in the history
Merge d91f05c into dev
  • Loading branch information
Dart CI committed Jun 6, 2024
2 parents 7df5ccd + d91f05c commit 23f41b7
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#
# Stats:
# - 42 "needsEvaluation"
# - 342 "needsFix"
# - 409 "hasFix"
# - 341 "needsFix"
# - 410 "hasFix"
# - 516 "noFix"

AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
Expand Down Expand Up @@ -2781,9 +2781,7 @@ ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER:
notes: |-
Remove the `external` keyword or remove the initializers.
ParserErrorCode.EXTERNAL_ENUM:
status: needsFix
notes: |-
Remove the `external` keyword.
status: hasFix
ParserErrorCode.EXTERNAL_FACTORY_REDIRECTION:
status: needsFix
notes: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,9 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
ParserErrorCode.EXTERNAL_CLASS: [
RemoveExtraModifier.new,
],
ParserErrorCode.EXTERNAL_ENUM: [
RemoveExtraModifier.new,
],
ParserErrorCode.EXTRANEOUS_MODIFIER: [
RemoveExtraModifier.new,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ class C {}
''');
}

Future<void> test_externalEnum() async {
await resolveTestCode(r'''
external enum E { o }
''');
await assertHasFix('''
enum E { o }
''');
}

Future<void> test_final_constructor() async {
await resolveTestCode('''
class C {
Expand Down
12 changes: 0 additions & 12 deletions pkg/analyzer/lib/src/summary2/ast_binary_tag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,6 @@ class Tag {
static const int VoidType = 12;
}

enum TypeAnnotationLocationKind {
aliasedType,
element,
extendsClause,
formalParameter,
listIndex,
recordNamedField,
recordPositionalField,
returnType,
variableType,
}

enum TypeParameterVarianceTag {
legacy,
unrelated,
Expand Down
50 changes: 5 additions & 45 deletions pkg/analyzer/lib/src/summary2/bundle_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import 'package:analyzer/src/summary2/export.dart';
import 'package:analyzer/src/summary2/informative_data.dart';
import 'package:analyzer/src/summary2/linked_element_factory.dart';
import 'package:analyzer/src/summary2/macro_application_error.dart';
import 'package:analyzer/src/summary2/macro_type_location.dart';
import 'package:analyzer/src/summary2/macro_type_location_storage.dart';
import 'package:analyzer/src/summary2/reference.dart';
import 'package:analyzer/src/task/inference_error.dart';
import 'package:analyzer/src/utilities/extensions/collection.dart';
Expand Down Expand Up @@ -2423,49 +2423,6 @@ class ResolutionReader {
MacroDiagnosticMessage _readMacroDiagnosticMessage() {
var message = _reader.readStringUtf8();

TypeAnnotationLocation readTypeAnnotationLocation() {
var kind = readEnum(TypeAnnotationLocationKind.values);
switch (kind) {
case TypeAnnotationLocationKind.aliasedType:
var parent = readTypeAnnotationLocation();
return AliasedTypeLocation(parent);
case TypeAnnotationLocationKind.element:
var element = readElement()!;
return ElementTypeLocation(element);
case TypeAnnotationLocationKind.extendsClause:
var parent = readTypeAnnotationLocation();
return ExtendsClauseTypeLocation(parent);
case TypeAnnotationLocationKind.formalParameter:
return FormalParameterTypeLocation(
readTypeAnnotationLocation(),
readUInt30(),
);
case TypeAnnotationLocationKind.listIndex:
return ListIndexTypeLocation(
readTypeAnnotationLocation(),
readUInt30(),
);
case TypeAnnotationLocationKind.recordNamedField:
return RecordNamedFieldTypeLocation(
readTypeAnnotationLocation(),
readUInt30(),
);
case TypeAnnotationLocationKind.recordPositionalField:
return RecordPositionalFieldTypeLocation(
readTypeAnnotationLocation(),
readUInt30(),
);
case TypeAnnotationLocationKind.returnType:
var parent = readTypeAnnotationLocation();
return ReturnTypeLocation(parent);
case TypeAnnotationLocationKind.variableType:
var parent = readTypeAnnotationLocation();
return VariableTypeLocation(parent);
default:
throw UnimplementedError('kind: $kind');
}
}

MacroDiagnosticTarget target;
var targetKind = readEnum(MacroDiagnosticTargetKind.values);
switch (targetKind) {
Expand All @@ -2485,7 +2442,10 @@ class ResolutionReader {
annotationIndex: readUInt30(),
);
case MacroDiagnosticTargetKind.type:
var location = readTypeAnnotationLocation();
var location = TypeAnnotationLocationReader(
reader: _reader,
readElement: readElement,
).read();
target = TypeAnnotationMacroDiagnosticTarget(location: location);
}

Expand Down
46 changes: 5 additions & 41 deletions pkg/analyzer/lib/src/summary2/bundle_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import 'package:analyzer/src/summary2/data_writer.dart';
import 'package:analyzer/src/summary2/element_flags.dart';
import 'package:analyzer/src/summary2/export.dart';
import 'package:analyzer/src/summary2/macro_application_error.dart';
import 'package:analyzer/src/summary2/macro_type_location.dart';
import 'package:analyzer/src/summary2/macro_type_location_storage.dart';
import 'package:analyzer/src/summary2/reference.dart';
import 'package:analyzer/src/task/inference_error.dart';

Expand Down Expand Up @@ -1024,45 +1024,6 @@ class ResolutionSink extends _SummaryDataWriter {
void _writeMacroDiagnosticMessage(MacroDiagnosticMessage object) {
writeStringUtf8(object.message);

void writeTypeAnnotationLocation(TypeAnnotationLocation location) {
switch (location) {
case AliasedTypeLocation():
writeEnum(TypeAnnotationLocationKind.aliasedType);
writeTypeAnnotationLocation(location.parent);
case ElementTypeLocation():
writeEnum(TypeAnnotationLocationKind.element);
writeElement(location.element);
case ExtendsClauseTypeLocation():
writeEnum(TypeAnnotationLocationKind.extendsClause);
writeTypeAnnotationLocation(location.parent);
case FormalParameterTypeLocation():
writeEnum(TypeAnnotationLocationKind.formalParameter);
writeTypeAnnotationLocation(location.parent);
writeUInt30(location.index);
case ListIndexTypeLocation():
writeEnum(TypeAnnotationLocationKind.listIndex);
writeTypeAnnotationLocation(location.parent);
writeUInt30(location.index);
case RecordNamedFieldTypeLocation():
writeEnum(TypeAnnotationLocationKind.recordNamedField);
writeTypeAnnotationLocation(location.parent);
writeUInt30(location.index);
case RecordPositionalFieldTypeLocation():
writeEnum(TypeAnnotationLocationKind.recordPositionalField);
writeTypeAnnotationLocation(location.parent);
writeUInt30(location.index);
case ReturnTypeLocation():
writeEnum(TypeAnnotationLocationKind.returnType);
writeTypeAnnotationLocation(location.parent);
case VariableTypeLocation():
writeEnum(TypeAnnotationLocationKind.variableType);
writeTypeAnnotationLocation(location.parent);
default:
// TODO(scheglov): Handle this case.
throw UnimplementedError('${location.runtimeType}');
}
}

var target = object.target;
switch (target) {
case ApplicationMacroDiagnosticTarget():
Expand All @@ -1077,7 +1038,10 @@ class ResolutionSink extends _SummaryDataWriter {
writeUInt30(target.annotationIndex);
case TypeAnnotationMacroDiagnosticTarget():
writeEnum(MacroDiagnosticTargetKind.type);
writeTypeAnnotationLocation(target.location);
TypeAnnotationLocationWriter(
sink: this,
writeElement: writeElement,
).write(target.location);
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/analyzer/lib/src/summary2/data_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ class BufferedSink {
}
}

/// Writes [items], converts to [List] first.
void writeIterable<T>(Iterable<T> items, void Function(T x) writeItem) {
writeList(items.toList(), writeItem);
}

void writeList<T>(List<T> items, void Function(T x) writeItem) {
writeUInt30(items.length);
for (var i = 0; i < items.length; i++) {
Expand Down
122 changes: 122 additions & 0 deletions pkg/analyzer/lib/src/summary2/macro_type_location_storage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/summary2/data_reader.dart';
import 'package:analyzer/src/summary2/data_writer.dart';
import 'package:analyzer/src/summary2/macro_type_location.dart';

class TypeAnnotationLocationReader {
final SummaryDataReader reader;
final Element? Function() readElement;

TypeAnnotationLocationReader({
required this.reader,
required this.readElement,
});

TypeAnnotationLocation read() {
var kind = reader.readEnum(_LocationKind.values);
switch (kind) {
case _LocationKind.aliasedType:
var parent = read();
return AliasedTypeLocation(parent);
case _LocationKind.element:
var element = readElement()!;
return ElementTypeLocation(element);
case _LocationKind.extendsClause:
var parent = read();
return ExtendsClauseTypeLocation(parent);
case _LocationKind.formalParameter:
return FormalParameterTypeLocation(
read(),
reader.readUInt30(),
);
case _LocationKind.listIndex:
return ListIndexTypeLocation(
read(),
reader.readUInt30(),
);
case _LocationKind.recordNamedField:
return RecordNamedFieldTypeLocation(
read(),
reader.readUInt30(),
);
case _LocationKind.recordPositionalField:
return RecordPositionalFieldTypeLocation(
read(),
reader.readUInt30(),
);
case _LocationKind.returnType:
var parent = read();
return ReturnTypeLocation(parent);
case _LocationKind.variableType:
var parent = read();
return VariableTypeLocation(parent);
default:
throw UnimplementedError('kind: $kind');
}
}
}

class TypeAnnotationLocationWriter {
final BufferedSink sink;
final void Function(Element element) writeElement;

TypeAnnotationLocationWriter({
required this.sink,
required this.writeElement,
});

void write(TypeAnnotationLocation location) {
switch (location) {
case AliasedTypeLocation():
sink.writeEnum(_LocationKind.aliasedType);
write(location.parent);
case ElementTypeLocation():
sink.writeEnum(_LocationKind.element);
writeElement(location.element);
case ExtendsClauseTypeLocation():
sink.writeEnum(_LocationKind.extendsClause);
write(location.parent);
case FormalParameterTypeLocation():
sink.writeEnum(_LocationKind.formalParameter);
write(location.parent);
sink.writeUInt30(location.index);
case ListIndexTypeLocation():
sink.writeEnum(_LocationKind.listIndex);
write(location.parent);
sink.writeUInt30(location.index);
case RecordNamedFieldTypeLocation():
sink.writeEnum(_LocationKind.recordNamedField);
write(location.parent);
sink.writeUInt30(location.index);
case RecordPositionalFieldTypeLocation():
sink.writeEnum(_LocationKind.recordPositionalField);
write(location.parent);
sink.writeUInt30(location.index);
case ReturnTypeLocation():
sink.writeEnum(_LocationKind.returnType);
write(location.parent);
case VariableTypeLocation():
sink.writeEnum(_LocationKind.variableType);
write(location.parent);
default:
// TODO(scheglov): Handle this case.
throw UnimplementedError('${location.runtimeType}');
}
}
}

enum _LocationKind {
aliasedType,
element,
extendsClause,
formalParameter,
listIndex,
recordNamedField,
recordPositionalField,
returnType,
variableType,
}
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 5
PATCH 0
PRERELEASE 229
PRERELEASE 230
PRERELEASE_PATCH 0

0 comments on commit 23f41b7

Please sign in to comment.