Skip to content

Commit

Permalink
Version 3.4.0-26.0.dev
Browse files Browse the repository at this point in the history
Merge df5a3d8 into dev
  • Loading branch information
Dart CI committed Jan 13, 2024
2 parents 13e87ed + df5a3d8 commit 7699d82
Show file tree
Hide file tree
Showing 23 changed files with 931 additions and 117 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ vars = {
"usage_rev": "e99690ae6d5fa9ec24ac5218bcd3621e8e3ae8a9",
"vector_math_rev": "38a00c35575b71a095903467141e5ee60c94d011",
"watcher_rev": "66cd694ffb7ee6e09ff0cde6c9f788aa47ee1a23",
"web_rev": "dd4bb852c6e4fbea7a8177328b065a645bf7e101",
"web_rev": "020ef3729a10a1969b98c2b99b9894c81a953440",
"web_socket_channel_rev": "5241175e7c66271850d6e75fb9ec90068f9dd3c4", # https://github.com/dart-lang/sdk/issues/54165
"webdev_rev": "c08a65c93c8504af27bf9169d17037e6abf3cd9c",
"webdriver_rev": "2c1b6f8b9d684caf62d72bb327c24f738a4e7455",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1630,15 +1630,15 @@ mixin TypeAnalyzer<
Error? argumentTypeNotAssignableError;
Error? operatorReturnTypeNotAssignableToBoolError;
if (operator != null) {
Type extensionTypeErasure = operations.extensionTypeErasure(operandType);
Type argumentType = isEquality
? operations.promoteToNonNull(extensionTypeErasure)
: extensionTypeErasure;
if (!operations.isAssignableTo(argumentType, operator.parameterType)) {
Type parameterType = operator.parameterType;
if (isEquality) {
parameterType = operations.makeNullable(parameterType);
}
if (!operations.isAssignableTo(operandType, parameterType)) {
argumentTypeNotAssignableError =
errors.relationalPatternOperandTypeNotAssignable(
pattern: node,
operandType: argumentType,
operandType: operandType,
parameterType: operator.parameterType,
);
}
Expand Down
30 changes: 15 additions & 15 deletions pkg/_fe_analyzer_shared/test/macros/executor/executor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ class LibraryInfo {
print('isGetter: false');
print('isSetter: false');
print('returnType: String');
return augment super();
return augmented();
}'''));
});

Expand Down Expand Up @@ -706,7 +706,7 @@ class LibraryInfo {
print('isGetter: true');
print('isSetter: false');
print('returnType: String');
return augment super;
return augmented;
}'''));
});

Expand All @@ -728,7 +728,7 @@ class LibraryInfo {
print('isSetter: true');
print('returnType: void');
print('positionalParam: String value');
return augment super = value;
return augmented = value;
}'''));
});

Expand All @@ -750,14 +750,14 @@ class LibraryInfo {
print('isExternal: false');
print('isFinal: true');
print('isLate: false');
return augment super;
return augmented;
}'''),
equalsIgnoringWhitespace('''
augment set _myVariable(/*inferred*/String value) {
augment super = value;
augmented = value;
}'''),
equalsIgnoringWhitespace('''
augment final /*inferred*/String _myVariable = 'new initial value' + augment super;
augment final /*inferred*/String _myVariable = 'new initial value' + augmented;
'''),
]));
});
Expand Down Expand Up @@ -830,7 +830,7 @@ class LibraryInfo {
print('isSetter: false');
print('returnType: MyEnum');
print('positionalParam: String myField');
return augment super();
return augmented();
}''')
]));
});
Expand Down Expand Up @@ -964,7 +964,7 @@ augment MyClass.myConstructor(/*inferred*/String myField, ) {
print('isSetter: false');
print('returnType: MyClass');
print('positionalParam: String (inferred) myField');
return augment super();
return augmented();
}''');

final fieldDefinitionMatchers = [
Expand All @@ -975,14 +975,14 @@ final fieldDefinitionMatchers = [
print('isExternal: false');
print('isFinal: false');
print('isLate: false');
return augment super;
return augmented;
}'''),
equalsIgnoringWhitespace('''
augment set myField(String value) {
augment super = value;
augmented = value;
}'''),
equalsIgnoringWhitespace('''
augment String myField = \'new initial value\' + augment super;'''),
augment String myField = \'new initial value\' + augmented;'''),
];

