mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 13:08:01 +00:00
Extension types. Tests for type literal.
Change-Id: I552119f6d2ff913c112d89cdf892ca7cbfdbef48 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319581 Reviewed-by: Phil Quitslund <pquitslund@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
0540ac84e1
commit
49ec5d5e7a
|
@ -326,6 +326,64 @@ TypeLiteral
|
|||
''');
|
||||
}
|
||||
|
||||
test_extensionType() async {
|
||||
await assertNoErrorsInCode('''
|
||||
extension type A<T>(T it) {}
|
||||
final v = A<int>;
|
||||
''');
|
||||
|
||||
final node = findNode.typeLiteral('A<int>;');
|
||||
assertResolvedNodeText(node, r'''
|
||||
TypeLiteral
|
||||
type: NamedType
|
||||
name: A
|
||||
typeArguments: TypeArgumentList
|
||||
leftBracket: <
|
||||
arguments
|
||||
NamedType
|
||||
name: int
|
||||
element: dart:core::@class::int
|
||||
type: int
|
||||
rightBracket: >
|
||||
element: self::@extensionType::A
|
||||
type: A<int>
|
||||
staticType: Type
|
||||
''');
|
||||
}
|
||||
|
||||
test_extensionType_importPrefix() async {
|
||||
newFile('$testPackageLibPath/a.dart', '''
|
||||
extension type A<T>(T it) {}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
import 'a.dart' as a;
|
||||
var t = a.A<int>;
|
||||
''');
|
||||
|
||||
final node = findNode.typeLiteral('A<int>;');
|
||||
assertResolvedNodeText(node, r'''
|
||||
TypeLiteral
|
||||
type: NamedType
|
||||
importPrefix: ImportPrefixReference
|
||||
name: a
|
||||
period: .
|
||||
element: self::@prefix::a
|
||||
name: A
|
||||
typeArguments: TypeArgumentList
|
||||
leftBracket: <
|
||||
arguments
|
||||
NamedType
|
||||
name: int
|
||||
element: dart:core::@class::int
|
||||
type: int
|
||||
rightBracket: >
|
||||
element: package:test/a.dart::@extensionType::A
|
||||
type: A<int>
|
||||
staticType: Type
|
||||
''');
|
||||
}
|
||||
|
||||
test_functionAlias() async {
|
||||
await assertNoErrorsInCode('''
|
||||
typedef Fn<T> = void Function(T);
|
||||
|
|
Loading…
Reference in a new issue