From f684982ae719d6760b85d0b28d74dc63ccf0dae6 Mon Sep 17 00:00:00 2001 From: Leaf Petersen Date: Thu, 29 Sep 2022 17:18:03 -0700 Subject: [PATCH 1/6] Specify interactions with older language versions --- .../records/records-feature-specification.md | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/accepted/future-releases/records/records-feature-specification.md b/accepted/future-releases/records/records-feature-specification.md index 189258ba40..799751a150 100644 --- a/accepted/future-releases/records/records-feature-specification.md +++ b/accepted/future-releases/records/records-feature-specification.md @@ -586,8 +586,52 @@ The runtime type of `pair` is `(int, double)`, not `(num, Object)`, However, the variable declaration is still valid and sound because records are naturally covariant in their field types. +### Interactions with libraries using older language versions + +The records feature is language versioned, as usual with new Dart features. +This means that it will be an error to use the syntax for records in libraries +which do not have a language version greater than or equal to the language +version in which records are released. More specifically, assuming that `v` is +the language version in which records are released, the following errors apply. + +It is an error to reference the SDK class `Record` in a library whose language +version is less than `v`. + +It is an error for the record literal syntax (e.g. `(3, 4)`) to be used +syntactically in a library whose language version is less than `v`. + +It is an error for the record type syntax (e.g. `(int, int)`) to be used +syntactically in a library whose language version is less than `v`. + +*It is not an error for a library whose language version is less than `v` (a +"legacy library") to include or reference the `Record` class, record types or +record expressions directly or indirectly from another library whose language +version is greater than or equal to `v`. Such a legacy library may reference a +typedef name which is bound to a record type in another library, and the +semantic interpretation of the typedef is as the underlying record type, just as +it would be for any other type. Similarly, type inference may introduce record +types into a legacy library, and such types will be interpreted by the compiler +as record types as usual (that is, there is no erasure implied to remove these +inferred types). Record values may flow into a legacy library via a reference +to a member from another libraries, and a legacy library may freely call getters +on record values (since there is no new syntax for calling a record getter). + +The reason for this choice is that the intent of language versioning (for an +additive feature such as records) is to ensure that users do not accidentally +use new features in a package without specifying an sdk constraint which ensures +that their code will always be run on an sdk which supports the feature. But in +the case of a legacy library which references record values or types indirectly +via another library, the sdk constraint on the referenced library is sufficient +to enforce this.* + + ## CHANGELOG +### 1.14 + +- Specify the interaction between libraries with a language version that + supports records and libraries with older language versions. + ### 1.13 - Introduce `()` syntax for empty record expressions and remove `Record.empty`. From efe62b012e75afae2fce9abefe47cffabb6ccef3 Mon Sep 17 00:00:00 2001 From: Leaf Petersen Date: Thu, 29 Sep 2022 17:23:06 -0700 Subject: [PATCH 2/6] Fix markdown --- .../future-releases/records/records-feature-specification.md | 1 - 1 file changed, 1 deletion(-) diff --git a/accepted/future-releases/records/records-feature-specification.md b/accepted/future-releases/records/records-feature-specification.md index 799751a150..f3794499cb 100644 --- a/accepted/future-releases/records/records-feature-specification.md +++ b/accepted/future-releases/records/records-feature-specification.md @@ -615,7 +615,6 @@ as record types as usual (that is, there is no erasure implied to remove these inferred types). Record values may flow into a legacy library via a reference to a member from another libraries, and a legacy library may freely call getters on record values (since there is no new syntax for calling a record getter). - The reason for this choice is that the intent of language versioning (for an additive feature such as records) is to ensure that users do not accidentally use new features in a package without specifying an sdk constraint which ensures From 49741ac39519c1c8fee0025ddb2ea6e0a5dbd085 Mon Sep 17 00:00:00 2001 From: Leaf Petersen Date: Thu, 29 Sep 2022 17:38:38 -0700 Subject: [PATCH 3/6] Fix capitalization --- .../records/records-feature-specification.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/accepted/future-releases/records/records-feature-specification.md b/accepted/future-releases/records/records-feature-specification.md index f3794499cb..254ba21877 100644 --- a/accepted/future-releases/records/records-feature-specification.md +++ b/accepted/future-releases/records/records-feature-specification.md @@ -617,10 +617,10 @@ to a member from another libraries, and a legacy library may freely call getters on record values (since there is no new syntax for calling a record getter). The reason for this choice is that the intent of language versioning (for an additive feature such as records) is to ensure that users do not accidentally -use new features in a package without specifying an sdk constraint which ensures -that their code will always be run on an sdk which supports the feature. But in +use new features in a package without specifying an SDK constraint which ensures +that their code will always be run on an SDK which supports the feature. But in the case of a legacy library which references record values or types indirectly -via another library, the sdk constraint on the referenced library is sufficient +via another library, the SDK constraint on the referenced library is sufficient to enforce this.* From a01b093d3e5a0a3a48b6f2eff9f62688ee2b7c0f Mon Sep 17 00:00:00 2001 From: Leaf Petersen Date: Fri, 30 Sep 2022 13:42:43 -0700 Subject: [PATCH 4/6] Address comments --- .../records/records-feature-specification.md | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/accepted/future-releases/records/records-feature-specification.md b/accepted/future-releases/records/records-feature-specification.md index 254ba21877..0b8f047c06 100644 --- a/accepted/future-releases/records/records-feature-specification.md +++ b/accepted/future-releases/records/records-feature-specification.md @@ -594,8 +594,8 @@ which do not have a language version greater than or equal to the language version in which records are released. More specifically, assuming that `v` is the language version in which records are released, the following errors apply. -It is an error to reference the SDK class `Record` in a library whose language -version is less than `v`. +It is an error for the identifier `Record`, resolving to the SDK class `Record`, +to appear syntactically in a library whose language version is less than `v`. It is an error for the record literal syntax (e.g. `(3, 4)`) to be used syntactically in a library whose language version is less than `v`. @@ -603,25 +603,27 @@ syntactically in a library whose language version is less than `v`. It is an error for the record type syntax (e.g. `(int, int)`) to be used syntactically in a library whose language version is less than `v`. -*It is not an error for a library whose language version is less than `v` (a -"legacy library") to include or reference the `Record` class, record types or -record expressions directly or indirectly from another library whose language -version is greater than or equal to `v`. Such a legacy library may reference a -typedef name which is bound to a record type in another library, and the -semantic interpretation of the typedef is as the underlying record type, just as -it would be for any other type. Similarly, type inference may introduce record -types into a legacy library, and such types will be interpreted by the compiler -as record types as usual (that is, there is no erasure implied to remove these -inferred types). Record values may flow into a legacy library via a reference -to a member from another libraries, and a legacy library may freely call getters -on record values (since there is no new syntax for calling a record getter). -The reason for this choice is that the intent of language versioning (for an -additive feature such as records) is to ensure that users do not accidentally -use new features in a package without specifying an SDK constraint which ensures -that their code will always be run on an SDK which supports the feature. But in -the case of a legacy library which references record values or types indirectly -via another library, the SDK constraint on the referenced library is sufficient -to enforce this.* +*Note that the above errors only apply to direct syntactic uses of the new +record syntax in legacy libraries. It is not an error for a library whose +language version is less than `v` (a "legacy library") to include types which +denote or include the `Record` class, record types or record expressions when +these terms arise directly or indirectly from references to another library +whose language version is greater than or equal to `v`. For example, such a +legacy library may reference a typedef name which is bound to a record type in +another library, and the semantic interpretation of the typedef is as the +underlying record type, just as it would be for any other type. Similarly, type +inference may introduce record types into a legacy library, and such types will +be interpreted by the compiler as record types as usual (that is, there is no +erasure implied to remove these inferred types). Record values may flow into a +legacy library via a reference to a member from another library, and a legacy +library may freely call getters on record values (since there is no new syntax +for calling a record getter). The rationale for the choices described in this +section is that the intent of language versioning (for an additive feature such +as records) is to ensure that users do not accidentally use new features in a +package without specifying an SDK constraint which ensures that their code will +always be run on an SDK which supports the feature. But in the case of a legacy +library which references record values or types indirectly via another library, +the SDK constraint on the referenced library is sufficient to enforce this.* ## CHANGELOG From cbb7ac37a4eb71f6f7043d0c780571f83a5d4d07 Mon Sep 17 00:00:00 2001 From: Leaf Petersen Date: Mon, 3 Oct 2022 16:40:45 -0700 Subject: [PATCH 5/6] Address comments --- .../records/records-feature-specification.md | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/accepted/future-releases/records/records-feature-specification.md b/accepted/future-releases/records/records-feature-specification.md index 0b8f047c06..22a166b637 100644 --- a/accepted/future-releases/records/records-feature-specification.md +++ b/accepted/future-releases/records/records-feature-specification.md @@ -594,8 +594,9 @@ which do not have a language version greater than or equal to the language version in which records are released. More specifically, assuming that `v` is the language version in which records are released, the following errors apply. -It is an error for the identifier `Record`, resolving to the SDK class `Record`, -to appear syntactically in a library whose language version is less than `v`. +It is an error for the identifier `Record`, denoting the `Record` class from +`dart:core`, where that import scope name is only imported from platform +libraries, to appear in a library whose language version is less than `v`. It is an error for the record literal syntax (e.g. `(3, 4)`) to be used syntactically in a library whose language version is less than `v`. @@ -614,21 +615,23 @@ another library, and the semantic interpretation of the typedef is as the underlying record type, just as it would be for any other type. Similarly, type inference may introduce record types into a legacy library, and such types will be interpreted by the compiler as record types as usual (that is, there is no -erasure implied to remove these inferred types). Record values may flow into a -legacy library via a reference to a member from another library, and a legacy -library may freely call getters on record values (since there is no new syntax -for calling a record getter). The rationale for the choices described in this -section is that the intent of language versioning (for an additive feature such -as records) is to ensure that users do not accidentally use new features in a -package without specifying an SDK constraint which ensures that their code will -always be run on an SDK which supports the feature. But in the case of a legacy -library which references record values or types indirectly via another library, -the SDK constraint on the referenced library is sufficient to enforce this.* +erasure implied to remove these inferred types). A legacy library may refer to +the `Record` class via a library which has re-exported it. Record values may +flow into a legacy library via a reference to a member from another library, and +a legacy library may freely call getters on record values (since there is no new +syntax for calling a record getter). The rationale for the choices described in +this section is that the intent of language versioning (for an additive feature +such as records) is to ensure that users do not accidentally use new features in +a package without specifying an SDK constraint which ensures that their code +will always be run on an SDK which supports the feature. But in the case of a +legacy library which references record values or types indirectly via another +library, the SDK constraint on the referenced library is sufficient to enforce +this.* ## CHANGELOG -### 1.14 +### 1.15 - Specify the interaction between libraries with a language version that supports records and libraries with older language versions. From d1138c6edb5c7d27d39a5efb833afd9d8fa8deff Mon Sep 17 00:00:00 2001 From: Leaf Petersen Date: Mon, 3 Oct 2022 16:42:40 -0700 Subject: [PATCH 6/6] Merge --- .../future-releases/records/records-feature-specification.md | 1 - 1 file changed, 1 deletion(-) diff --git a/accepted/future-releases/records/records-feature-specification.md b/accepted/future-releases/records/records-feature-specification.md index 8d0829b5ac..88cbf50ba7 100644 --- a/accepted/future-releases/records/records-feature-specification.md +++ b/accepted/future-releases/records/records-feature-specification.md @@ -722,7 +722,6 @@ this.* ### 1.14 - Specify type inference, add static semantics to resources/type-system ->>>>>>> origin/master ### 1.13