mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:27:43 +00:00
fix #27353, support @checked
covariant parameters in DDC
Seems pretty straightforward. Just added a simple test for now. R=leafp@google.com Review URL: https://codereview.chromium.org/2340463009 .
This commit is contained in:
parent
47cc06ae66
commit
a4734d4b33
|
@ -2179,15 +2179,15 @@ class CodeGenerator extends GeneralizingAstVisitor
|
|||
// TODO(jmesserly): various problems here, see:
|
||||
// https://github.com/dart-lang/dev_compiler/issues/116
|
||||
var paramType = param.element.type;
|
||||
if (node is MethodDeclaration && _unsoundCovariant(paramType, true)) {
|
||||
if (node is MethodDeclaration &&
|
||||
(param.element.isCovariant || _unsoundCovariant(paramType, true)) &&
|
||||
!_inWhitelistCode(node)) {
|
||||
var castType = _emitType(paramType,
|
||||
nameType: options.nameTypeTests || options.hoistTypeTests,
|
||||
hoistType: options.hoistTypeTests);
|
||||
if (!_inWhitelistCode(node)) {
|
||||
body.add(js.statement('#._check(#);', [castType, jsParam]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return body.isEmpty ? null : _statement(body);
|
||||
}
|
||||
|
||||
|
|
|
@ -159,9 +159,9 @@ packages:
|
|||
version: "0.12.0+2"
|
||||
meta:
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
path: "../meta"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.3"
|
||||
mime:
|
||||
description:
|
||||
|
|
|
@ -16,6 +16,7 @@ dependencies:
|
|||
func: ^0.1.0
|
||||
html: ^0.12.0
|
||||
js: ^0.6.0
|
||||
meta: ^1.0.3
|
||||
path: ^1.3.0
|
||||
pub_semver: ^1.1.0
|
||||
source_maps: ^0.10.0
|
||||
|
@ -31,15 +32,9 @@ dev_dependencies:
|
|||
webdriver: ^1.1.0
|
||||
|
||||
dependency_overrides:
|
||||
# This is here until we can update package:test and dart_style
|
||||
analyzer:
|
||||
path: ../analyzer
|
||||
# Depend directly on packages in the same repositiory
|
||||
analyzer: { path: ../analyzer }
|
||||
meta: { path: ../meta }
|
||||
|
||||
environment:
|
||||
sdk: ">=1.12.0 <2.0.0"
|
||||
|
||||
executables:
|
||||
# Similar to "analyzer.dart" and its command line "dartanalyzer" we use
|
||||
# "dartdevc".
|
||||
dartdevc: dartdevc
|
||||
dev_compiler: dartdevc
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) 2016, 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.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:meta/meta.dart' show checked;
|
||||
|
||||
// Test runtime behavior of @checked
|
||||
|
||||
class View {
|
||||
addChild(View v) {}
|
||||
transform(View fn(View v)) {}
|
||||
}
|
||||
class MyView extends View {
|
||||
addChild(@checked MyView v) {}
|
||||
transform(@checked MyView fn(Object v)) {}
|
||||
}
|
||||
|
||||
main() {
|
||||
dynamic mv = new MyView();
|
||||
dynamic v = new View();
|
||||
|
||||
mv.addChild(mv);
|
||||
Expect.throws(() => mv.addChild(v));
|
||||
|
||||
mv.transform((_) => new MyView());
|
||||
|
||||
// TODO(jmesserly): these *should* be a cast failures, but DDC is currently
|
||||
// ignoring function type failures w/ a warning at the console...
|
||||
|
||||
// * -> * not a subtype of Object -> MyView
|
||||
// Expect.throws(() => mv.transform((_) => mv));
|
||||
|
||||
// View -> View not a subtype of Object -> MyView
|
||||
// Expect.throws(() => mv.transform((View x) => x));
|
||||
}
|
Loading…
Reference in a new issue