Skip to content

Commit

Permalink
dart-lang#1400. File delete/rename commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Jun 2, 2023
1 parent e43ef65 commit 7eb903c
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 110 deletions.
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 sgrekhov22@gmail.com
// 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 sgrekhov22@gmail.com
// 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.

0 comments on commit 7eb903c

Please sign in to comment.