[ddc] Avoid adding raw type parameters to type table

There is no need to add a single type parameter to the type table
because it is already represented as a local variable in the scope
where it appears.

Change-Id: I4553d54304a2e3b82e856b8511fdce81cda0653e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324901
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Nicholas Shahan 2023-09-11 21:00:47 +00:00 committed by Commit Queue
parent db214e8c81
commit 1cce9b8052

View file

@ -3366,7 +3366,14 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
normalizedType, _currentTypeEnvironment);
var typeRep =
evalInEnvironment(result.requiredEnvironment, result.recipe);
if (_cacheTypes) typeRep = _typeTable.nameType(normalizedType, typeRep);
if (_cacheTypes &&
// Avoid adding a the use of a single type parameter to the type
// table. These can be referenced directly because the are already
// represented as a local variable in the scope.
!(normalizedType is TypeParameterType &&
normalizedType.isPotentiallyNonNullable)) {
typeRep = _typeTable.nameType(normalizedType, typeRep);
}
return typeRep;
} on UnsupportedError catch (e) {
_typeCompilationError(normalizedType, e.message ?? 'Unknown Error');