Skip to content

Commit 01c3cbe

Browse files
authored
Access to type using specific types and getters. (#2283)
1 parent 2f1f19d commit 01c3cbe

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/src/model/model_element.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ abstract class ModelElement extends Canonicalization
947947
.renderLinkedParams(parameters, showMetadata: false, showNames: false);
948948

949949
ElementType get modelType {
950+
var element = this.element;
950951
if (_modelType == null) {
951952
// TODO(jcollins-g): Need an interface for a "member with a type" (or changed object model).
952953
if (_originalMember != null &&
@@ -962,13 +963,16 @@ abstract class ModelElement extends Canonicalization
962963
_modelType = ElementType.from(
963964
(_originalMember as ParameterMember).type, library, packageGraph);
964965
}
965-
} else if (element is ExecutableElement ||
966-
element is FunctionTypedElement ||
967-
element is ParameterElement ||
968-
element is TypeDefiningElement ||
969-
element is PropertyInducingElement) {
970-
_modelType =
971-
ElementType.from((element as dynamic).type, library, packageGraph);
966+
} else if (element is ClassElement) {
967+
_modelType = ElementType.from(element.thisType, library, packageGraph);
968+
} else if (element is FunctionTypedElement) {
969+
_modelType = ElementType.from(element.type, library, packageGraph);
970+
} else if (element is ParameterElement) {
971+
_modelType = ElementType.from(element.type, library, packageGraph);
972+
} else if (element is PropertyInducingElement) {
973+
_modelType = ElementType.from(element.type, library, packageGraph);
974+
} else {
975+
throw UnimplementedError('(${element.runtimeType}) $element');
972976
}
973977
}
974978
return _modelType;

0 commit comments

Comments
 (0)