Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Issue 3010943002: Add ability to look up type parameters that are associated with ClassEntities with the element envi… (Closed)

Created:
3 years, 3 months ago by Emily Fortuna
Modified:
3 years, 3 months ago
Reviewers:
Johnni Winther
CC:
reviews_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Add ability to look up type parameters that are associated with ClassEntities with the element environment. BUG=

Patch Set 1 #

Total comments: 8

Patch Set 2 : . #

Unified diffs Side-by-side diffs Delta from patch set Stats (+78 lines, -87 lines) Patch
M pkg/compiler/lib/src/ssa/optimize.dart View 1 2 chunks +6 lines, -3 lines 0 comments Download
M tests/corelib_2/corelib_2.status View 1 2 chunks +8 lines, -6 lines 0 comments Download
M tests/language/language_dart2js.status View 1 26 chunks +64 lines, -78 lines 0 comments Download

Messages

Total messages: 6 (3 generated)
Emily Fortuna
Suggestion for a different name other than "getTypeVariables" is welcome. :-P
3 years, 3 months ago (2017-09-02 00:52:55 UTC) #2
Johnni Winther
lgtm https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/common_elements.dart File pkg/compiler/lib/src/common_elements.dart (right): https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/common_elements.dart#newcode1358 pkg/compiler/lib/src/common_elements.dart:1358: List<DartType> getTypeVariables(ClassEntity cls); [getClassTypeVariables] is probably better since ...
3 years, 3 months ago (2017-09-04 06:59:56 UTC) #3
Emily Fortuna
3 years, 3 months ago (2017-09-05 17:13:31 UTC) #4
https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/common...
File pkg/compiler/lib/src/common_elements.dart (right):

https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/common...
pkg/compiler/lib/src/common_elements.dart:1358: List<DartType>
getTypeVariables(ClassEntity cls);
On 2017/09/04 06:59:56, Johnni Winther wrote:
> [getClassTypeVariables] is probably better since methods can also have type
> variables.

Done.

https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/kernel...
File pkg/compiler/lib/src/kernel/element_map_impl.dart (right):

https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/kernel...
pkg/compiler/lib/src/kernel/element_map_impl.dart:258: .map((ir.TypeParameter
type) => getDartType(type.bound));
On 2017/09/04 06:59:56, Johnni Winther wrote:
> This is not the correct implementation.
> 
> class C<T extends String> {}
> 
> for this class [getTypeVariables] would return `[String]` and not `[T]`.
> 
> The correct implementation can be implementated directly in the element
> environment (see comment below).

Done.

https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/kernel...
pkg/compiler/lib/src/kernel/element_map_impl.dart:1289: :
elementMap.getTypeVariables(irClass);
On 2017/09/04 06:59:56, Johnni Winther wrote:
> This method can be implemented using the current interface:
> 
> List<DartType> getTypeVariables(ClassEntity cls) =>
>     getThisType(cls).typeArguments;

Done.

https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/ssa/op...
File pkg/compiler/lib/src/ssa/optimize.dart (right):

https://codereview.chromium.org/3010943002/diff/1/pkg/compiler/lib/src/ssa/op...
pkg/compiler/lib/src/ssa/optimize.dart:1222: .length) {
On 2017/09/04 06:59:56, Johnni Winther wrote:
> If we replace this by
> 
> if (node.inputs.length !=
>     _closedWorld.elementEnvironment
>         .getThisType(contextClass).typeArguments.length) {
> 
> we can avoid the need for the [getTypeVariables] method.
> 
> It might be worth having it as a convenience method, though.

ah, my mistake. I misunderstood the distinction between typeArguments and type
parameters. Thank you.

Powered by Google App Engine
This is Rietveld 408576698