blob: aadf9cebf383763311e19134f3616f82dc6faea8 [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 The upwards inference key type of a for map element is the key
/// type of the body element, likewise for the value type.
///
/// @description Checks that the upwards inference key type of a for map element
/// is the key type of the body element, likewise for the value type.
/// @author sgrekhov@unipro.ru
import "../../Utils/expect.dart";
class A {}
class B extends A {}
class C extends B {}
main() {
var i = 1;
var map1 = {
new C(): B(),
for (int i = 0; i < 2; i++)
new B(): A()
};
Expect.isTrue(map1 is Map<B, A>);
checkType(checkIs<Map<B, A>>, true, map1);
var map2 = {
"": "",
for (int i = 0; i < 2; i++) "": 1,
};
Expect.isTrue(map2 is Map<String, Object>);
checkType(checkIs<Map<String, Object>>, true, map2);
var map3 = {
1: 1,
for (var i in []) 3.14: 1
};
Expect.isTrue(map3 is Map<num, int>);
checkType(checkIs<Map<num, int>>, true, map3);
}