Skip to content

Commit

Permalink
#2388. Rename and reorder static_analysis_member_invocation_A06_t* te…
Browse files Browse the repository at this point in the history
…sts (#2397)

Renaming operations:
static_analysis_member_invocation_A06_t03.dart -> *02*
static_analysis_member_invocation_A06_t05.dart -> *03*
static_analysis_member_invocation_A06_t06.dart -> *05*
static_analysis_member_invocation_A06_t07.dart -> *06*
tatic_analysis_member_invocation_A06_t08.dart -> *04*
.. plus a couple of small changes in a `@description`.
  • Loading branch information
sgrekhov authored Nov 24, 2023
1 parent 85c868a commit 24af6b9
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 132 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2023, 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.

/// @assertion We say that an extension type declaration DV has an extension
/// type member named n in the cases where:
/// - DV declares a member named n.
/// - DV has no such declaration, but DV has a direct extension type
/// superinterface V that has an extension type member named n due to a member
/// declaration DM2, and DV does not declare a member that precludes DM2.
///
/// @description Checks that if an extension type `ET` has a superinterface with
/// a member `m` then this member is also present in `ET` but members of its
/// representation type are not
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=inline-class

extension type ET0(int id) {
void m1() {}
int get m2 => 42;
void set m3(int val) {}
}

extension type ET1(int id) implements ET0 {}

main() {
ET1 et1 = ET1(42);
et1.m1();
et1.m2;
et1.m3 = 42;
et1.ceil();
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,65 @@
/// superinterface V that has an extension type member named n due to a member
/// declaration DM2, and DV does not declare a member that precludes DM2.
///
/// @description Checks that if an extension type `ET` has a superinterface with
/// a member `m` then this member is also present in `ET` but members of its
/// representation type are not
/// @description Checks that a getter doesn't preclude setter and vice versa
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=inline-class

extension type ET0(int id) {
void m1() {}
int get m2 => 42;
void set m3(int val) {}
import "../../Utils/expect.dart";

String log = "";

extension type V1(int _) {
String get n => "V1";
}

extension type V2(int _) {
void set n(String n) {
log = "V2: $n";
}
}

extension type ET1(int id) implements ET0 {}
extension type V0(int _) implements V1, V2 {}

extension type ET1(V1 _) implements V1 {
void set n(String v) {
log = "ET1: $v";
}
}

extension type ET2(V2 _) implements V2 {
String get n => "ET2";
}

extension type ET3(V0 _) implements V1, V2 {
String get n => "ET3";
}

extension type ET4(V0 _) implements V1, V2 {
void set n(String v) {
log = "ET4: $v";
}
}

main() {
ET1 et1 = ET1(42);
et1.m1();
et1.m2;
et1.m3 = 42;
et1.ceil();
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified
final v = V0(0);
Expect.equals("V1", ET1(v).n);
ET1(v).n = "a";
Expect.equals("ET1: a", log);
log = "";

Expect.equals("ET2", ET2(v).n);
ET2(v).n = "b";
Expect.equals("V2: b", log);
log = "";

Expect.equals("ET3", ET3(v).n);
ET3(v).n = "c";
Expect.equals("V2: c", log);
log = "";

Expect.equals("V1", ET4(v).n);
ET4(v).n = "d";
Expect.equals("ET4: d", log);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
/// superinterface V that has an extension type member named n due to a member
/// declaration DM2, and DV does not declare a member that precludes DM2.
///
/// @description Checks that a getter doesn't preclude setter and vice versa
/// @description Checks that an extension type declares a method or setter then
/// they may preclude inherited members
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=inline-class
Expand All @@ -19,55 +20,41 @@ import "../../Utils/expect.dart";
String log = "";

extension type V1(int _) {
String get n => "V1";
String n() => "V1";
}

extension type V2(int _) {
void set n(String n) {
log = "V2: $n";
void set n(String v) {
log = "V2: $v";
}
}

extension type V0(int _) implements V1, V2 {}

extension type ET1(V1 _) implements V1 {
void set n(String v) {
log = "ET1: $v";
}
}

extension type ET2(V2 _) implements V2 {
String get n => "ET2";
String n() => "ET2";
}

extension type ET3(V0 _) implements V1, V2 {
String get n => "ET3";
extension type ET3(V1 _) implements V1 {
void set n(int v) {
log = "ET3: $v";
}
}

extension type ET4(V0 _) implements V1, V2 {
void set n(String v) {
log = "ET4: $v";
}
extension type ET4(V2 _) implements V2 {
T n<T>(T t) => t;
}

main() {
final v = V0(0);
Expect.equals("V1", ET1(v).n);
ET1(v).n = "a";
Expect.equals("ET1: a", log);
ET1(V1(0)).n = "1";
Expect.equals("ET1: 1", log);
log = "";

Expect.equals("ET2", ET2(v).n);
ET2(v).n = "b";
Expect.equals("V2: b", log);
log = "";

Expect.equals("ET3", ET3(v).n);
ET3(v).n = "c";
Expect.equals("V2: c", log);
log = "";

Expect.equals("V1", ET4(v).n);
ET4(v).n = "d";
Expect.equals("ET4: d", log);
Expect.equals("ET2", ET2(V2(0)).n());
ET3(V1(0)).n = 3;
Expect.equals("ET3: 3", log);
Expect.equals(42, ET4(V2(0)).n<int>(42));
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,55 @@
/// superinterface V that has an extension type member named n due to a member
/// declaration DM2, and DV does not declare a member that precludes DM2.
///
/// @description Checks that an extension type declares a method or setter then
/// they preclude inherited members
/// @description Checks that if an extension type declares a method or setter
/// and they preclude inherited members then the attempt to call of those
/// precluded members is a compile-time error
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=inline-class

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

String log = "";

extension type V1(int _) {
String n() => "V1";
}

extension type V2(int _) {
void set n(String v) {
log = "V2: $v";
}
void set n(String v) {}
}

extension type ET1(V1 _) implements V1 {
void set n(String v) {
log = "ET1: $v";
}
void set n(String v) {}
}

extension type ET2(V2 _) implements V2 {
String n() => "ET2";
}

extension type ET3(V1 _) implements V1 {
void set n(int v) {
log = "ET3: $v";
}
void set n(int v) {}
}

extension type ET4(V2 _) implements V2 {
T n<T>(T t) => t;
int n() => 42;
}

main() {
ET1(V1(0)).n = "1";
Expect.equals("ET1: 1", log);
log = "";
Expect.equals("ET2", ET2(V2(0)).n());
ET3(V1(0)).n = 3;
Expect.equals("ET3: 3", log);
Expect.equals(42, ET4(V2(0)).n<int>(42));
ET1(V1(0)).n();
// ^
// [analyzer] unspecified
// [cfe] unspecified

ET2(V2(0)).n = "42";
// ^
// [analyzer] unspecified
// [cfe] unspecified

ET3(V1(0)).n();
// ^
// [analyzer] unspecified
// [cfe] unspecified

ET4(V2(0)).n = "42";
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

This file was deleted.

0 comments on commit 24af6b9

Please sign in to comment.