Skip to content

Commit

Permalink
Version 3.4.0-160.0.dev
Browse files Browse the repository at this point in the history
Merge 249895f into dev
  • Loading branch information
Dart CI committed Feb 21, 2024
2 parents a30222a + 249895f commit 0a77450
Show file tree
Hide file tree
Showing 70 changed files with 576 additions and 698 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ class DartLazyTypeHierarchyComputer {

var matches =
await searchEngine.searchSubtypes(target, SearchEngineCache());
return matches.map(toHierarchyItem).toList();
return matches
.where((match) => !(match.element as InterfaceElement).isAugmentation)
.map(toHierarchyItem)
.toList();
}

/// Gets immediate super types for the class/mixin [element].
Expand Down
50 changes: 50 additions & 0 deletions pkg/analysis_server/test/lsp/type_hierarchy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,31 @@ import 'main.dart';
]));
}

Future<void> test_augment_extends() async {
final content = '''
import augment 'other.dart';
class MyCl^ass1 {}
[!class /*[1*/C/*1]*/ {}!]
''';
final augmentation = '''
library augment 'main.dart';
augment class C extends MyClass1 {}
''';
await _fetchSubtypes(content, otherContent: augmentation);
expect(
subtypes,
equals([
_isItem(
'C',
mainFileUri,
range: code.ranges[0].range,
selectionRange: code.ranges[1].range,
),
]));
}