final methodDefinitionMatchers = [
Expand All @@ -993,7 +993,7 @@ final methodDefinitionMatchers = [
print('isGetter: false');
print('isSetter: false');
print('returnType: (String, bool? hello, {String world})');
return augment super();
return augmented();
}'''),
equalsIgnoringWhitespace('''
augment (String, bool? hello, {String world}) myMethod() {
Expand All @@ -1011,7 +1011,7 @@ final methodDefinitionMatchers = [
print('field: myField');
print('method: myMethod');
print('constructor: myConstructor');
return augment super();
return augmented();
}'''),
];

Expand All @@ -1023,7 +1023,7 @@ final mixinMethodDefinitionMatchers = [
print('isGetter: false');
print('isSetter: false');
print('returnType: (String, bool? hello, {String world})');
return augment super();
return augmented();
}'''),
equalsIgnoringWhitespace('''
augment (String, bool? hello, {String world}) myMixinMethod() {
Expand All @@ -1037,6 +1037,6 @@ final mixinMethodDefinitionMatchers = [
print('parentClass: MyMixin');
print('superClass: null');
print('method: myMixinMethod');
return augment super();
return augmented();
}'''),
];
11 changes: 5 additions & 6 deletions pkg/_fe_analyzer_shared/test/macros/executor/simple_macro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class SimpleMacro
for (var constructor in constructors)
"\n print('constructor: ${constructor.identifier.name}');",
'''
\n return augment super();
\n return augmented();
}''',
]));
}
Expand Down Expand Up @@ -448,18 +448,17 @@ class SimpleMacro
'''print('isExternal: ${variable.hasExternal}');
print('isFinal: ${variable.hasFinal}');
print('isLate: ${variable.hasLate}');
return augment super;
return augmented;
}''',
]),
setter: DeclarationCode.fromParts([
'set ',
variable.identifier.name,
'(',
variable.type.code,
' value) { augment super = value; }'
' value) { augmented = value; }'
]),
initializer:
ExpressionCode.fromString("'new initial value' + augment super"),
initializer: ExpressionCode.fromString("'new initial value' + augmented"),
);
}

Expand Down Expand Up @@ -759,7 +758,7 @@ Future<FunctionBodyCode> _buildFunctionAugmentation(
if (param.bound != null) param.bound!.code,
"');\n",
],
'return augment super',
'return augmented',
if (function.isSetter) ...[
' = ',
function.positionalParameters.first.identifier,
Expand Down
4 changes: 2 additions & 2 deletions pkg/_fe_analyzer_shared/test/macros/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class Fixtures {
IdentifierImpl(id: RemoteInstance.uniqueId, name: 'myConstructor'),
library: Fixtures.library,
metadata: [],
hasBody: true,
hasBody: false, // we will augment with one
hasExternal: false,
namedParameters: [],
positionalParameters: [
Expand Down Expand Up @@ -611,7 +611,7 @@ class Fixtures {
id: RemoteInstance.uniqueId, name: 'myEnumConstructor'),
library: Fixtures.library,
metadata: [],
hasBody: true,
hasBody: false, // We will augment with one
hasExternal: false,
namedParameters: [],
positionalParameters: [
Expand Down
28 changes: 23 additions & 5 deletions pkg/_fe_analyzer_shared/test/mini_ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,8 @@ class GuardedPattern extends Node with PossiblyGuardedPattern {

class Harness {
static Map<String, Type> _coreMemberTypes = {
'int.<': Type('bool Function(num)'),
'int.<=': Type('bool Function(num)'),
'int.>': Type('bool Function(num)'),
'int.>=': Type('bool Function(num)'),
'num.sign': Type('num'),
Expand Down Expand Up @@ -1684,6 +1686,12 @@ class Harness {
operations.addExhaustiveness(type, isExhaustive);
}

/// Updates the harness so that when an extension type erasure query is
/// invoked on type [type], [representation] will be returned.
void addExtensionTypeErasure(String type, String representation) {
operations.addExtensionTypeErasure(type, representation);
}

/// Updates the harness so that when member [memberName] is looked up on type
/// [targetType], a member is found having the given [type].
///
Expand Down Expand Up @@ -2617,6 +2625,7 @@ class MiniAstOperations implements TypeAnalyzerOperations<Var, Type> {
'int, num': Type('num'),
'Never, int': Type('int'),
'Null, int': Type('int?'),
'Null, Object': Type('Object?'),
'?, int': Type('int'),
'?, List<?>': Type('List<?>'),
'?, Null': Type('Null'),
Expand Down Expand Up @@ -2682,6 +2691,8 @@ class MiniAstOperations implements TypeAnalyzerOperations<Var, Type> {

final Map<String, bool> _exhaustiveness = Map.of(_coreExhaustiveness);

final Map<String, Type> _extensionTypeErasure = {};

final Map<String, Type> _glbs = Map.of(_coreGlbs);

final Map<String, Type> _lubs = Map.of(_coreLubs);
Expand Down Expand Up @@ -2726,6 +2737,12 @@ class MiniAstOperations implements TypeAnalyzerOperations<Var, Type> {
_exhaustiveness[type] = isExhaustive;
}

/// Updates the harness so that when an extension type erasure query is
/// invoked on type [type], [representation] will be returned.
void addExtensionTypeErasure(String type, String representation) {
_extensionTypeErasure[type] = Type(representation);
}

void addPromotionException(String from, String to, String result) {
(_promotionExceptions[from] ??= {})[to] = result;
}
Expand Down Expand Up @@ -2783,6 +2800,12 @@ class MiniAstOperations implements TypeAnalyzerOperations<Var, Type> {
fail('Unknown downward inference query: $query');
}

@override
Type extensionTypeErasure(Type type) {
var query = '$type';
return _extensionTypeErasure[query] ?? type;
}

@override
Type factor(Type from, Type what) {
return _typeSystem.factor(from, what);
Expand Down Expand Up @@ -2944,11 +2967,6 @@ class MiniAstOperations implements TypeAnalyzerOperations<Var, Type> {
);
}

@override
Type extensionTypeErasure(Type type) {
return type;
}

@override
Type streamType(Type elementType) {
return PrimaryType('Stream', args: [elementType]);
Expand Down
Loading

0 comments on commit 7699d82

Please sign in to comment.