OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library fasta.procedure_builder; | 5 library fasta.procedure_builder; |
6 | 6 |
7 // Note: we're deliberately using AsyncMarker and ProcedureKind from kernel | 7 // Note: we're deliberately using AsyncMarker and ProcedureKind from kernel |
8 // outside the kernel-specific builders. This is simpler than creating | 8 // outside the kernel-specific builders. This is simpler than creating |
9 // additional enums. | 9 // additional enums. |
10 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; | 10 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 bool get isFactory => identical(ProcedureKind.Factory, kind); | 62 bool get isFactory => identical(ProcedureKind.Factory, kind); |
63 | 63 |
64 void set body(covariant statement); | 64 void set body(covariant statement); |
65 | 65 |
66 /// This is the formal parameter scope as specified in the Dart Programming | 66 /// This is the formal parameter scope as specified in the Dart Programming |
67 /// Language Specifiction, 4th ed, section 9.2. | 67 /// Language Specifiction, 4th ed, section 9.2. |
68 Scope computeFormalParameterScope(Scope parent) { | 68 Scope computeFormalParameterScope(Scope parent) { |
69 if (formals == null) return parent; | 69 if (formals == null) return parent; |
70 Map<String, Builder> local = <String, Builder>{}; | 70 Map<String, Builder> local = <String, Builder>{}; |
71 for (FormalParameterBuilder formal in formals) { | 71 for (FormalParameterBuilder formal in formals) { |
72 if (!formal.hasThis) { | 72 if (!isConstructor || !formal.hasThis) { |
73 local[formal.name] = formal; | 73 local[formal.name] = formal; |
74 } | 74 } |
75 } | 75 } |
76 return new Scope(local, parent, isModifiable: false); | 76 return new Scope(local, parent, isModifiable: false); |
77 } | 77 } |
78 | 78 |
79 /// This scope doesn't correspond to any scope specified in the Dart | 79 /// This scope doesn't correspond to any scope specified in the Dart |
80 /// Programming Language Specifiction, 4th ed. It's an unspecified extension | 80 /// Programming Language Specifiction, 4th ed. It's an unspecified extension |
81 /// to support generic methods. | 81 /// to support generic methods. |
82 Scope computeTypeParameterScope(Scope parent) { | 82 Scope computeTypeParameterScope(Scope parent) { |
83 if (typeVariables == null) return parent; | 83 if (typeVariables == null) return parent; |
84 Map<String, Builder> local = <String, Builder>{}; | 84 Map<String, Builder> local = <String, Builder>{}; |
85 for (TypeVariableBuilder variable in typeVariables) { | 85 for (TypeVariableBuilder variable in typeVariables) { |
86 local[variable.name] = variable; | 86 local[variable.name] = variable; |
87 } | 87 } |
88 return new Scope(local, parent, isModifiable: false); | 88 return new Scope(local, parent, isModifiable: false); |
89 } | 89 } |
90 } | 90 } |
OLD | NEW |