Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #3784 into an 8.0.9+1 release #3799

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 8.0.9+1

* Fix referencing an aliased type parameter. (#3784)

## 8.0.9

* Deprecate the `missingCodeBlockLanguage` warning. This is replaced with the
Expand Down
2 changes: 1 addition & 1 deletion dartdoc_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dartdoc:
linkToSource:
root: '.'
uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/v8.0.9/%f%#L%l%'
uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/v8.0.9+1/%f%#L%l%'
32 changes: 20 additions & 12 deletions lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,28 @@ abstract class DefinedElementType extends ElementType {

factory DefinedElementType._from(DartType type, ModelElement modelElement,
Library library, PackageGraph packageGraph) {
// `TypeAliasElement.alias.element` has different implications.
// In that case it is an actual type alias of some kind (generic or
// otherwise). Here however `alias.element` signals that this is a type
// referring to an alias.
if (type is! TypeAliasElement && type.alias != null) {
return AliasedElementType._(
type as ParameterizedType, library, packageGraph, modelElement);
// Here, `alias.element` signals that this is a type referring to an
// alias. (`TypeAliasElement.alias.element` has different implications.
// In that case it is an actual type alias of some kind (generic or
// otherwise).)
return switch (type) {
TypeParameterType() =>
TypeParameterElementType._(type, library, packageGraph, modelElement),
ParameterizedType() =>
AliasedElementType._(type, library, packageGraph, modelElement),
_ => throw UnimplementedError(
'No ElementType implemented for aliased ${type.runtimeType}'),
};
}
if (type is TypeParameterType) {
return TypeParameterElementType._(
type, library, packageGraph, modelElement);
}
return ParameterizedElementType._(
type as ParameterizedType, library, packageGraph, modelElement);
return switch (type) {
TypeParameterType() =>
TypeParameterElementType._(type, library, packageGraph, modelElement),
ParameterizedType() =>
ParameterizedElementType._(type, library, packageGraph, modelElement),
_ => throw UnimplementedError(
'No ElementType implemented for ${type.runtimeType}'),
};
}

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const packageVersion = '8.0.9';
const packageVersion = '8.0.9+1';
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: dartdoc
version: 8.0.9
version: 8.0.9+1
description: A non-interactive HTML documentation generator for Dart source code.
repository: https://github.com/dart-lang/dartdoc

Expand Down
15 changes: 15 additions & 0 deletions test/typedef_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ typedef T = C;
expect(tTypedef.aliasedType, isA<InterfaceType>());
}

void test_extensionType_generic_referenceToTypeParameter() async {
var library = await bootPackageWithLibrary('''
typedef TD<T> = T;

/// Text [T].
extension type ET<T>(TD<T> _) {}
''');

expect(
library.extensionTypes.named('ET').documentationAsHtml,
// There is no way to link to a type parameter.
contains('<p>Text <code>T</code>.</p>'),
);
}

void test_extensionType_basic() async {
var library = await bootPackageWithLibrary('''
extension type E(int i) {}
Expand Down