Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 44fa3b9

Browse files
author
Dart CI
committed
Version 2.11.0-201.0.dev
Merge commit '34e4a6d814c54fabdb209e5368b6d01bb55b8dd4' into 'dev'
2 parents 98ea0b4 + 34e4a6d commit 44fa3b9

File tree

4 files changed

+103
-4
lines changed

4 files changed

+103
-4
lines changed

pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,9 +2361,7 @@ class ConstantEvaluator extends RecursiveVisitor<Constant> {
23612361

23622362
@override
23632363
Constant visitIsExpression(IsExpression node) {
2364-
// TODO(jensj): Why does this call .accept directly?
2365-
// (@askesc says it's probably an oversight)
2366-
final Constant constant = node.operand.accept(this);
2364+
final Constant constant = _evaluateSubexpression(node.operand);
23672365
if (constant is AbortConstant) return constant;
23682366
if (shouldBeUnevaluated) {
23692367
return unevaluated(
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import '../static_type_helper.dart';
6+
7+
// Test least upper bound for a type variable with an F-bound.
8+
9+
bool condition = true;
10+
11+
class A<X extends A<X, X>?, Y extends A<Y, Y>?> {
12+
X x;
13+
late Y y;
14+
15+
A(this.x);
16+
17+
void m(X x, Y y) {
18+
// UP(X extends A<X, X>?, Y extends A<Y, Y>?) ==
19+
// A<Object?, Object?>?.
20+
var z = condition ? x : y;
21+
z.expectStaticType<Exactly<A<Object?, Object?>?>>();
22+
23+
// Distinguish top types.
24+
if (z == null) throw 0;
25+
var zx = z.x, zy = z.y;
26+
27+
// Not `dynamic`, not `void`.
28+
zx?.whatever;
29+
// ^^^^^^^^
30+
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
31+
// [cfe] The getter 'whatever' isn't defined for the class 'Object'.
32+
zy?.whatever;
33+
// ^^^^^^^^
34+
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
35+
// [cfe] The getter 'whatever' isn't defined for the class 'Object'.
36+
37+
if (zx == null || zy == null) throw 0;
38+
zx.expectStaticType<Exactly<Object>>();
39+
zy.expectStaticType<Exactly<Object>>();
40+
}
41+
}
42+
43+
class B<X> extends A<B<X>?, B<X>?> {
44+
B() : super(null);
45+
}
46+
47+
void main() {
48+
var b = B<Null>();
49+
b.m(b, null);
50+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Test least upper bound for a Function type and a type that doesn't match
6+
// any of the cases for function types being subtypes of each other.
7+
8+
import 'dart:async';
9+
import '../static_type_helper.dart';
10+
11+
bool condition = true;
12+
13+
void main() {
14+
void f1(void Function() x, Object y) {
15+
var z = condition ? x : y;
16+
z.expectStaticType<Exactly<Object>>();
17+
}
18+
19+
void f2(int x, void Function<X>() y) {
20+
var z = condition ? x : y;
21+
z.expectStaticType<Exactly<Object>>();
22+
}
23+
24+
void f3(double Function(int, int) x, FutureOr<Function> y) {
25+
var z = condition ? x : y;
26+
z.expectStaticType<Exactly<Object>>();
27+
}
28+
29+
void f4(FutureOr<Function?> x, Function(int i, {int j}) y) {
30+
var z = condition ? x : y;
31+
z.expectStaticType<Exactly<Object?>>();
32+
}
33+
34+
void f5(Function Function<Y>([Y y]) x, dynamic y) {
35+
var z = condition ? x : y;
36+
// Check that the type is a top type.
37+
z.expectStaticType<Exactly<dynamic>>();
38+
// Check that the type is `dynamic`.
39+
z.unknownMember;
40+
}
41+
42+
void f6(Never x, Never Function() y) {
43+
var z = condition ? x : y;
44+
z.expectStaticType<Exactly<Never Function()>>();
45+
}
46+
47+
void f7(Function(Function) x, Null y) {
48+
var z = condition ? x : y;
49+
z.expectStaticType<Exactly<Object?>>();
50+
}
51+
}

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 11
2929
PATCH 0
30-
PRERELEASE 200
30+
PRERELEASE 201
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)