Skip to content

Commit 3d4bd85

Browse files
committed
[cfe] Add test for type context in cascade
The question of whether type context was correctly passed through cascade arose during debugging. Added a test to verify that we handle it correctly. Change-Id: Ic828296815f7e08af18d9cc8e0708dbc929a20f8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155329 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
1 parent 22dc855 commit 3d4bd85

6 files changed

+65
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
T f<T>() => null;
6+
7+
test() {
8+
int v1 = f();
9+
int v2 = f()..isEven;
10+
int v3 = f()
11+
..isEven
12+
..isEven;
13+
}
14+
15+
main() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
static method f<T extends core::Object* = dynamic>() → self::f::T*
6+
;
7+
static method test() → dynamic
8+
;
9+
static method main() → dynamic
10+
;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
static method f<T extends core::Object* = dynamic>() → self::f::T*
6+
return null;
7+
static method test() → dynamic {
8+
core::int* v1 = self::f<core::int*>();
9+
core::int* v2 = let final core::int* #t1 = self::f<core::int*>() in block {
10+
#t1.{core::int::isEven};
11+
} =>#t1;
12+
core::int* v3 = let final core::int* #t2 = self::f<core::int*>() in block {
13+
#t2.{core::int::isEven};
14+
#t2.{core::int::isEven};
15+
} =>#t2;
16+
}
17+
static method main() → dynamic {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
static method f<T extends core::Object* = dynamic>() → self::f::T*
6+
return null;
7+
static method test() → dynamic {
8+
core::int* v1 = self::f<core::int*>();
9+
core::int* v2 = let final core::int* #t1 = self::f<core::int*>() in block {
10+
#t1.{core::int::isEven};
11+
} =>#t1;
12+
core::int* v3 = let final core::int* #t2 = self::f<core::int*>() in block {
13+
#t2.{core::int::isEven};
14+
#t2.{core::int::isEven};
15+
} =>#t2;
16+
}
17+
static method main() → dynamic {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
T f<T>() => null;
2+
test() {}
3+
main() {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
T f<T>() => null;
2+
main() {}
3+
test() {}

0 commit comments

Comments
 (0)