Future<void> test_extends() async {
final content = '''
class MyCla^ss1 {}
Expand Down Expand Up @@ -309,6 +334,31 @@ class MyCla^ss2 extends MyClass1 {}
]));
}

Future<void> test_augment_extends() async {
final content = '''
import augment 'other.dart';
[!class /*[1*/MyClass1/*1]*/ {}!]
class C^s {}
''';
final augmentation = '''
library augment 'main.dart';
augment class Cs extends MyClass1 {}
''';
await _fetchSupertypes(content, otherContent: augmentation);
expect(
supertypes,
equals([
_isItem(
'MyClass1',
mainFileUri,
range: code.ranges[0].range,
selectionRange: code.ranges[1].range,
),
]));
}

Future<void> test_extends() async {
final content = '''
/*[0*/class /*[1*/MyClass1/*1]*/ {}/*0]*/
Expand Down
2 changes: 0 additions & 2 deletions pkg/compiler/lib/src/constants/constant_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ ConstructedConstantValue createSymbol(
InterfaceType type = commonElements.symbolImplementationType;
FieldEntity field = commonElements.symbolField;
ConstantValue argument = createString(text);
// TODO(johnniwinther): Use type arguments when all uses no longer expect
// a [FieldElement].
var fields = <FieldEntity, ConstantValue>{field: argument};
return ConstructedConstantValue(type, fields);
}
Expand Down
29 changes: 6 additions & 23 deletions pkg/compiler/lib/src/elements/entities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,19 @@ abstract class FunctionEntity extends MemberEntity {
}

/// Enum for the synchronous/asynchronous function body modifiers.
class AsyncMarker {
enum AsyncMarker {
/// The default function body marker.
static const AsyncMarker SYNC = AsyncMarker._(AsyncModifier.Sync);
SYNC._(AsyncModifier.Sync),

/// The `sync*` function body marker.
static const AsyncMarker SYNC_STAR =
AsyncMarker._(AsyncModifier.SyncStar, isYielding: true);
SYNC_STAR._(AsyncModifier.SyncStar, isYielding: true),

/// The `async` function body marker.
static const AsyncMarker ASYNC =
AsyncMarker._(AsyncModifier.Async, isAsync: true);
ASYNC._(AsyncModifier.Async, isAsync: true),

/// The `async*` function body marker.
static const AsyncMarker ASYNC_STAR =
AsyncMarker._(AsyncModifier.AsyncStar, isAsync: true, isYielding: true);
ASYNC_STAR._(AsyncModifier.AsyncStar, isAsync: true, isYielding: true),
;

/// Is `true` if this marker defines the function body to have an
/// asynchronous result, that is, either a [Future] or a [Stream].
Expand All @@ -207,21 +205,6 @@ class AsyncMarker {
String toString() {
return '${isAsync ? 'async' : 'sync'}${isYielding ? '*' : ''}';
}

/// Canonical list of marker values.
///
/// Added to make [AsyncMarker] enum-like.
static const List<AsyncMarker> values = <AsyncMarker>[
SYNC,
SYNC_STAR,
ASYNC,
ASYNC_STAR
];

/// Index to this marker within [values].
///
/// Added to make [AsyncMarker] enum-like.
int get index => values.indexOf(this);
}

/// Stripped down super interface for constructor like entities.
Expand Down
4 changes: 2 additions & 2 deletions pkg/compiler/lib/src/elements/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ class _DartTypeToStringVisitor extends DartTypeVisitor<void, void> {
// internal notion. The language specification does not define a '*' token
// in the type language, and no such token should be surfaced to users.
// For debugging, pass `--debug-print-legacy-stars` to emit the '*'.
if (_options == null || _options!.printLegacyStars) {
if (_options == null || _options.printLegacyStars) {
_token('*');
}
}
Expand Down Expand Up @@ -1712,7 +1712,7 @@ class _DartTypeToStringVisitor extends DartTypeVisitor<void, void> {
needsComma = _comma(needsComma);
_visit(typeVariable);
DartType bound = typeVariable.bound;
if (_dartTypes == null || !_dartTypes!.isTopType(bound)) {
if (_dartTypes == null || !_dartTypes.isTopType(bound)) {
_token(' extends ');
_visit(bound);
}
Expand Down
8 changes: 1 addition & 7 deletions pkg/compiler/lib/src/inferrer/abstract_value_domain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class AbstractBool {

@override
String toString() =>
'AbstractBool.${_value == null ? 'Maybe' : (_value! ? 'True' : 'False')}';
'AbstractBool.${_value == null ? 'Maybe' : (_value ? 'True' : 'False')}';
}

/// A value in an abstraction of runtime values.
Expand Down Expand Up @@ -296,12 +296,6 @@ mixin AbstractValueDomain {
/// subtypes of [cls] or `null` at runtime.
AbstractBool containsOnlyType(covariant AbstractValue value, ClassEntity cls);

/// Returns an [AbstractBool] that describes whether [value] is an instance of
/// [cls] or `null` at runtime.
// TODO(johnniwinther): Merge this with [isInstanceOf].
AbstractBool isInstanceOfOrNull(
covariant AbstractValue value, ClassEntity cls);

/// Returns an [AbstractBool] that describes whether [value] is known to be an
/// instance of [cls] at runtime.
AbstractBool isInstanceOf(AbstractValue value, ClassEntity cls);
Expand Down
3 changes: 1 addition & 2 deletions pkg/compiler/lib/src/inferrer/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,7 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault<TypeInformation?>

@override
TypeInformation visitLoadLibrary(ir.LoadLibrary node) {
// TODO(johnniwinther): Improve this by returning a Future type instead.
return _types.dynamicType;
return _types.asyncFutureType;
}

@override
Expand Down
5 changes: 0 additions & 5 deletions pkg/compiler/lib/src/inferrer/computable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,6 @@ class ComputableAbstractValueDomain with AbstractValueDomain {
covariant ComputableAbstractValue value, ClassEntity cls) =>
_wrappedDomain.containsOnlyType(_unwrap(value), cls);

@override
AbstractBool isInstanceOfOrNull(
covariant ComputableAbstractValue value, ClassEntity cls) =>
_wrappedDomain.isInstanceOfOrNull(_unwrap(value), cls);

@override
AbstractBool isInstanceOf(
covariant ComputableAbstractValue value, ClassEntity cls) =>
Expand Down
2 changes: 0 additions & 2 deletions pkg/compiler/lib/src/inferrer/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ class InferrerEngine {
closedWorld.abstractValueDomain;
CommonElements get commonElements => closedWorld.commonElements;

// TODO(johnniwinther): This should be part of [ClosedWorld] or
// [ClosureWorldRefiner].
NoSuchMethodData get noSuchMethodData => closedWorld.noSuchMethodData;

final MemberHierarchyBuilder memberHierarchyBuilder;
Expand Down
7 changes: 0 additions & 7 deletions pkg/compiler/lib/src/inferrer/powersets/powersets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,6 @@ class PowersetDomain with AbstractValueDomain {
_powersetBitsDomain.isInstanceOf(value._powersetBits, cls),
_abstractValueDomain.isInstanceOf(value._abstractValue, cls));

@override
AbstractBool isInstanceOfOrNull(
covariant PowersetValue value, ClassEntity cls) =>
AbstractBool.strengthen(
_powersetBitsDomain.isInstanceOfOrNull(value._powersetBits, cls),
_abstractValueDomain.isInstanceOfOrNull(value._abstractValue, cls));

@override
AbstractBool containsOnlyType(
covariant PowersetValue value, ClassEntity cls) =>
Expand Down
4 changes: 0 additions & 4 deletions pkg/compiler/lib/src/inferrer/trivial.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,6 @@ class TrivialAbstractValueDomain with AbstractValueDomain {
AbstractBool isInstanceOf(AbstractValue value, ClassEntity cls) =>
AbstractBool.Maybe;

@override
AbstractBool isInstanceOfOrNull(AbstractValue value, ClassEntity cls) =>
AbstractBool.Maybe;

@override
AbstractBool containsOnlyType(AbstractValue value, ClassEntity cls) =>
AbstractBool.Maybe;
Expand Down
2 changes: 1 addition & 1 deletion pkg/compiler/lib/src/inferrer/type_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class TypeSystem {
bool isTypedArray =
_closedWorld.classHierarchy.isInstantiated(typedDataClass) &&
_abstractValueDomain
.isInstanceOfOrNull(type.type, typedDataClass)
.isInstanceOf(type.type, typedDataClass)
.isDefinitelyTrue;
bool isConst = (type.type == _abstractValueDomain.constListType);
bool isFixed = (type.type == _abstractValueDomain.fixedListType) ||
Expand Down
5 changes: 0 additions & 5 deletions pkg/compiler/lib/src/inferrer/typemasks/masks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ class CommonMasks with AbstractValueDomain {
late final TypeMask asyncStarStreamType =
TypeMask.nonNullExact(commonElements.controllerStream, _closedWorld);

// TODO(johnniwinther): Assert that the null type has been resolved.
@override
late final TypeMask nullType = TypeMask.empty();

Expand Down Expand Up @@ -409,10 +408,6 @@ class CommonMasks with AbstractValueDomain {
typeMask.containsOnly(cls);
}

@override
AbstractBool isInstanceOfOrNull(TypeMask typeMask, ClassEntity cls) =>
AbstractBool.trueOrMaybe(_isInstanceOfOrNull(typeMask, cls));

bool _isInstanceOfOrNull(TypeMask typeMask, ClassEntity cls) {
return _closedWorld.isImplemented(cls) &&
typeMask.satisfies(cls, _closedWorld);
Expand Down
5 changes: 0 additions & 5 deletions pkg/compiler/lib/src/inferrer/wrapped.dart
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,6 @@ class WrappedAbstractValueDomain with AbstractValueDomain {
covariant WrappedAbstractValue value, ClassEntity cls) =>
_abstractValueDomain.isInstanceOf(value._abstractValue, cls);

@override
AbstractBool isInstanceOfOrNull(
covariant WrappedAbstractValue value, ClassEntity cls) =>
_abstractValueDomain.isInstanceOfOrNull(value._abstractValue, cls);

@override
AbstractBool containsOnlyType(
covariant WrappedAbstractValue value, ClassEntity cls) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class CustomElementsAnalysisJoin {
}
if (_backendUsageBuilder != null) {
escapingConstructors
.forEach(_backendUsageBuilder!.registerGlobalFunctionDependency);
.forEach(_backendUsageBuilder.registerGlobalFunctionDependency);
}
// Force the generation of the type constant that is the key to an entry
// in the generated table.
Expand Down
4 changes: 0 additions & 4 deletions pkg/compiler/lib/src/js_backend/namer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,6 @@ class Namer extends ModularNamer {

case SelectorKind.SPECIAL:
return specialSelectorName(selector);

default:
throw failedAt(CURRENT_ELEMENT_SPANNABLE,
'Unexpected selector kind: ${selector.kind}');
}
}

Expand Down
Loading

0 comments on commit 0a77450

Please sign in to comment.