Files
sdk/tests/language_2/variance/syntax/variance_disabled_syntax_test.dart
T
Konstantin Shcheglov 3e26a5d0dd Issue 40957. Report the language feature, and recommend to set SDK constraint.
...but don't recommend to enabled any experiment.

R=brianwilkerson@google.com, paulberry@google.com

Bug: https://github.com/dart-lang/sdk/issues/40957
Change-Id: I556ce9952b28d0b079521ac46558f8e3adf352c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144982
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-04-27 22:11:46 +00:00

77 lines
2.1 KiB
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 with `variance` flag disabled
// Correct variance modifier usage will issue an error.
import 'package:expect/expect.dart';
abstract class A<in X> {
// ^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
int foo(X bar);
}
class B<out X, in Y, inout Z> {}
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
// ^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
// ^^^^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
class C<in T> extends A<T> {
// ^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
@override
int foo(T bar) {
return 2;
}
}
mixin D<out T> {}
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
class E1 {}
mixin E<in T extends E1> {}
// ^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
class F<out T> = Object with D<T>;
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
class G<out out> {}
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
class H<out inout> {}
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the 'variance' language feature to be enabled.
main() {
B<int, String, bool> b = B();
C<int> c = C();
Expect.equals(2, c.foo(3));
F<int> f = F();
G<int> g = G();
H<int> h = H();
}