-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type inference for while and do loops.
Analyzer does not type infer these constructs correctly (it uses an empty context for the loop condition, instead of bool), so the tests are in inference_new. R=scheglov@google.com Review-Url: https://codereview.chromium.org/2954253002 .
- Loading branch information
1 parent
7553b2e
commit 213c208
Showing
13 changed files
with
149 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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; | ||
|
||
T f<T>() => null; | ||
|
||
void test() { | ||
do { | ||
var /*@type=int*/ x = 0; | ||
} while (/*@typeArgs=bool*/ f()); | ||
} | ||
|
||
main() {} |
13 changes: 13 additions & 0 deletions
13
pkg/front_end/testcases/inference_new/do_loop.dart.direct.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
library test; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method f<T extends core::Object>() → self::f::T | ||
return null; | ||
static method test() → void { | ||
do { | ||
dynamic x = 0; | ||
} | ||
while (self::f<dynamic>()) | ||
} | ||
static method main() → dynamic {} |
10 changes: 10 additions & 0 deletions
10
pkg/front_end/testcases/inference_new/do_loop.dart.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
library test; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method f<T extends core::Object>() → self::f::T | ||
; | ||
static method test() → void | ||
; | ||
static method main() → dynamic | ||
; |
13 changes: 13 additions & 0 deletions
13
pkg/front_end/testcases/inference_new/do_loop.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
library test; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method f<T extends core::Object>() → self::f::T | ||
return null; | ||
static method test() → void { | ||
do { | ||
core::int x = 0; | ||
} | ||
while (self::f<core::bool>()) | ||
} | ||
static method main() → dynamic {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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; | ||
|
||
T f<T>() => null; | ||
|
||
void test() { | ||
while (/*@typeArgs=bool*/ f()) { | ||
var /*@type=int*/ x = 0; | ||
} | ||
} | ||
|
||
main() {} |
12 changes: 12 additions & 0 deletions
12
pkg/front_end/testcases/inference_new/while_loop.dart.direct.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
library test; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method f<T extends core::Object>() → self::f::T | ||
return null; | ||
static method test() → void { | ||
while (self::f<dynamic>()) { | ||
dynamic x = 0; | ||
} | ||
} | ||
static method main() → dynamic {} |
10 changes: 10 additions & 0 deletions
10
pkg/front_end/testcases/inference_new/while_loop.dart.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
library test; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method f<T extends core::Object>() → self::f::T | ||
; | ||
static method test() → void | ||
; | ||
static method main() → dynamic | ||
; |
12 changes: 12 additions & 0 deletions
12
pkg/front_end/testcases/inference_new/while_loop.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
library test; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method f<T extends core::Object>() → self::f::T | ||
return null; | ||
static method test() → void { | ||
while (self::f<core::bool>()) { | ||
core::int x = 0; | ||
} | ||
} | ||
static method main() → dynamic {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters