// Copyright (c) 2020, 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. assertRightSubtype(dynamic x) { x as Set; } assertLeftSubtype(X x) { new Set() as X; } class C { test(X x, Y? y) { var v = {x, 42}; // Checking UP(X, int). var w = {42, x}; // Checking UP(int, X). var p = {y, 42}; // Checking UP(Y?, int). var q = {42, y}; // Checking UP(int, Y?). // Check that variable types are both subtype and supertype of Set. assertRightSubtype(v); assertLeftSubtype(v); assertRightSubtype(w); assertLeftSubtype(w); assertRightSubtype(p); assertLeftSubtype(p); assertRightSubtype(q); assertLeftSubtype(q); // Check the same for intersection types. if (x is Object?) { var v = {x, 42}; // Checking UP(X & Object?, int). var w = {42, x}; // Checking UP(int, X & Object?). assertRightSubtype(v); assertLeftSubtype(v); assertRightSubtype(w); assertLeftSubtype(w); } } } main() { new C().test(42, null); new C().test(null, null); }