mirror of
https://github.com/dart-lang/sdk
synced 2024-09-22 11:21:35 +00:00
Add a test and improve comment on generic checks.
Review URL: https://codereview.chromium.org//12463012 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19557 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
ed3d5eefe7
commit
2dcc3b14ca
|
@ -541,7 +541,10 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
|||
} else {
|
||||
return graph.addConstantBool(false, constantSystem);
|
||||
}
|
||||
// TODO(karlklose): remove the hasTypeArguments check.
|
||||
// Wee need the [:hasTypeArguments:] check because we don't have
|
||||
// the notion of generics in the backend. For example, [:this:] in
|
||||
// a class [:A<T>:], is currently always considered to have the
|
||||
// raw type.
|
||||
} else if (expressionType.isUseful()
|
||||
&& !expressionType.canBeNull()
|
||||
&& !RuntimeTypeInformation.hasTypeArguments(type)) {
|
||||
|
@ -549,7 +552,7 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
|||
if (receiverType != null) {
|
||||
if (!receiverType.isMalformed &&
|
||||
!type.isMalformed &&
|
||||
compiler.types.isSubtype(receiverType, type)) {
|
||||
compiler.types.isSubtype(receiverType.element.rawType, type)) {
|
||||
return graph.addConstantBool(true, constantSystem);
|
||||
} else if (expressionType.isExact()) {
|
||||
return graph.addConstantBool(false, constantSystem);
|
||||
|
|
13
tests/language/generic_is_check_test.dart
Normal file
13
tests/language/generic_is_check_test.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
class A<T> {
|
||||
foo() => this is A<int>;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.isTrue(new A().foo());
|
||||
Expect.isTrue(new A<int>().foo());
|
||||
Expect.isFalse(new A<String>().foo());
|
||||
}
|
Loading…
Reference in a new issue