Files
sdk/pkg/front_end/testcases/inference_new/const_invocation.dart
T
Paul Berry 8f1ca007f2 Fix type inference for const expressions.
The inferred types for const expressions shouldn't refer to type
variables that are in scope, because at runtime those type variables
may take on different values at different times (meaning the const
expression isn't actually const after all).

Test cases are in inference_new, since analyzer implements incorrect
behavior.

Fixes #30677.

Change-Id: I27b9a95a92557ad1ce1c2c0f28d9a760c372d52a
Reviewed-on: https://dart-review.googlesource.com/5298
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-09-12 21:43:49 +00:00

28 lines
945 B
Dart

// Copyright (c) 2017, 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.
/*@testedFeatures=inference*/
library test;
typedef V F<U, V>(U u);
class Foo<T> {
Bar<T> get v1 => const /*@typeArgs=Null*/ Bar();
Bar<List<T>> get v2 => const /*@typeArgs=List<Null>*/ Bar();
Bar<F<T, T>> get v3 => const /*@typeArgs=(Object) -> Null*/ Bar();
Bar<F<F<T, T>, T>> get v4 =>
const /*@typeArgs=((Null) -> Object) -> Null*/ Bar();
List<T> get v5 => /*@typeArgs=Null*/ const [];
List<F<T, T>> get v6 => /*@typeArgs=(Object) -> Null*/ const [];
Map<T, T> get v7 => /*@typeArgs=Null, Null*/ const {};
Map<F<T, T>, T> get v8 => /*@typeArgs=(Object) -> Null, Null*/ const {};
Map<T, F<T, T>> get v9 => /*@typeArgs=Null, (Object) -> Null*/ const {};
}
class Bar<T> {
const Bar();
}
main() {}