Skip to content

Commit

Permalink
Version 3.6.0-302.0.dev
Browse files Browse the repository at this point in the history
Merge 8a77fa0 into dev
  • Loading branch information
Dart CI committed Sep 30, 2024
2 parents 79863e3 + 8a77fa0 commit d9fb41a
Show file tree
Hide file tree
Showing 13 changed files with 990 additions and 563 deletions.

Large diffs are not rendered by default.

80 changes: 40 additions & 40 deletions pkg/_fe_analyzer_shared/lib/src/type_inference/type_constraint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,20 @@ class MergedTypeConstraint<
}
}

void mergeInTypeSchemaUpper(
void mergeInTypeSchemaLower(
SharedTypeSchemaView<TypeStructure> constraint,
TypeAnalyzerOperations<TypeStructure, Variable, TypeParameter,
TypeDeclarationType, TypeDeclaration>
typeAnalyzerOperations) {
upper = typeAnalyzerOperations.typeSchemaGlb(upper, constraint);
lower = typeAnalyzerOperations.typeSchemaLub(lower, constraint);
}

void mergeInTypeSchemaLower(
void mergeInTypeSchemaUpper(
SharedTypeSchemaView<TypeStructure> constraint,
TypeAnalyzerOperations<TypeStructure, Variable, TypeParameter,
TypeDeclarationType, TypeDeclaration>
typeAnalyzerOperations) {
lower = typeAnalyzerOperations.typeSchemaLub(lower, constraint);
upper = typeAnalyzerOperations.typeSchemaGlb(upper, constraint);
}

@override
Expand All @@ -171,42 +171,6 @@ class MergedTypeConstraint<
}
}

/// The origin of a type constraint, for the purposes of producing a human
/// readable error message during type inference as well as determining whether
/// the constraint was used to fix the type parameter or not.
abstract class TypeConstraintOrigin<
TypeStructure extends SharedTypeStructure<TypeStructure>,
Variable extends Object,
TypeParameter extends Object,
TypeDeclarationType extends Object,
TypeDeclaration extends Object> {
const TypeConstraintOrigin();

List<String> formatError(
TypeAnalyzerOperations<TypeStructure, Variable, TypeParameter,
TypeDeclarationType, TypeDeclaration>
typeAnalyzerOperations);
}

class UnknownTypeConstraintOrigin<
TypeStructure extends SharedTypeStructure<TypeStructure>,
Variable extends Object,
InferableParameter extends Object,
TypeDeclarationType extends Object,
TypeDeclaration extends Object>
extends TypeConstraintOrigin<TypeStructure, Variable, InferableParameter,
TypeDeclarationType, TypeDeclaration> {
const UnknownTypeConstraintOrigin();

@override
List<String> formatError(
TypeAnalyzerOperations<TypeStructure, Variable, InferableParameter,
TypeDeclarationType, TypeDeclaration>
typeAnalyzerOperations) {
return <String>[];
}
}

class TypeConstraintFromArgument<
TypeStructure extends SharedTypeStructure<TypeStructure>,
Variable extends Object,
Expand Down Expand Up @@ -355,3 +319,39 @@ class TypeConstraintFromReturnType<
];
}
}

/// The origin of a type constraint, for the purposes of producing a human
/// readable error message during type inference as well as determining whether
/// the constraint was used to fix the type parameter or not.
abstract class TypeConstraintOrigin<
TypeStructure extends SharedTypeStructure<TypeStructure>,
Variable extends Object,
TypeParameter extends Object,
TypeDeclarationType extends Object,
TypeDeclaration extends Object> {
const TypeConstraintOrigin();

List<String> formatError(
TypeAnalyzerOperations<TypeStructure, Variable, TypeParameter,
TypeDeclarationType, TypeDeclaration>
typeAnalyzerOperations);
}

class UnknownTypeConstraintOrigin<
TypeStructure extends SharedTypeStructure<TypeStructure>,
Variable extends Object,
InferableParameter extends Object,
TypeDeclarationType extends Object,
TypeDeclaration extends Object>
extends TypeConstraintOrigin<TypeStructure, Variable, InferableParameter,
TypeDeclarationType, TypeDeclaration> {
const UnknownTypeConstraintOrigin();

@override
List<String> formatError(
TypeAnalyzerOperations<TypeStructure, Variable, InferableParameter,
TypeDeclarationType, TypeDeclaration>
typeAnalyzerOperations) {
return <String>[];
}
}
90 changes: 45 additions & 45 deletions pkg/_fe_analyzer_shared/lib/src/types/shared_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,53 @@ abstract interface class SharedVoidTypeStructure<
TypeStructure extends SharedTypeStructure<TypeStructure>>
implements SharedTypeStructure<TypeStructure> {}

extension type SharedTypeView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedTypeStructure<TypeStructure> _typeStructure) implements Object {
TypeStructure unwrapTypeView() => _typeStructure as TypeStructure;

NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;

String getDisplayString() => _typeStructure.getDisplayString();
}
extension type SharedDynamicTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedDynamicTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeSchemaView<TypeStructure> {}

extension type SharedDynamicTypeView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedDynamicTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeView<TypeStructure> {}

extension type SharedInvalidTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedInvalidTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeSchemaView<TypeStructure> {}

extension type SharedInvalidTypeView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedInvalidTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeView<TypeStructure> {}

extension type SharedNamedTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedNamedTypeStructure<TypeStructure> _typeStructure) implements Object {}

extension type SharedNamedTypeView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedNamedTypeStructure<TypeStructure> _namedTypeStructure)
implements Object {
String get name => _namedTypeStructure.name;

SharedTypeView<TypeStructure> get type =>
new SharedTypeView(_namedTypeStructure.type);
}

String get name => _namedTypeStructure.name;
extension type SharedRecordTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedRecordTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeSchemaView<TypeStructure> {
List<SharedNamedTypeSchemaView<TypeStructure>> get namedTypes {
return _typeStructure.namedTypes
as List<SharedNamedTypeSchemaView<TypeStructure>>;
}

List<SharedTypeSchemaView<TypeStructure>> get positionalTypes {
return _typeStructure.positionalTypes
as List<SharedTypeSchemaView<TypeStructure>>;
}
}

extension type SharedRecordTypeView<
Expand All @@ -116,48 +135,24 @@ extension type SharedRecordTypeView<
}
}

extension type SharedVoidTypeView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedVoidTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeView<TypeStructure> {}

extension type SharedTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedTypeStructure<TypeStructure> _typeStructure) implements Object {
TypeStructure unwrapTypeSchemaView() => _typeStructure as TypeStructure;

NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;

String getDisplayString() => _typeStructure.getDisplayString();
}

extension type SharedDynamicTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedDynamicTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeSchemaView<TypeStructure> {}

extension type SharedInvalidTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedInvalidTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeSchemaView<TypeStructure> {}
TypeStructure unwrapTypeSchemaView() => _typeStructure as TypeStructure;
}

extension type SharedNamedTypeSchemaView<
extension type SharedTypeView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedNamedTypeStructure<TypeStructure> _typeStructure) implements Object {}
SharedTypeStructure<TypeStructure> _typeStructure) implements Object {
NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;

extension type SharedRecordTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedRecordTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeSchemaView<TypeStructure> {
List<SharedNamedTypeSchemaView<TypeStructure>> get namedTypes {
return _typeStructure.namedTypes
as List<SharedNamedTypeSchemaView<TypeStructure>>;
}
String getDisplayString() => _typeStructure.getDisplayString();

List<SharedTypeSchemaView<TypeStructure>> get positionalTypes {
return _typeStructure.positionalTypes
as List<SharedTypeSchemaView<TypeStructure>>;
}
TypeStructure unwrapTypeView() => _typeStructure as TypeStructure;
}

/// Note that there is no `SharedUnknownTypeView`, only
Expand All @@ -174,6 +169,11 @@ extension type SharedVoidTypeSchemaView<
SharedVoidTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeSchemaView<TypeStructure> {}

extension type SharedVoidTypeView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
SharedVoidTypeStructure<TypeStructure> _typeStructure)
implements SharedTypeView<TypeStructure> {}

/// Extension methods of [SharedTypeStructureExtension] are intended to avoid
/// explicit null-testing on types before wrapping them into [SharedTypeView] or
/// [SharedTypeSchemaView].
Expand All @@ -193,13 +193,13 @@ extension type SharedVoidTypeSchemaView<
extension SharedTypeStructureExtension<
TypeStructure extends SharedTypeStructure<TypeStructure>>
on SharedTypeStructure<TypeStructure> {
SharedTypeView<TypeStructure> wrapSharedTypeView() {
return new SharedTypeView(this);
}

SharedTypeSchemaView<TypeStructure> wrapSharedTypeSchemaView() {
return new SharedTypeSchemaView(this);
}

SharedTypeView<TypeStructure> wrapSharedTypeView() {
return new SharedTypeView(this);
}
}

extension SharedTypeStructureMapEntryExtension<
Expand Down
9 changes: 9 additions & 0 deletions pkg/_fe_analyzer_shared/test/mini_ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5602,6 +5602,15 @@ class _MiniAstTypeAnalyzer
var methodType = _handlePropertyTargetAndMemberLookup(
null, target, methodName,
location: node.location);
if (methodType is FunctionType) {
if (methodType.namedParameters.isNotEmpty) {
throw UnimplementedError('Named parameters are not supported yet');
} else if (methodType.requiredPositionalParameterCount !=
methodType.positionalParameters.length) {
throw UnimplementedError(
'Optional positional parameters are not supported yet');
}
}
// Recursively analyze each argument.
var inputKinds = [Kind.expression];
for (var i = 0; i < arguments.length; i++) {
Expand Down
Loading

0 comments on commit d9fb41a

Please sign in to comment.