blob: bf32016e5146dc2de57784ef1da11bba60bd996f [file] [log] [blame] [edit]
// Copyright (c) 2025, 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.
class HasNone {}
class HasIndexGet {
operator [](_) {}
}
class HasIndexSet {
operator []=(_, _) {}
}
class HasIndexGetSet {
operator [](_) {}
operator []=(_, _) {}
}
extension HasNoneExtension on HasNone {
operator [](_) {}
operator []=(_, _) {}
}
extension HasIndexGetExtension on HasIndexGet {
operator [](_) {}
operator []=(_, _) {}
}
extension HasIndexSetExtension on HasIndexSet {
operator [](_) {}
operator []=(_, _) {}
}
extension HasIndexGetSetExtension on HasIndexGetSet {
operator [](_) {}
operator []=(_, _) {}
}
implicit(
HasNone hasNone,
HasIndexGet hasIndexGet,
HasIndexSet hasIndexSet,
HasIndexGetSet hasIndexGetSet,
) {
hasNone[0]; // Ok
hasNone[0] = 0; // Ok
hasIndexGet[0]; // Ok
hasIndexGet[0] = 0; // Error
hasIndexSet[0]; // Error
hasIndexSet[0] = 0; // Ok
hasIndexGetSet[0]; // Ok
hasIndexGetSet[0] = 0; // Ok
}
explicit(
HasNone hasNone,
HasIndexGet hasIndexGet,
HasIndexSet hasIndexSet,
HasIndexGetSet hasIndexGetSet,
) {
HasNoneExtension(hasNone)[0]; // Ok
HasNoneExtension(hasNone)[0] = 0; // Ok
HasIndexGetExtension(hasIndexGet)[0]; // Ok
HasIndexGetExtension(hasIndexGet)[0] = 0; // Ok
HasIndexSetExtension(hasIndexSet)[0]; // Ok
HasIndexSetExtension(hasIndexSet)[0] = 0; // Ok
HasIndexGetSetExtension(hasIndexGetSet)[0]; // Ok
HasIndexGetSetExtension(hasIndexGetSet)[0] = 0; // Ok
}