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

#2477. Add more constant evaluation tests #2484

Merged
merged 2 commits into from
Jan 17, 2024
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
@@ -0,0 +1,39 @@
// Copyright (c) 2024, 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 The extension type erasure of an extension type V is obtained by
/// recursively replacing every subterm of V which is an extension type by the
/// corresponding representation type.
///
/// Let X1 extends B1, .. Xs extends Bs be a declaration of the type parameters
/// of a generic entity (it could be a generic class, extension type, mixin,
/// typedef, or function). Let BBj be the extension type erasure of
/// Bj, for j in 1 .. s. It is a compile-time error if
/// X1 extends BB1, .. Xs extends BBs has any compile-time errors.
///
/// @description Check that the erasure of an extension type `V` is obtained by
/// recursively replacing every subterm of `V` which is an extension type by the
/// corresponding representation type.
/// @author sgrekhov22@gmail.com

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

class Check {
const Check(Object? v, {required Object? eq})
: assert(v == eq, "Not equal ${(v, eq: eq)}");
}

extension type const Ext1(Object? value) {}
extension type const Ext2(Object value) implements Object {}

void main() {
const Check([Ext1(1)], eq: <Object?>[1,]);
const Check([Ext2(1)], eq: <Object>[1,]);
const Check({Ext1(1)}, eq: <Object?>{1,});
const Check({Ext2(1)}, eq: <Object>{1,});
const Check({Ext1(1): Ext1(2)}, eq: <Object?, Object?>{1: 2});
const Check({Ext2(1): Ext1(2)}, eq: <Object, Object?>{1: 2});
const Check({Ext1(1): Ext2(2)}, eq: <Object?, Object>{1: 2});
const Check({Ext2(1): Ext2(2)}, eq: <Object, Object>{1: 2});
eernstg marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2024, 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 The extension type erasure of an extension type V is obtained by
/// recursively replacing every subterm of V which is an extension type by the
/// corresponding representation type.
///
/// Let X1 extends B1, .. Xs extends Bs be a declaration of the type parameters
/// of a generic entity (it could be a generic class, extension type, mixin,
/// typedef, or function). Let BBj be the extension type erasure of
/// Bj, for j in 1 .. s. It is a compile-time error if
/// X1 extends BB1, .. Xs extends BBs has any compile-time errors.
///
/// @description Check that the erasure of an extension type `V` is obtained by
/// recursively replacing every subterm of `V` which is an extension type by the
/// corresponding representation type.
/// @author sgrekhov22@gmail.com

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

class Check {
const Check(Object? v, {required Object? eq})
: assert(v == eq, "Not equal ${(v, eq: eq)}");
}

extension type const IntET1(int _) {}
extension type const IntET2(int _) implements int {}

extension type const MapET1<X>(Map<IntET1, X> _) {}
extension type const MapET2<X>(Map<IntET2, X> _) {}

void main() {
const Check([MapET1<List<IntET1>>({})], eq: [<int, List<int>>{}]);
const Check([MapET1<List<IntET2>>({})], eq: [<int, List<int>>{}]);
const Check([MapET2<List<IntET1>>({})], eq: [<int, List<int>>{}]);
const Check([MapET2<List<IntET2>>({})], eq: [<int, List<int>>{}]);
}