Skip to content

Commit

Permalink
Version 3.4.0-174.0.dev
Browse files Browse the repository at this point in the history
Merge 02614d8 into dev
  • Loading branch information
Dart CI committed Feb 24, 2024
2 parents e5e4aac + 02614d8 commit c591323
Show file tree
Hide file tree
Showing 14 changed files with 240 additions and 375 deletions.
13 changes: 8 additions & 5 deletions pkg/analyzer/lib/src/summary2/macro_application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1243,11 +1243,14 @@ class _TypePhaseIntrospector implements macro.TypePhaseIntrospector {
element = element.variable;
}
if (element == null) {
throw macro.MacroImplementationExceptionImpl([
'Unresolved identifier.',
'library: $library',
'name: $name',
].join('\n'));
throw macro.MacroImplementationExceptionImpl(
[
'Unresolved identifier.',
'library: $library',
'name: $name',
].join('\n'),
stackTrace: StackTrace.current.toString(),
);
}
return declarationBuilder.fromElement.identifier(element);
}
Expand Down
62 changes: 35 additions & 27 deletions pkg/analyzer/lib/src/summary2/macro_declarations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,18 @@ class DeclarationBuilder {
/// See [macro.DefinitionPhaseIntrospector.declarationOf].
macro.DeclarationImpl declarationOf(macro.Identifier identifier) {
if (identifier is! IdentifierImpl) {
throw macro.MacroImplementationExceptionImpl('Not analyzer identifier.');
throw macro.MacroImplementationExceptionImpl(
'Not analyzer identifier.',
stackTrace: StackTrace.current.toString(),
);
}

final element = identifier.element;
if (element == null) {
throw macro.MacroImplementationExceptionImpl(
'Identifier without element.');
'Identifier without element.',
stackTrace: StackTrace.current.toString(),
);
}

return declarationOfElement(element);
Expand Down Expand Up @@ -319,7 +324,10 @@ class DeclarationBuilder {
case macro.OmittedTypeAnnotationCode():
return _resolveTypeCodeOmitted(typeCode);
case macro.RawTypeAnnotationCode():
throw macro.MacroImplementationExceptionImpl('Not supported');
throw macro.MacroImplementationExceptionImpl(
'Not supported',
stackTrace: StackTrace.current.toString(),
);
case macro.RecordTypeAnnotationCode():
return _resolveTypeCodeRecord(typeCode);
}
Expand All @@ -328,13 +336,18 @@ class DeclarationBuilder {
/// See [macro.DeclarationPhaseIntrospector.typeDeclarationOf].
macro.TypeDeclarationImpl typeDeclarationOf(macro.Identifier identifier) {
if (identifier is! IdentifierImpl) {
throw macro.MacroImplementationExceptionImpl('Not analyzer identifier.');
throw macro.MacroImplementationExceptionImpl(
'Not analyzer identifier.',
stackTrace: StackTrace.current.toString(),
);
}

final element = identifier.element;
if (element == null) {
throw macro.MacroImplementationExceptionImpl(
'Identifier without element.');
'Identifier without element.',
stackTrace: StackTrace.current.toString(),
);
}

final node = nodeOfElement(element);
Expand Down Expand Up @@ -736,7 +749,9 @@ class DeclarationBuilderFromElement {
default:
// TODO(scheglov): other elements
throw macro.MacroImplementationExceptionImpl(
'element: (${element.runtimeType}) $element');
'element: (${element.runtimeType}) $element',
stackTrace: StackTrace.current.toString(),
);
}
}

Expand Down Expand Up @@ -1112,9 +1127,6 @@ class DeclarationBuilderFromNode {

final Map<Element, LibraryImpl> _libraryMap = Map.identity();

final Map<ast.GenericTypeAliasImpl, macro.TypeAliasDeclarationImpl>
_typeAliasDeclarationMap = Map.identity();

DeclarationBuilderFromNode(this.builder);

ClassDeclarationImpl classDeclaration(
Expand Down Expand Up @@ -1472,7 +1484,17 @@ class DeclarationBuilderFromNode {
macro.TypeAliasDeclarationImpl typeAliasDeclaration(
ast.GenericTypeAliasImpl node,
) {
return _typeAliasDeclarationMap[node] ??= _typeAliasDeclaration(node);
final element = node.declaredElement as TypeAliasElementImpl;

return TypeAliasDeclarationImpl._(
id: macro.RemoteInstance.uniqueId,
element: element,
identifier: _declaredIdentifier(node.name, element),
library: library(element),
metadata: _buildMetadata(element),
aliasedType: _typeAnnotationAliasedType(node),
typeParameters: _typeParameterDeclarations(node.typeParameters),
);
}

/// See [macro.DeclarationPhaseIntrospector.typeDeclarationOf].
Expand All @@ -1495,7 +1517,9 @@ class DeclarationBuilderFromNode {
default:
// TODO(scheglov): other nodes
throw macro.MacroImplementationExceptionImpl(
'node: (${node.runtimeType}) $node');
'node: (${node.runtimeType}) $node',
stackTrace: StackTrace.current.toString(),
);
}
}

Expand Down Expand Up @@ -1814,22 +1838,6 @@ class DeclarationBuilderFromNode {
}
}

