// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. // @dart = 2.9 import "package:expect/expect.dart" show Expect; import 'package:kernel/ast.dart'; import 'package:kernel/src/legacy_erasure.dart'; import 'package:kernel/testing/type_parser_environment.dart'; const Map data = { 'Null': 'Null', 'Never': 'Null', 'Never?': 'Null', 'void': 'void', 'dynamic': 'dynamic', 'bool': 'bool*', 'bool?': 'bool*', 'bool*': 'bool*', 'List': 'List*', 'List': 'List*', 'List': 'List*', 'List?': 'List*', 'List?': 'List*', 'List?': 'List*', 'List*': 'List*', 'List*': 'List*', 'List*': 'List*', '() ->* bool*': '() ->* bool*', '() ->? bool*': '() ->* bool*', '() -> bool*': '() ->* bool*', '() ->* bool?': '() ->* bool*', '() ->? bool?': '() ->* bool*', '() -> bool?': '() ->* bool*', '() ->* bool': '() ->* bool*', '() ->? bool': '() ->* bool*', '() -> bool': '() ->* bool*', '(int*) -> void': '(int*) ->* void', '(int?) -> void': '(int*) ->* void', '(int) -> void': '(int*) ->* void', '([int*]) -> void': '([int*]) ->* void', '([int?]) -> void': '([int*]) ->* void', '([int]) -> void': '([int*]) ->* void', '({int* a}) -> void': '({int* a}) ->* void', '({int? a}) -> void': '({int* a}) ->* void', '({int a}) -> void': '({int* a}) ->* void', '({required int* a}) -> void': '({int* a}) ->* void', '({required int? a}) -> void': '({int* a}) ->* void', '({required int a}) -> void': '({int* a}) ->* void', '(T) -> void': '(T) ->* void', '(T?) -> void': '(T*) ->* void', '(T) -> void': '(T) ->* void', '>(T) -> void': '*>(T) ->* void', }; main() { Env env = new Env('', isNonNullableByDefault: true); data.forEach((String input, String output) { DartType inputType = env.parseType(input); DartType expectedOutputType = env.parseType(output); DartType actualOutputType = legacyErasure(inputType); print('legacyErasure($inputType) = $actualOutputType: $expectedOutputType'); Expect.equals( expectedOutputType, actualOutputType, "Unexpected legacy erasure of $inputType ('$input'):\n" "Expected: ${expectedOutputType} ('$output')\n" "Actual: ${actualOutputType}"); }); }