Elements. Test for https://dart-review.googlesource.com/c/sdk/+/491140
Cover additional topMerge cases that were either untested or only partially exercised. Add failure cases for incompatible shapes, including function types with different formal parameter counts, different type parameter counts, nullability mismatches, and records whose positional or named fields do not line up. Also add positive coverage for records that merge both positional and named fields in the same type. This makes the expected behavior around record and function structure more explicit and helps guard the recent top merge changes against regressions. Change-Id: I85f3a2206d5c1cfb2a6f31964dc646382d91d227 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491681 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
21a67c5c31
commit
c28c056f21
@@ -32,6 +32,16 @@ class TopMergeTest extends AbstractTypeSystemTest {
|
||||
_check(dynamicType, dynamicType, dynamicType);
|
||||
}
|
||||
|
||||
test_function_formalParameters_differentCount() {
|
||||
_checkThrows(
|
||||
functionTypeNone(returnType: voidNone, formalParameters: []),
|
||||
functionTypeNone(
|
||||
returnType: voidNone,
|
||||
formalParameters: [requiredParameter(type: intNone)],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
test_function_parameters_covariant() {
|
||||
_check(
|
||||
functionTypeNone(
|
||||
@@ -199,6 +209,15 @@ class TopMergeTest extends AbstractTypeSystemTest {
|
||||
);
|
||||
}
|
||||
|
||||
test_function_typeParameters_differentCount() {
|
||||
var T = typeParameter('T');
|
||||
var S = typeParameter('S');
|
||||
_checkThrows(
|
||||
functionTypeNone(returnType: voidNone),
|
||||
functionTypeNone(typeParameters: [T, S], returnType: voidNone),
|
||||
);
|
||||
}
|
||||
|
||||
test_interface() {
|
||||
_check(
|
||||
listNone(dynamicType),
|
||||
@@ -229,6 +248,10 @@ class TopMergeTest extends AbstractTypeSystemTest {
|
||||
_check(intQuestion, intQuestion, intQuestion);
|
||||
}
|
||||
|
||||
test_nullability_mismatch() {
|
||||
_checkThrows(intQuestion, intNone);
|
||||
}
|
||||
|
||||
test_objectQuestion() {
|
||||
// NNBD_TOP_MERGE(Object?, Object?) = Object?
|
||||
_check(objectQuestion, objectQuestion, objectQuestion);
|
||||
@@ -260,6 +283,42 @@ class TopMergeTest extends AbstractTypeSystemTest {
|
||||
recordTypeNone(namedTypes: {'f': objectQuestion}),
|
||||
recordTypeNone(namedTypes: {'f': objectQuestion}),
|
||||
);
|
||||
|
||||
_check(
|
||||
recordTypeNone(
|
||||
positionalTypes: [dynamicType],
|
||||
namedTypes: {'f': voidNone},
|
||||
),
|
||||
recordTypeNone(
|
||||
positionalTypes: [objectQuestion],
|
||||
namedTypes: {'f': objectQuestion},
|
||||
),
|
||||
recordTypeNone(
|
||||
positionalTypes: [objectQuestion],
|
||||
namedTypes: {'f': objectQuestion},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
test_record_namedFields_differentCount() {
|
||||
_checkThrows(
|
||||
recordTypeNone(namedTypes: {'a': intNone}),
|
||||
recordTypeNone(namedTypes: {'a': intNone, 'b': intNone}),
|
||||
);
|
||||
}
|
||||
|
||||
test_record_namedFields_differentNames() {
|
||||
_checkThrows(
|
||||
recordTypeNone(namedTypes: {'a': intNone}),
|
||||
recordTypeNone(namedTypes: {'b': intNone}),
|
||||
);
|
||||
}
|
||||
|
||||
test_record_positionalFields_differentCount() {
|
||||
_checkThrows(
|
||||
recordTypeNone(positionalTypes: [intNone]),
|
||||
recordTypeNone(positionalTypes: [intNone, intNone]),
|
||||
);
|
||||
}
|
||||
|
||||
test_typeParameter() {
|
||||
|
||||
Reference in New Issue
Block a user