Skip to content

Wrong expectation in normalization test. #42143

@crelier

Description

@crelier

A new normalization test introduced in this CL does not include requirements to run either in weak or strong mode, therefore, it runs in both modes.

On the VM (a non yet committed version including fixes), this test fails in both modes due to wrong expectations.

Weak mode:

DART_CONFIGURATION=DebugX64 out/DebugX64/dart --enable_asserts --no-null-safety --enable-experiment=non-nullable --ignore-unrecognized-flags --packages=/usr/local/google/home/regis/dart2/sdk/.packages /usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart

exit code:
255

stderr:
Unhandled exception:
Expect.notEquals(unexpected: <<S extends Future<Never>?>() => Never>, actual:<<S extends Future<Never>>() => Never>) fails.
#0      Expect._fail (package:expect/expect.dart:685:5)
#1      Expect.notEquals (package:expect/expect.dart:306:5)
#2      checkNotEquals2 (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/type_builder.dart:134:10)
#3      checkTypeNotEquals2 (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:19:3)
#4      SimpleBoundTests.checkAtBottomType (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:80:7)
#5      SimpleBoundTests.checkBottomTypes (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:88:5)
#6      SimpleBoundTests.check (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:130:5)
#7      main (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:195:20)
#8      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

The bounds Future<Never>? and Future<Never> are mutual subtypes, since their nullability is ignored in weak mode.

In strong mode:

DART_CONFIGURATION=DebugX64 out/DebugX64/dart --null-safety --enable-experiment=non-nullable --ignore-unrecognized-flags --packages=/usr/local/google/home/regis/dart2/sdk/.packages /usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart

exit code:
255

stderr:
Unhandled exception:
Expect.notEquals(unexpected: <<S extends FutureOr<Future<Object>>>() => Future<Object>>, actual:<<R extends Future<Object>>() => Future<Object>>) fails.
#0      Expect._fail (package:expect/expect.dart:685:5)
#1      Expect.notEquals (package:expect/expect.dart:306:5)
#2      checkNotEquals2 (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/type_builder.dart:134:10)
#3      checkTypeNotEquals2 (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:19:3)
#4      SimpleBoundTests.checkAtNonNullableType (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:96:5)
#5      SimpleBoundTests.checkNonNullableTypes (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:107:5)
#6      SimpleBoundTests.check (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:131:5)
#7      main (file:///usr/local/google/home/regis/dart2/sdk/tests/language/nnbd/normalization/generic_function_type_object_normalization_test.dart:195:20)
#8      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Here also, the bounds FutureOr<Future<Object>> and Future<Object> are mutual subtypes.
It is easy to see that Future<Object> is a subtype of FutureOr<Future<Object>>.
The reverse is less obvious. We have to show that Future<Future<Object>> is a subtype of Future<Object> and it is, because Future<Object> is a subtype of Object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NNBDIssues related to NNBD Releasearea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions