Files
sdk/tests/language/variance/variance_unconstrained_inference_test.dart
T
Robert Nystrom 48608ce9bc Migrate language_2/variance to NNBD.
Change-Id: I8e21f82dc241a63f78fb1f6a25669b1aa633788c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152080
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2020-06-26 18:37:00 +00:00

27 lines
790 B
Dart

// 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.
// Tests unconstrained inferencing with sound variance.
// SharedOptions=--enable-experiment=variance
class Covariant<out T> {}
class Contravariant<in T> {}
class Invariant<inout T> {}
void covariantListInfer<T>(Covariant<List<T>> x) {}
void contravariantListInfer<T>(Contravariant<List<T>> x) {}
void invariantListInfer<T>(Invariant<List<T>> x) {}
main() {
var cov = new Covariant();
covariantListInfer(Covariant());
var contra = new Contravariant();
contravariantListInfer(Contravariant());
var inv = new Invariant();
invariantListInfer(Invariant());
}