blob: 49e5dad5e0e85bf5903f7e5d419b7024fdfac357 [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 If element is an ifElement with one element, p1, and no "else"
/// element:
///
/// The condition is inferred with a context type of bool.
///
/// If the inferred set element type of p1 is S then the inferred set element
/// type of element is S.
///
/// @description Checks that if the inferred set element type of p1 is S then the
/// inferred set element type of element is S
/// @author sgrekhov@unipro.ru
import "../../Utils/expect.dart";
main() {
var i = 1;
var x = [1, 2, 3] as List<int>?;
var set1 = {
if (i > 0) ...?x,
};
Expect.isTrue(set1 is Set<int>);
checkType(checkIs<Set<int>>, true, set1);
var set2 = {
"",
if (i < 0) ...?x,
};
Expect.isTrue(set2 is Set<Object>);
Expect.isFalse(set2 is Set<String>);
Expect.isFalse(set2 is Set<num>);
checkType(checkIs<Set<Object>>, true, set2);
checkType(checkIs<Set<String>>, false, set2);
checkType(checkIs<Set<num>>, false, set2);
}