Files
sdk/tests/language_2/variance/variance_unconstrained_inference_test.dart
T
Kallen Tu aa6709974d [cfe] Fix inference for variant parameters leaking UnknownTypes.
Change-Id: I056535cbfc74554de408ce4f9d89c142c4c860cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128771
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2019-12-19 02:14:59 +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());
}