macro.TypeAliasDeclarationImpl _typeAliasDeclaration(
ast.GenericTypeAliasImpl node,
) {
final element = node.declaredElement as TypeAliasElementImpl;

return TypeAliasDeclarationImpl._(
id: macro.RemoteInstance.uniqueId,
element: element,
identifier: _declaredIdentifier(node.name, element),
library: library(element),
metadata: _buildMetadata(element),
aliasedType: _typeAnnotationAliasedType(node),
typeParameters: _typeParameterDeclarations(node.typeParameters),
);
}

macro.TypeAnnotationImpl _typeAnnotation(
ast.TypeAnnotation node,
TypeAnnotationLocation location,
Expand Down
22 changes: 0 additions & 22 deletions pkg/analyzer/test/generated/elements_types_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -593,17 +593,6 @@ mixin ElementsTypesMixin {
);
}

TypeParameterTypeImpl promotedTypeParameterTypeStar(
TypeParameterElement element,
DartType promotedBound,
) {
return promotedTypeParameterType(
element: element,
nullabilitySuffix: NullabilitySuffix.star,
promotedBound: promotedBound,
);
}

RecordTypeImpl recordType({
List<DartType> positionalTypes = const [],
Map<String, DartType> namedTypes = const {},
Expand Down Expand Up @@ -736,17 +725,6 @@ mixin ElementsTypesMixin {
promotedBound: promotedBound,
);
}

TypeParameterTypeImpl typeParameterTypeStar(
TypeParameterElement element, {
DartType? promotedBound,
}) {
return typeParameterType(
element,
nullabilitySuffix: NullabilitySuffix.star,
promotedBound: promotedBound,
);
}
}

class _MockSource implements Source {
Expand Down
4 changes: 0 additions & 4 deletions pkg/analyzer/test/generated/type_system_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,12 @@ class TryPromoteToTest extends AbstractTypeSystemTest {
var T = typeParameter('T');
var T_none = typeParameterTypeNone(T);
var T_question = typeParameterTypeQuestion(T);
var T_star = typeParameterTypeStar(T);

check(tryPromote(numNone, T_none), 'T & num');
check(tryPromote(numQuestion, T_none), 'T & num?');

check(tryPromote(numNone, T_question), 'T & num');
check(tryPromote(numQuestion, T_question), '(T & num?)?');

check(tryPromote(numNone, T_star), '(T & num)*');
check(tryPromote(numQuestion, T_star), '(T & num?)*');
}

test_typeParameter_twice() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class HasTypeParameterReferenceTest extends AbstractTypeSystemTest {
var T = typeParameter('T');
_checkTrue(typeParameterTypeNone(T));
_checkTrue(typeParameterTypeQuestion(T));
_checkTrue(typeParameterTypeStar(T));
}

test_void() {
Expand Down
26 changes: 0 additions & 26 deletions pkg/analyzer/test/src/dart/element/nullable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,6 @@ class IsStrictlyNonNullableTest extends AbstractTypeSystemTest {
isNotStrictlyNonNullable(
typeParameterTypeQuestion(T),
);

isNotStrictlyNonNullable(
typeParameterTypeStar(T),
);
}

test_typeParameter_boundQuestion() {
Expand All @@ -566,10 +562,6 @@ class IsStrictlyNonNullableTest extends AbstractTypeSystemTest {
isNotStrictlyNonNullable(
typeParameterTypeQuestion(T),
);

isNotStrictlyNonNullable(
typeParameterTypeStar(T),
);
}

test_void() {
Expand Down Expand Up @@ -685,12 +677,6 @@ class PromoteToNonNullTest extends AbstractTypeSystemTest {
element: element,
promotedBound: intNone,
);

_checkTypeParameter(
typeParameterTypeStar(element),
element: element,
promotedBound: intNone,
);
}

test_typeParameter_promotedBound_none() {
Expand All @@ -707,12 +693,6 @@ class PromoteToNonNullTest extends AbstractTypeSystemTest {
element: element,
promotedBound: intNone,
);

_checkTypeParameter(
promotedTypeParameterTypeStar(element, intNone),
element: element,
promotedBound: intNone,
);
}

test_typeParameter_promotedBound_question() {
Expand All @@ -729,12 +709,6 @@ class PromoteToNonNullTest extends AbstractTypeSystemTest {
element: element,
promotedBound: intNone,
);

_checkTypeParameter(
promotedTypeParameterTypeStar(element, intQuestion),
element: element,
promotedBound: intNone,
);
}

test_void() {
Expand Down
Loading

0 comments on commit c591323

Please sign in to comment.