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.source_class_builder; | 5 library fasta.source_class_builder; |
6 | 6 |
7 import 'package:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
8 show Class, Constructor, Supertype, TreeNode, setParents; | 8 show Class, Constructor, Supertype, TreeNode, setParents; |
9 | 9 |
10 import '../dill/dill_member_builder.dart' show DillMemberBuilder; | 10 import '../dill/dill_member_builder.dart' show DillMemberBuilder; |
11 | 11 |
| 12 import '../fasta_codes.dart' |
| 13 show |
| 14 templateConflictsWithConstructor, |
| 15 templateConflictsWithFactory, |
| 16 templateConflictsWithMember, |
| 17 templateConflictsWithSetter; |
| 18 |
12 import '../kernel/kernel_builder.dart' | 19 import '../kernel/kernel_builder.dart' |
13 show | 20 show |
14 Builder, | 21 Builder, |
15 ClassBuilder, | 22 ClassBuilder, |
16 ConstructorReferenceBuilder, | 23 ConstructorReferenceBuilder, |
17 KernelClassBuilder, | 24 KernelClassBuilder, |
18 KernelFieldBuilder, | 25 KernelFieldBuilder, |
19 KernelFunctionBuilder, | 26 KernelFunctionBuilder, |
20 KernelLibraryBuilder, | 27 KernelLibraryBuilder, |
21 KernelTypeBuilder, | 28 KernelTypeBuilder, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // TODO(ahe): Report an error if supertype is null. | 116 // TODO(ahe): Report an error if supertype is null. |
110 cls.implementedTypes.add(supertype); | 117 cls.implementedTypes.add(supertype); |
111 } | 118 } |
112 } | 119 } |
113 } | 120 } |
114 | 121 |
115 constructors.forEach((String name, Builder constructor) { | 122 constructors.forEach((String name, Builder constructor) { |
116 Builder member = scopeBuilder[name]; | 123 Builder member = scopeBuilder[name]; |
117 if (member == null) return; | 124 if (member == null) return; |
118 // TODO(ahe): charOffset is missing. | 125 // TODO(ahe): charOffset is missing. |
119 deprecated_addCompileTimeError( | 126 addCompileTimeError(templateConflictsWithMember.withArguments(name), |
120 constructor.charOffset, "Conflicts with member '${name}'."); | 127 constructor.charOffset); |
121 if (constructor.isFactory) { | 128 if (constructor.isFactory) { |
122 deprecated_addCompileTimeError(member.charOffset, | 129 addCompileTimeError( |
123 "Conflicts with factory '${this.name}.${name}'."); | 130 templateConflictsWithFactory.withArguments("${this.name}.${name}"), |
| 131 member.charOffset); |
124 } else { | 132 } else { |
125 deprecated_addCompileTimeError(member.charOffset, | 133 addCompileTimeError( |
126 "Conflicts with constructor '${this.name}.${name}'."); | 134 templateConflictsWithConstructor |
| 135 .withArguments("${this.name}.${name}"), |
| 136 member.charOffset); |
127 } | 137 } |
128 }); | 138 }); |
129 | 139 |
130 scope.setters.forEach((String name, Builder setter) { | 140 scope.setters.forEach((String name, Builder setter) { |
131 Builder member = scopeBuilder[name]; | 141 Builder member = scopeBuilder[name]; |
132 if (member == null || !member.isField || member.isFinal) return; | 142 if (member == null || !member.isField || member.isFinal) return; |
133 // TODO(ahe): charOffset is missing. | 143 // TODO(ahe): charOffset is missing. |
134 var report = member.isInstanceMember != setter.isInstanceMember | 144 var report = member.isInstanceMember != setter.isInstanceMember |
135 ? deprecated_addWarning | 145 ? addWarning |
136 : deprecated_addCompileTimeError; | 146 : addCompileTimeError; |
137 report(setter.charOffset, "Conflicts with member '${name}'."); | 147 report( |
138 report(member.charOffset, "Conflicts with setter '${name}'."); | 148 templateConflictsWithMember.withArguments(name), setter.charOffset); |
| 149 report( |
| 150 templateConflictsWithSetter.withArguments(name), member.charOffset); |
139 }); | 151 }); |
140 | 152 |
141 cls.procedures.sort(compareProcedures); | 153 cls.procedures.sort(compareProcedures); |
142 return cls; | 154 return cls; |
143 } | 155 } |
144 | 156 |
145 void addSyntheticConstructor(Constructor constructor) { | 157 void addSyntheticConstructor(Constructor constructor) { |
146 String name = constructor.name.name; | 158 String name = constructor.name.name; |
147 cls.constructors.add(constructor); | 159 cls.constructors.add(constructor); |
148 constructor.parent = cls; | 160 constructor.parent = cls; |
149 DillMemberBuilder memberBuilder = new DillMemberBuilder(constructor, this); | 161 DillMemberBuilder memberBuilder = new DillMemberBuilder(constructor, this); |
150 memberBuilder.next = constructorScopeBuilder[name]; | 162 memberBuilder.next = constructorScopeBuilder[name]; |
151 constructorScopeBuilder.addMember(name, memberBuilder); | 163 constructorScopeBuilder.addMember(name, memberBuilder); |
152 } | 164 } |
153 | 165 |
154 @override | 166 @override |
155 void prepareInitializerInference( | 167 void prepareInitializerInference( |
156 SourceLibraryBuilder library, ClassBuilder currentClass) { | 168 SourceLibraryBuilder library, ClassBuilder currentClass) { |
157 scope.forEach((name, builder) { | 169 scope.forEach((name, builder) { |
158 builder.prepareInitializerInference(library, this); | 170 builder.prepareInitializerInference(library, this); |
159 }); | 171 }); |
160 } | 172 } |
161 } | 173 } |
OLD | NEW |