-
Notifications
You must be signed in to change notification settings - Fork 29
#3292. Update assertions for promotion_via_assignment_*
tests
#3294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sgrekhov
wants to merge
1
commit into
dart-lang:master
Choose a base branch
from
sgrekhov:co19-3292-02
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -2,17 +2,85 @@ | |
// 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. | ||
|
||
/// @assertion We say that a variable `x` is promotable via assignment of an | ||
/// expression of type `T` given variable model `VM` if | ||
/// - `VM = VariableModel(declared, promoted, tested, assigned, unassigned, | ||
/// captured)` | ||
/// - and captured is false | ||
/// - and `S` is the current type of `x` in `VM` | ||
/// - and `T <: S` and not `S <: T` | ||
/// - and `T` is a type of interest for `x` in `tested` | ||
/// @assertion `toi_promote(declared, promotionChain, tested, written)`, where | ||
/// declared and written are types satisfying `written <: declared`, | ||
/// `promotionChain` is valid for declared type declared, and all types `T` in | ||
/// `promotionChain` satisfy `written <: T`, is the promotion chain | ||
/// `newPromotionChain`, defined as follows. ("toi" stands for "type of | ||
/// interest".) | ||
/// - Let `provisionalType` be the last type in `promotionChain`, or `declared` | ||
/// if `promotionChain` is empty. (This is the type of the variable after | ||
/// demotions, but before type of interest promotion.) | ||
/// - Since the last type in a promotion chain is a subtype of all the others, | ||
/// it follows that all types `T` in `promotionChain` satisfy | ||
/// `provisionalType <: T`. | ||
/// - If `written` and `provisionalType` are the same type, then | ||
/// `newPromotionChain` is `promotionChain`. (No type of interest promotion is | ||
/// necessary in this case.) | ||
/// - Otherwise (when `written` is not `provisionalType`), let `p1` be a set | ||
/// containing the following types: | ||
/// - NonNull(`declared`), if it is not the same as `declared`. | ||
/// - For each type `T` in the `tested` list: | ||
/// - `T` | ||
/// - NonNull(`T`) | ||
/// The types in `p1` are known as the types of interest. | ||
/// - Let `p2` be the set `p1 \ { provisionalType }` (where `\` denotes set | ||
/// difference). | ||
/// - If the `written` type is in `p2`, and `written <: provisionalType`, then | ||
/// `newPromotionChain` is `[...promotionChain, written]`. Writing a value | ||
/// whose static type is a type of interest promotes to that type. | ||
/// - By precondition, `written <: declared` and `written <: T` for all types | ||
/// in `promotionChain`. Therefore, `newPromotionChain` satisfies the | ||
/// definition of a promotion chain, and is valid for declared type | ||
/// `declared`. | ||
/// - Otherwise (when `written` is not in `p2`: | ||
/// - Let `p3` be the set of all types `T` in `p2` such that | ||
/// `written <: T <: provisionalType`. | ||
/// - If `p3` contains exactly one type `T` that is a subtype of all the | ||
/// others, then `promoted` is `[...promotionChain, T]`. Writing a value | ||
/// whose static type is a subtype of a type of interest promotes to that | ||
/// type of interest, provided there is a single "best" type of interest | ||
/// available to promote to. | ||
/// - Since `T <: provisionalType <: declared`, and all types `U` in | ||
/// `promotionChain` satisfy `provisionalType <: U`, it follows that all | ||
/// types `U` in `promotionChain` satisfy `T <: U`. Therefore | ||
/// `newPromotionChain` satisfies the definition of a promotion chain, | ||
/// and is valid for declared type `declared`. | ||
/// - Otherwise, `newPromotionChain` is `promotionChain`. If there is no | ||
/// single "best" type of interest to promote to, then no type of interest | ||
/// promotion is done. | ||
/// | ||
/// `assign(x, E, M)` where `x` is a local variable, `E` is an | ||
/// expression of inferred type `T` (which must be a subtype of `x`'s declared | ||
/// type), and `M = FlowModel(r, VI)` is the flow model for `E` is defined to be | ||
/// `FlowModel(r, VI[x -> VM])` where: | ||
/// - `VI(x) = VariableModel(declared, promoted, tested, assigned, unassigned, captured)` | ||
/// - If `captured` is true then: | ||
/// - `VM = VariableModel(declared, promotionChain, tested, true, false, captured)`. | ||
/// - Otherwise: | ||
/// - Let `written = T`. | ||
/// - Let `promotionChain' = demote(promotionChain, written)`. | ||
/// - Let `promotionChain'' = toi_promote(declared, promotionChain', tested, written)`. | ||
/// - The preconditions for toi_promote are satisfied because: | ||
/// - `demote` deletes any elements from `promotionChain` that do not | ||
/// satisfy `written <: T`, therefore every element of `promotionChain'` | ||
/// satisfies `written <: T`. | ||
/// - `written = T` and `T` is a subtype of `x`'s declared type, therefore | ||
/// `written <: declared`. | ||
/// - Then `VM = VariableModel(declared, promotionChain'', tested, true, false, captured)`. | ||
/// ... | ||
/// Local-variable assignment: If `N` is an expression of the form `x = E1` | ||
/// where `x` is a local variable, then: | ||
/// - Let `before(E1) = before(N)`. | ||
/// - Let `E1'` be the result of applying type coercion to `E1`, to coerce it to | ||
/// the declared type of `x`. | ||
/// - Let `after(N) = assign(x, E1', after(E1))`. | ||
/// - Since type coercion to type `T` produces an expression whose static type | ||
/// is a subtype of `T`, the precondition of assign is satisfied, namely | ||
/// that the static type of `E1'` must be a subtype of `x`'s declared type. | ||
/// | ||
/// @description Checks that a variable is promotable to the type `T` if all | ||
/// requirements above are met. | ||
/// requirements of `toi_promote` and `assign` are met. | ||
/// @author [email protected] | ||
|
||
class S {} | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -2,17 +2,85 @@ | |
// 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. | ||
|
||
/// @assertion We say that a variable `x` is promotable via assignment of an | ||
/// expression of type `T` given variable model `VM` if | ||
/// - `VM = VariableModel(declared, promoted, tested, assigned, unassigned, | ||
/// captured)` | ||
/// - and captured is false | ||
/// - and `S` is the current type of `x` in `VM` | ||
/// - and `T <: S` and not `S <: T` | ||
/// - and `T` is a type of interest for `x` in `tested` | ||
/// @assertion `toi_promote(declared, promotionChain, tested, written)`, where | ||
/// declared and written are types satisfying `written <: declared`, | ||
/// `promotionChain` is valid for declared type declared, and all types `T` in | ||
/// `promotionChain` satisfy `written <: T`, is the promotion chain | ||
/// `newPromotionChain`, defined as follows. ("toi" stands for "type of | ||
/// interest".) | ||
/// - Let `provisionalType` be the last type in `promotionChain`, or `declared` | ||
/// if `promotionChain` is empty. (This is the type of the variable after | ||
/// demotions, but before type of interest promotion.) | ||
/// - Since the last type in a promotion chain is a subtype of all the others, | ||
/// it follows that all types `T` in `promotionChain` satisfy | ||
/// `provisionalType <: T`. | ||
/// - If `written` and `provisionalType` are the same type, then | ||
/// `newPromotionChain` is `promotionChain`. (No type of interest promotion is | ||
/// necessary in this case.) | ||
/// - Otherwise (when `written` is not `provisionalType`), let `p1` be a set | ||
/// containing the following types: | ||
/// - NonNull(`declared`), if it is not the same as `declared`. | ||
/// - For each type `T` in the `tested` list: | ||
/// - `T` | ||
/// - NonNull(`T`) | ||
/// The types in `p1` are known as the types of interest. | ||
/// - Let `p2` be the set `p1 \ { provisionalType }` (where `\` denotes set | ||
/// difference). | ||
/// - If the `written` type is in `p2`, and `written <: provisionalType`, then | ||
/// `newPromotionChain` is `[...promotionChain, written]`. Writing a value | ||
/// whose static type is a type of interest promotes to that type. | ||
/// - By precondition, `written <: declared` and `written <: T` for all types | ||
/// in `promotionChain`. Therefore, `newPromotionChain` satisfies the | ||
/// definition of a promotion chain, and is valid for declared type | ||
/// `declared`. | ||
/// - Otherwise (when `written` is not in `p2`: | ||
/// - Let `p3` be the set of all types `T` in `p2` such that | ||
/// `written <: T <: provisionalType`. | ||
/// - If `p3` contains exactly one type `T` that is a subtype of all the | ||
/// others, then `promoted` is `[...promotionChain, T]`. Writing a value | ||
/// whose static type is a subtype of a type of interest promotes to that | ||
/// type of interest, provided there is a single "best" type of interest | ||
/// available to promote to. | ||
/// - Since `T <: provisionalType <: declared`, and all types `U` in | ||
/// `promotionChain` satisfy `provisionalType <: U`, it follows that all | ||
/// types `U` in `promotionChain` satisfy `T <: U`. Therefore | ||
/// `newPromotionChain` satisfies the definition of a promotion chain, | ||
/// and is valid for declared type `declared`. | ||
/// - Otherwise, `newPromotionChain` is `promotionChain`. If there is no | ||
/// single "best" type of interest to promote to, then no type of interest | ||
/// promotion is done. | ||
/// | ||
/// @description Checks that if `captured` is `true` then promotion via | ||
/// assignment is not performed | ||
/// `assign(x, E, M)` where `x` is a local variable, `E` is an | ||
/// expression of inferred type `T` (which must be a subtype of `x`'s declared | ||
/// type), and `M = FlowModel(r, VI)` is the flow model for `E` is defined to be | ||
/// `FlowModel(r, VI[x -> VM])` where: | ||
/// - `VI(x) = VariableModel(declared, promoted, tested, assigned, unassigned, captured)` | ||
/// - If `captured` is true then: | ||
/// - `VM = VariableModel(declared, promotionChain, tested, true, false, captured)`. | ||
/// - Otherwise: | ||
/// - Let `written = T`. | ||
/// - Let `promotionChain' = demote(promotionChain, written)`. | ||
/// - Let `promotionChain'' = toi_promote(declared, promotionChain', tested, written)`. | ||
/// - The preconditions for toi_promote are satisfied because: | ||
/// - `demote` deletes any elements from `promotionChain` that do not | ||
/// satisfy `written <: T`, therefore every element of `promotionChain'` | ||
/// satisfies `written <: T`. | ||
/// - `written = T` and `T` is a subtype of `x`'s declared type, therefore | ||
/// `written <: declared`. | ||
/// - Then `VM = VariableModel(declared, promotionChain'', tested, true, false, captured)`. | ||
/// ... | ||
/// Local-variable assignment: If `N` is an expression of the form `x = E1` | ||
/// where `x` is a local variable, then: | ||
/// - Let `before(E1) = before(N)`. | ||
/// - Let `E1'` be the result of applying type coercion to `E1`, to coerce it to | ||
/// the declared type of `x`. | ||
/// - Let `after(N) = assign(x, E1', after(E1))`. | ||
/// - Since type coercion to type `T` produces an expression whose static type | ||
/// is a subtype of `T`, the precondition of assign is satisfied, namely | ||
/// that the static type of `E1'` must be a subtype of `x`'s declared type. | ||
/// | ||
/// @description Checks that if the variable was assigned after it was made a | ||
/// type of interest then promotion via assignment is not performed. | ||
/// @author [email protected] | ||
|
||
class S {} | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -2,17 +2,85 @@ | |
// 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. | ||
|
||
/// @assertion We say that a variable `x` is promotable via assignment of an | ||
/// expression of type `T` given variable model `VM` if | ||
/// - `VM = VariableModel(declared, promoted, tested, assigned, unassigned, | ||
/// captured)` | ||
/// - and captured is false | ||
/// - and `S` is the current type of `x` in `VM` | ||
/// - and `T <: S` and not `S <: T` | ||
/// - and `T` is a type of interest for `x` in `tested` | ||
/// @assertion `toi_promote(declared, promotionChain, tested, written)`, where | ||
/// declared and written are types satisfying `written <: declared`, | ||
/// `promotionChain` is valid for declared type declared, and all types `T` in | ||
/// `promotionChain` satisfy `written <: T`, is the promotion chain | ||
/// `newPromotionChain`, defined as follows. ("toi" stands for "type of | ||
/// interest".) | ||
/// - Let `provisionalType` be the last type in `promotionChain`, or `declared` | ||
/// if `promotionChain` is empty. (This is the type of the variable after | ||
/// demotions, but before type of interest promotion.) | ||
/// - Since the last type in a promotion chain is a subtype of all the others, | ||
/// it follows that all types `T` in `promotionChain` satisfy | ||
/// `provisionalType <: T`. | ||
/// - If `written` and `provisionalType` are the same type, then | ||
/// `newPromotionChain` is `promotionChain`. (No type of interest promotion is | ||
/// necessary in this case.) | ||
/// - Otherwise (when `written` is not `provisionalType`), let `p1` be a set | ||
/// containing the following types: | ||
/// - NonNull(`declared`), if it is not the same as `declared`. | ||
/// - For each type `T` in the `tested` list: | ||
/// - `T` | ||
/// - NonNull(`T`) | ||
/// The types in `p1` are known as the types of interest. | ||
/// - Let `p2` be the set `p1 \ { provisionalType }` (where `\` denotes set | ||
/// difference). | ||
/// - If the `written` type is in `p2`, and `written <: provisionalType`, then | ||
/// `newPromotionChain` is `[...promotionChain, written]`. Writing a value | ||
/// whose static type is a type of interest promotes to that type. | ||
/// - By precondition, `written <: declared` and `written <: T` for all types | ||
/// in `promotionChain`. Therefore, `newPromotionChain` satisfies the | ||
/// definition of a promotion chain, and is valid for declared type | ||
/// `declared`. | ||
/// - Otherwise (when `written` is not in `p2`: | ||
/// - Let `p3` be the set of all types `T` in `p2` such that | ||
/// `written <: T <: provisionalType`. | ||
/// - If `p3` contains exactly one type `T` that is a subtype of all the | ||
/// others, then `promoted` is `[...promotionChain, T]`. Writing a value | ||
/// whose static type is a subtype of a type of interest promotes to that | ||
/// type of interest, provided there is a single "best" type of interest | ||
/// available to promote to. | ||
/// - Since `T <: provisionalType <: declared`, and all types `U` in | ||
/// `promotionChain` satisfy `provisionalType <: U`, it follows that all | ||
/// types `U` in `promotionChain` satisfy `T <: U`. Therefore | ||
/// `newPromotionChain` satisfies the definition of a promotion chain, | ||
/// and is valid for declared type `declared`. | ||
/// - Otherwise, `newPromotionChain` is `promotionChain`. If there is no | ||
/// single "best" type of interest to promote to, then no type of interest | ||
/// promotion is done. | ||
/// | ||
/// @description Checks that if `T <: S` and `S <: T` then promotion via | ||
/// assignment is not performed. | ||
/// `assign(x, E, M)` where `x` is a local variable, `E` is an | ||
/// expression of inferred type `T` (which must be a subtype of `x`'s declared | ||
/// type), and `M = FlowModel(r, VI)` is the flow model for `E` is defined to be | ||
/// `FlowModel(r, VI[x -> VM])` where: | ||
/// - `VI(x) = VariableModel(declared, promoted, tested, assigned, unassigned, captured)` | ||
/// - If `captured` is true then: | ||
/// - `VM = VariableModel(declared, promotionChain, tested, true, false, captured)`. | ||
/// - Otherwise: | ||
/// - Let `written = T`. | ||
/// - Let `promotionChain' = demote(promotionChain, written)`. | ||
/// - Let `promotionChain'' = toi_promote(declared, promotionChain', tested, written)`. | ||
/// - The preconditions for toi_promote are satisfied because: | ||
/// - `demote` deletes any elements from `promotionChain` that do not | ||
/// satisfy `written <: T`, therefore every element of `promotionChain'` | ||
/// satisfies `written <: T`. | ||
/// - `written = T` and `T` is a subtype of `x`'s declared type, therefore | ||
/// `written <: declared`. | ||
/// - Then `VM = VariableModel(declared, promotionChain'', tested, true, false, captured)`. | ||
/// ... | ||
/// Local-variable assignment: If `N` is an expression of the form `x = E1` | ||
/// where `x` is a local variable, then: | ||
/// - Let `before(E1) = before(N)`. | ||
/// - Let `E1'` be the result of applying type coercion to `E1`, to coerce it to | ||
/// the declared type of `x`. | ||
/// - Let `after(N) = assign(x, E1', after(E1))`. | ||
/// - Since type coercion to type `T` produces an expression whose static type | ||
/// is a subtype of `T`, the precondition of assign is satisfied, namely | ||
/// that the static type of `E1'` must be a subtype of `x`'s declared type. | ||
/// | ||
/// @description Checks that if `written <: declared` and `declared <: written` | ||
/// then promotion via assignment is not performed. | ||
/// @author [email protected] | ||
|
||
import 'dart:async'; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the old description was better: