1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 12:06:26 +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:
Konstantin Shcheglov 2023-08-09 18:46:08 +00:00
parent 0540ac84e1
commit 49ec5d5e7a

View File

@ -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);