blob: 795416de6e4f47c3b5331d307ad2ff32d3df915f [file] [log] [blame]
/*
* Copyright (c) 2018, 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.
*/
/**
* @assertion Let e be a setOrMapLiteral
* ...
* If e has typeArguments then:
* - If there is exactly one type argument T, then e is a set literal with
* static type Set<T>.
* - If there are exactly two type arguments K and V, then e is a map literal
* with static type Map<K, V>.
* - Otherwise (three or more type arguments), report a compile-time error.
*
* @description Checks that it is a compile-time error if a setLiteral has a
* typeArguments with more than one type argument.
* @author sgrekhov@unipro.ru
*/
Set set1 = {1, 2};
Set set2 = {};
var v1 = <int, String> {1};
// [error line 23, column 0]
// [analyzer] unspecified
// [cfe] unspecified
var v2 = const <String, int> {1, 2};
// [error line 27, column 0]
// [analyzer] unspecified
// [cfe] unspecified
var v3 = <String, int> {'1', '2'};
// [error line 31, column 0]
// [analyzer] unspecified
// [cfe] unspecified
var v4 = const <int?, String?> {'s', null};
// [error line 35, column 0]
// [analyzer] unspecified
// [cfe] unspecified
var v5 = <String, int> {...set1};
// ^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_MAP_SPREAD
// [cfe] Unexpected type 'Set<dynamic>' of a map spread entry. Expected 'dynamic' or a Map.
var v6 = const <int, String> {...set2};
// [error line 43, column 0]
// [analyzer] unspecified
// [cfe] unspecified
main() {
var x1 = <int, String> {1};
// [error line 49, column 0]
// [analyzer] unspecified
// [cfe] unspecified
var x2 = const <String, int> {1, 2};
// [error line 53, column 0]
// [analyzer] unspecified
// [cfe] unspecified
var x3 = <String, int> {'1', '2'};
// [error line 57, column 0]
// [analyzer] unspecified
// [cfe] unspecified
var x4 = const <int?, String?> {'s', null};
// [error line 61, column 0]
// [analyzer] unspecified
// [cfe] unspecified
var x5 = <String, int> {...set1};
// ^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_MAP_SPREAD
// [cfe] Unexpected type 'Set<dynamic>' of a map spread entry. Expected 'dynamic' or a Map.
var x6 = const <int, String> {...set2};
// [error line 69, column 0]
// [analyzer] unspecified
// [cfe] unspecified
}