-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Allow generic types in arguments and bounds under a flag
The flag that enables the feature is the 'generic-metadata' experiment flag. Bug: #44916 Change-Id: I2770c672280831bf5af6643fde9cb0f1be3083b8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188701 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Dmitry Stefantsov <[email protected]>
- Loading branch information
1 parent
bec37f1
commit c83d879
Showing
27 changed files
with
566 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
pkg/front_end/testcases/generic_metadata/inferred_generic_types_in_arguments_and_bounds.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
class A<X> {} | ||
|
||
A<Y> foo<Y>(Y y) => throw 42; | ||
|
||
test() { | ||
var x = foo(<Z>(Z) => throw 42); | ||
var y = [foo]; | ||
var z = {y.first}; | ||
} | ||
|
||
main() {} |
25 changes: 25 additions & 0 deletions
25
...tcases/generic_metadata/inferred_generic_types_in_arguments_and_bounds.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:collection" as col; | ||
|
||
class A<X extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::X%> | ||
: super core::Object::•() | ||
; | ||
} | ||
static method foo<Y extends core::Object? = dynamic>(self::foo::Y% y) → self::A<self::foo::Y%> | ||
return throw 42; | ||
static method test() → dynamic { | ||
self::A<<Z extends core::Object? = dynamic>(dynamic) → Never> x = self::foo<<Z extends core::Object? = dynamic>(dynamic) → Never>(<Z extends core::Object? = dynamic>(dynamic Z) → Never => throw 42); | ||
core::List<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> y = <<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>>[#C1]; | ||
core::Set<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> z = block { | ||
final core::Set<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> #t1 = col::LinkedHashSet::•<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>>(); | ||
#t1.{core::Set::add}{Invariant}(y.{core::Iterable::first}); | ||
} =>#t1; | ||
} | ||
static method main() → dynamic {} | ||
|
||
constants { | ||
#C1 = tearoff self::foo | ||
} |
25 changes: 25 additions & 0 deletions
25
...ic_metadata/inferred_generic_types_in_arguments_and_bounds.dart.strong.transformed.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:collection" as col; | ||
|
||
class A<X extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::X%> | ||
: super core::Object::•() | ||
; | ||
} | ||
static method foo<Y extends core::Object? = dynamic>(self::foo::Y% y) → self::A<self::foo::Y%> | ||
return throw 42; | ||
static method test() → dynamic { | ||
self::A<<Z extends core::Object? = dynamic>(dynamic) → Never> x = self::foo<<Z extends core::Object? = dynamic>(dynamic) → Never>(<Z extends core::Object? = dynamic>(dynamic Z) → Never => throw 42); | ||
core::List<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> y = core::_GrowableList::_literal1<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>>(#C1); | ||
core::Set<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> z = block { | ||
final core::Set<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> #t1 = new col::_CompactLinkedHashSet::•<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>>(); | ||
#t1.{core::Set::add}{Invariant}(y.{core::Iterable::first}); | ||
} =>#t1; | ||
} | ||
static method main() → dynamic {} | ||
|
||
constants { | ||
#C1 = tearoff self::foo | ||
} |
5 changes: 5 additions & 0 deletions
5
...neric_metadata/inferred_generic_types_in_arguments_and_bounds.dart.textual_outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class A<X> {} | ||
|
||
A<Y> foo<Y>(Y y) => throw 42; | ||
test() {} | ||
main() {} |
6 changes: 6 additions & 0 deletions
6
...adata/inferred_generic_types_in_arguments_and_bounds.dart.textual_outline_modelled.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
A<Y> foo<Y>(Y y) => throw 42; | ||
|
||
class A<X> {} | ||
|
||
main() {} | ||
test() {} |
25 changes: 25 additions & 0 deletions
25
...estcases/generic_metadata/inferred_generic_types_in_arguments_and_bounds.dart.weak.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:collection" as col; | ||
|
||
class A<X extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::X%> | ||
: super core::Object::•() | ||
; | ||
} | ||
static method foo<Y extends core::Object? = dynamic>(self::foo::Y% y) → self::A<self::foo::Y%> | ||
return throw 42; | ||
static method test() → dynamic { | ||
self::A<<Z extends core::Object? = dynamic>(dynamic) → Never> x = self::foo<<Z extends core::Object? = dynamic>(dynamic) → Never>(<Z extends core::Object? = dynamic>(dynamic Z) → Never => throw 42); | ||
core::List<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> y = <<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>>[#C1]; | ||
core::Set<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> z = block { | ||
final core::Set<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> #t1 = col::LinkedHashSet::•<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>>(); | ||
#t1.{core::Set::add}{Invariant}(y.{core::Iterable::first}); | ||
} =>#t1; | ||
} | ||
static method main() → dynamic {} | ||
|
||
constants { | ||
#C1 = tearoff self::foo | ||
} |
14 changes: 14 additions & 0 deletions
14
.../generic_metadata/inferred_generic_types_in_arguments_and_bounds.dart.weak.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class A<X extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::X%> | ||
; | ||
} | ||
static method foo<Y extends core::Object? = dynamic>(self::foo::Y% y) → self::A<self::foo::Y%> | ||
; | ||
static method test() → dynamic | ||
; | ||
static method main() → dynamic | ||
; |
25 changes: 25 additions & 0 deletions
25
...eric_metadata/inferred_generic_types_in_arguments_and_bounds.dart.weak.transformed.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:collection" as col; | ||
|
||
class A<X extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::X%> | ||
: super core::Object::•() | ||
; | ||
} | ||
static method foo<Y extends core::Object? = dynamic>(self::foo::Y% y) → self::A<self::foo::Y%> | ||
return throw 42; | ||
static method test() → dynamic { | ||
self::A<<Z extends core::Object? = dynamic>(dynamic) → Never> x = self::foo<<Z extends core::Object? = dynamic>(dynamic) → Never>(<Z extends core::Object? = dynamic>(dynamic Z) → Never => throw 42); | ||
core::List<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> y = core::_GrowableList::_literal1<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>>(#C1); | ||
core::Set<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> z = block { | ||
final core::Set<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>> #t1 = new col::_CompactLinkedHashSet::•<<Y extends core::Object? = dynamic>(Y%) → self::A<Y%>>(); | ||
#t1.{core::Set::add}{Invariant}(y.{core::Iterable::first}); | ||
} =>#t1; | ||
} | ||
static method main() → dynamic {} | ||
|
||
constants { | ||
#C1 = tearoff self::foo | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/front_end/testcases/generic_metadata/simple_generic_types_in_arguments_and_bounds.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
class A<X> {} | ||
|
||
A<Function<Y>(Y)> foo(A<Function<Y>(Y)> x) => throw 42; | ||
|
||
class B extends A<Function<Y>(Y)> {} | ||
|
||
class C<Z extends Function<Y>(Y)> {} | ||
|
||
bar<V extends Function<Y>(Y)>() => throw 42; | ||
|
||
main() {} |
24 changes: 24 additions & 0 deletions
24
...estcases/generic_metadata/simple_generic_types_in_arguments_and_bounds.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class A<X extends core::Object? = dynamic> extends core::Object { | ||
synthetic constructor •() → self::A<self::A::X%> | ||
: super core::Object::•() | ||
; | ||
} | ||
class B extends self::A<<Y extends core::Object? = dynamic>(Y%) → dynamic> { | ||
synthetic constructor •() → self::B | ||
: super self::A::•() | ||
; | ||
} | ||
class C<Z extends <Y extends core::Object? = dynamic>(Y%) → dynamic = <Y extends core::Object? = dynamic>(Y%) → dynamic> extends core::Object { | ||
synthetic constructor •() → self::C<self::C::Z> | ||
: super core::Object::•() | ||
; | ||
} | ||
static method foo(self::A<<Y extends core::Object? = dynamic>(Y%) → dynamic> x) → self::A<<Y extends core::Object? = dynamic>(Y%) → dynamic> | ||
return throw 42; | ||
static method bar<V extends <Y extends core::Object? = dynamic>(Y%) → dynamic = <Y extends core::Object? = dynamic>(Y%) → dynamic>() → dynamic | ||
return throw 42; | ||
static method main() → dynamic {} |
Oops, something went wrong.