blob: cb44c305923e6e35524c93c78712cf78f3377819 [file] [log] [blame]
/*
* 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.
*/
/**
* @assertion It is a static error if:
* A spread element in a list or set literal has a static type that is not
* assignable to Iterable<Object>.
* @description Checks that compile error is thrown if spread element in set
* literal is not assignable to [Iterate<Object>]
* @author iarkh@unipro.ru
*/
main() {
var number = 1;
var str = "checkme";
var map = {1: 1, 2: 2};
var list = [1, 2, 3, 4, 5];
Set l1 = <dynamic>{...number};
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ITERABLE_SPREAD
// [cfe] Unexpected type 'int' of a spread. Expected 'dynamic' or an Iterable.
Set l2 = <dynamic>{...str};
// ^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ITERABLE_SPREAD
// [cfe] Unexpected type 'String' of a spread. Expected 'dynamic' or an Iterable.
Set l3 = <dynamic>{...map};
// ^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ITERABLE_SPREAD
// [cfe] Unexpected type 'Map<int, int>' of a spread. Expected 'dynamic' or an Iterable.
Set l4 = <dynamic>{...list[0]};
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NOT_ITERABLE_SPREAD
// ^
// [cfe] Unexpected type 'int' of a spread. Expected 'dynamic' or an Iterable.
Set l5 = <dynamic>{...?number};
// [error line 39, column 0]
// [analyzer] unspecified
// [cfe] unspecified
Set l6 = <dynamic>{...?str};
// [error line 43, column 0]
// [analyzer] unspecified
// [cfe] unspecified
Set l7 = <dynamic>{...?map};
// [error line 47, column 0]
// [analyzer] unspecified
// [cfe] unspecified
Set l8 = <dynamic>{...?list[0]};
// [error line 51, column 0]
// [analyzer] unspecified
// [cfe] unspecified
}