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

Issue 3000353002: Start implementing logic for determining when formal parameters need type checks. (Closed)

Created:
3 years, 4 months ago by Paul Berry
Modified:
3 years, 4 months ago
Reviewers:
ahe, scheglov
CC:
reviews_dartlang.org, dart-fe-team+reviews_google.com
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Start implementing logic for determining when formal parameters need type checks. We haven't quite figured out how we want to store the need for these type checks in the kernel representation, and I'm hoping that my coding work can help inform that decision. So for the moment the annotation is simply stored in the front_end wrapper (KernelVariableDeclaration). This is enough to get simple tests to pass. R=ahe@google.com Committed: https://github.com/dart-lang/sdk/commit/6e842b3c11457b96c798a93d65d1c96571d8f57a

Patch Set 1 #

Total comments: 10
Unified diffs Side-by-side diffs Delta from patch set Stats (+121 lines, -10 lines) Patch
M pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart View 1 chunk +11 lines, -0 lines 2 comments Download
M pkg/front_end/lib/src/fasta/kernel/kernel_target.dart View 1 chunk +1 line, -0 lines 0 comments Download
M pkg/front_end/lib/src/fasta/source/source_loader.dart View 2 chunks +23 lines, -1 line 2 comments Download
M pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart View 4 chunks +34 lines, -7 lines 6 comments Download
M pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart View 2 chunks +32 lines, -0 lines 0 comments Download
M pkg/front_end/testcases/ast_builder.status View 1 chunk +0 lines, -1 line 0 comments Download
A pkg/front_end/testcases/runtime_checks/covariant_generic_parameter.dart.strong.expect View 1 chunk +20 lines, -0 lines 0 comments Download
M pkg/front_end/testcases/strong.status View 1 chunk +0 lines, -1 line 0 comments Download

Messages

Total messages: 8 (2 generated)
Paul Berry
I only need a review from one of you.
3 years, 4 months ago (2017-08-22 23:31:45 UTC) #2
ahe
lgtm https://codereview.chromium.org/3000353002/diff/1/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart File pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart (right): https://codereview.chromium.org/3000353002/diff/1/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart#newcode2390 pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart:2390: bool isSemiSafe = false; As for the future ...
3 years, 4 months ago (2017-08-23 09:55:58 UTC) #3
Paul Berry
https://codereview.chromium.org/3000353002/diff/1/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart File pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart (right): https://codereview.chromium.org/3000353002/diff/1/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart#newcode2390 pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart:2390: bool isSemiSafe = false; On 2017/08/23 09:55:58, ahe wrote: ...
3 years, 4 months ago (2017-08-23 17:09:11 UTC) #4
Paul Berry
Committed patchset #1 (id:1) manually as 6e842b3c11457b96c798a93d65d1c96571d8f57a (presubmit successful).
3 years, 4 months ago (2017-08-23 17:17:59 UTC) #6
ahe
https://codereview.chromium.org/3000353002/diff/1/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart File pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart (right): https://codereview.chromium.org/3000353002/diff/1/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart#newcode7 pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart:7: import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; On 2017/08/23 17:09:10, Paul Berry wrote: > ...
3 years, 4 months ago (2017-08-24 09:23:48 UTC) #7
ahe
3 years, 4 months ago (2017-08-24 09:35:26 UTC) #8
Message was sent while issue was closed.
https://codereview.chromium.org/3000353002/diff/1/pkg/front_end/lib/src/fasta...
File pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
(right):

https://codereview.chromium.org/3000353002/diff/1/pkg/front_end/lib/src/fasta...
pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart:286: if
(!typeSchemaEnvironment.isSubtypeOf(formal.type, pessimisticType)) {
On 2017/08/23 17:09:10, Paul Berry wrote:
> On 2017/08/23 09:55:58, ahe wrote:
> > I think this needs documentation. As far as I understand, you're trying to
> > recognize the following situation:
> > 
> > class A<T> {
> >   foo(A argument) {}
> > }
> 
> I assume you mean:
> 
> class A<T> {
>   foo(T argument) {}
> }

Yes.

> > 
> > Why not:
> > 
> > var type = formal.type;
> > if (!(type is TypeParameterType && type.parameter.parent == cls)) { ... }
> 
> That would be sufficient to identify the case you mention above, but it would
> not identify other cases where the type parameter appears in the type of the
> formal parameter in covariant fashion, e.g.:
> 
> class A<T> {
>   foo(List<T> argument) {}
> }
> 
> Or:
> 
> class A<T> {
>   foo(T bar()) {}
> }
> 
> Note however that not all uses of T in the type of foo's parameter are bad. 
> This one is ok:
> 
> class A<T> {
>   foo(void bar(T argument)) {}
> }
> 
> I've added comments explaining the reasoning process.  In a follow up CL I'll
> add additional tests to cover these corner cases.

Thank you, I looked at your comments and it now makes sense to me. Next time, it
would be nice if you ensure that what you commit is uploaded as new patch set
(not that it needs another lgtm, but it's easier to comment if needed).

Powered by Google App Engine
This is Rietveld 408576698