// 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 reified types of torn-off methods with type parameters that have // explicit variance modifiers. // SharedOptions=--enable-experiment=variance import "package:expect/expect.dart"; class Contravariant { int method(T x) { return -1; } } class Invariant { T method(T x) { return x; } } class LegacyCovariant { int method(T x) { return -1; } } class NoSuchMethod implements Invariant { noSuchMethod(_) => 3; } main() { Contravariant contraDiff = new Contravariant(); Expect.notType(contraDiff.method); Expect.type(contraDiff.method); Contravariant contraSame = new Contravariant(); Expect.notType(contraSame.method); Expect.type(contraSame.method); Invariant invSame = new Invariant(); Expect.notType(invSame.method); Expect.type(invSame.method); LegacyCovariant legacyDiff = new LegacyCovariant(); Expect.type(legacyDiff.method); Expect.type(legacyDiff.method); LegacyCovariant legacySame = new LegacyCovariant(); Expect.type(legacySame.method); Expect.type(legacySame.method); NoSuchMethod nsm = new NoSuchMethod(); Expect.notType(nsm.method); Expect.type(nsm.method); }