@@ -169,8 +169,8 @@ abstract class Generator {
169169
170170 /// Builds a [Expression] representing a read from the generator.
171171 ///
172- /// The read of the this subexpression does _not_ need to support a
173- /// simultaneous write of the same subexpression.
172+ /// The read of this subexpression does _not_ need to support a simultaneous
173+ /// write of the same subexpression.
174174 Expression buildSimpleRead () {
175175 return _finish (_makeSimpleRead (), null );
176176 }
@@ -181,7 +181,7 @@ abstract class Generator {
181181 /// simultaneous write of the same subexpression.
182182 ///
183183 /// This is in contrast to [_makeRead] which is used for instance in compound
184- /// assignments like `a.b = c` where both a read and a write of the
184+ /// assignments like `a.b + = c` where both a read and a write of the
185185 /// subexpression `a.b` occurs.
186186 ///
187187 /// Subclasses that can benefit from this distinction should override this
@@ -440,6 +440,11 @@ abstract class Generator {
440440 }
441441 }
442442
443+ /// Returns a [TypeBuilder] for this subexpression instantiated with the
444+ /// type [arguments] . If no type arguments are provided [arguments] is `null` .
445+ ///
446+ /// The type arguments have not been resolved and should be resolved to
447+ /// create a [TypeBuilder] for a valid type.
443448 TypeBuilder buildTypeWithResolvedArguments (
444449 List <UnresolvedType <TypeBuilder >> arguments) {
445450 NamedTypeBuilder result = new NamedTypeBuilder (token.lexeme, null );
@@ -1647,8 +1652,8 @@ class DeferredAccessGenerator extends Generator {
16471652 @override
16481653 TypeBuilder buildTypeWithResolvedArguments (
16491654 List <UnresolvedType <TypeBuilder >> arguments) {
1650- String name =
1651- "${prefixGenerator . _plainNameForRead }.${ suffixGenerator ._plainNameForRead }" ;
1655+ String name = "${ prefixGenerator . _plainNameForRead }."
1656+ "${suffixGenerator ._plainNameForRead }" ;
16521657 TypeBuilder type =
16531658 suffixGenerator.buildTypeWithResolvedArguments (arguments);
16541659 LocatedMessage message;
@@ -1705,6 +1710,25 @@ class DeferredAccessGenerator extends Generator {
17051710 }
17061711}
17071712
1713+ /// [TypeUseGenerator] represents the subexpression whose prefix is the name of
1714+ /// a class, enum, type variable, typedef, mixin declaration, extension
1715+ /// declaration or built-in type, like dynamic and void.
1716+ ///
1717+ /// For instance:
1718+ ///
1719+ /// class A<T> {}
1720+ /// typedef B = Function();
1721+ /// mixin C<T> on A<T> {}
1722+ /// extension D<T> on A<T> {}
1723+ ///
1724+ /// method<T>() {
1725+ /// C<B> // a TypeUseGenerator is created for `C` and `B`.
1726+ /// B b; // a TypeUseGenerator is created for `B`.
1727+ /// D.foo(); // a TypeUseGenerator is created for `D`.
1728+ /// new A<T>(); // a TypeUseGenerator is created for `A` and `T`.
1729+ /// T(); // a TypeUseGenerator is created for `T`.
1730+ /// }
1731+ ///
17081732class TypeUseGenerator extends ReadOnlyAccessGenerator {
17091733 final TypeDeclarationBuilder declaration;
17101734
@@ -1718,6 +1742,10 @@ class TypeUseGenerator extends ReadOnlyAccessGenerator {
17181742 @override
17191743 TypeBuilder buildTypeWithResolvedArguments (
17201744 List <UnresolvedType <TypeBuilder >> arguments) {
1745+ if (declaration.isExtension) {
1746+ // Extension declarations cannot be used as types.
1747+ return super .buildTypeWithResolvedArguments (arguments);
1748+ }
17211749 if (arguments != null ) {
17221750 int expected = declaration.typeVariablesCount;
17231751 if (arguments.length != expected) {
0 commit comments