Skip to content
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

#1400. File delete/rename commit #2072

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion If e is an expression whose static type V is the inline type
/// Inline<T1, .. Ts> and m is the name of a member that V has, a member access
/// like e.m(args) is treated as an invocation of the inline member m on the
/// receiver e according to the inline type Inline and with the actual type
/// arguments T1, ..., Ts, with the actual argument part args.
/// Inline<T1, .. Ts> and V has no member whose basename is the basename of m,
/// a member access like e.m(args) may be an extension member access, following
/// the normal rules about applicability and accessibility of extensions, in
/// particular that V must match the on-type of the extension.
///
/// @description Checks that a member access `e.m(args)` is treated as an
/// invocation of the inline member m on the receiver `e` according to the
/// inline type `Inline` and with the actual type arguments `T1, ..., Ts`, with
/// the actual argument part `args`.
/// @description Checks that if `V` has no member with the name `m`, but there
/// is an extension member `m` then it is invoked
/// @author [email protected]

// SharedOptions=--enable-experiment=inline-class

import "../../Utils/static_type_helper.dart";
import "../../Utils/expect.dart";

inline class V1<T> {
final T id;
V1(this.id);
extension Ex1 on V {
String foo() => "Ex1.foo()";
}

(Map<K, V>, T) asMap<K, V>() => (<K, V>{}, id);
extension Ex2 on int {
String bar() => "Ex2.bar()";
}

main() {
V1<num> v1 = V1(42);
v1.asMap<String, bool>()
.expectStaticType<Exactly<(Map<String, bool>, num)>>();
inline class V {
final int id;
V(this.id);
}

V1<String> v2 = V1("42");
v2.asMap<String, String>()
.expectStaticType<Exactly<(Map<String, String>, String)>>();
main() {
V v = V(42);
Expect.equals("Ex1.foo()", v.foo());
Expect.equals("Ex2.bar()", v.id.bar());
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@
// 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 Similarly, e.m is treated an invocation of the inline member m on
/// the receiver e according to the inline type Inline and with the actual type
/// arguments T1, ..., Ts and no actual argument part.
/// @assertion Let DV be an inline class declaration named Inline with type
/// parameters X1 extends B1, .. Xs extends Bs. Assume that DV declares a final
/// instance variable with name id and type R.
///
/// @description Checks that a member access `e.m` is treated as an invocation
/// of the inline member `m` on the receiver `e` according to the inline type
/// `Inline` and with the actual type arguments `T1, ..., Ts` and no actual
/// argument part
/// We say that the declared representation type of Inline is R, and the
/// instantiated representation type corresponding to Inline<T1,.. Ts> is
/// [T1/X1, .. Ts/Xs]R.
/// ...
/// Let V be an inline type of the form Inline<T1, .. Ts>, and let R be the
/// corresponding instantiated representation type. If R is non-nullable then V
/// is a proper subtype of Object, and V is non-nullable. Otherwise, V is a
/// proper subtype of Object?, and V is potentially nullable.
///
/// @description Checks that if an instantiated representation type `R` is
/// non-nullable then it is not an error to assign it to `Object`
/// @author [email protected]

// SharedOptions=--enable-experiment=inline-class

import "../../Utils/static_type_helper.dart";

inline class V1<T, K, V> {
final T id;
inline class V1 {
final int id;
V1(this.id);
}

(Map<K, V>, T) get asMap => (<K, V>{}, id);
inline class V2<T1, T2 extends num?> {
final T1 id;
V2(this.id);
}

main() {
V1<num, String, bool> v1 = V1(42);
v1.asMap.expectStaticType<Exactly<(Map<String, bool>, num)>>();

V1<String, String, Null> v2 = V1("42");
v2.asMap.expectStaticType<Exactly<(Map<String, Null>, String)>>();
Object v1 = V1(42);
Object v2 = V2<String?, int?>("42");
}

This file was deleted.

This file was deleted.