// 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 erroneous subclass usage for the `in` variance modifier. // SharedOptions=--enable-experiment=variance typedef CovFunction = T Function(); typedef ContraFunction = void Function(T); typedef InvFunction = T Function(T); class LegacyCovariant {} class Covariant {} class Contravariant {} class Invariant {} mixin MLegacyCovariant {} mixin MCovariant {} mixin MContravariant {} mixin MInvariant {} class A extends LegacyCovariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'LegacyCovariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class B implements LegacyCovariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'LegacyCovariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class C with MLegacyCovariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'MLegacyCovariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class D extends Covariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Covariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class E implements Covariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Covariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class F with MCovariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'MCovariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class G extends Invariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'inout' position in supertype 'Invariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class H implements Invariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'inout' position in supertype 'Invariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class I with MInvariant {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'inout' position in supertype 'MInvariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class J extends Covariant> {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Covariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class K extends Contravariant> {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Contravariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class L extends Covariant> {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Covariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class M extends Covariant>> {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Covariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class N extends Contravariant>> {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Contravariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class O extends Covariant>> {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Covariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class P extends Covariant>> {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Covariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class Q extends Invariant> {} // ^ // [cfe] Can't use 'in' type variable 'T' in an 'inout' position in supertype 'Invariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class R = Covariant with MContravariant; // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'Covariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class S = Contravariant with MCovariant; // ^ // [cfe] Can't use 'in' type variable 'T' in an 'out' position in supertype 'MCovariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE class T = Invariant with MInvariant; // ^ // [cfe] Can't use 'in' type variable 'X' in an 'inout' position in supertype 'Invariant'. // ^ // [cfe] Can't use 'in' type variable 'X' in an 'inout' position in supertype 'MInvariant'. // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE // ^ // [analyzer] COMPILE_TIME_ERROR.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE