Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

Commit 8920b96

Browse files
matanlureyalorenzen
authored andcommitted
fix(Compiler): Revert parts of the view compiler change to support *Token<T>.
... as observed by client teams, this breaks compilation, as sometimes the generic type is not in scope. The hacky way this was implemented inside of compile_metadata.dart needs to be done properly to roll-forward. PiperOrigin-RevId: 182103218
1 parent 6b38e07 commit 8920b96

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

_goldens/test_files/directives/directive_wrapper.template_debug.golden

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ List<StaticNodeDebugInfo> nodeDebugInfos_InputFormTest0 = [
204204
new StaticNodeDebugInfo(
205205
[
206206
import13.DefaultValueAccessor,
207-
const OpaqueToken<ControlValueAccessor>('NgValueAccessor'),
207+
const OpaqueToken<dynamic>('NgValueAccessor'),
208208
import14.NgControlName,
209209
import15.NgControl
210210
],
@@ -218,7 +218,7 @@ class ViewInputFormTest0 extends DebugAppView<import1.InputFormTest> {
218218
dynamic _ControlContainer_0_5;
219219
import3.InputElement _el_1;
220220
import13.DefaultValueAccessor _DefaultValueAccessor_1_4;
221-
List<dynamic> _const_OpaqueToken_ControlValueAccessor___NgValueAccessor___1_5;
221+
List<dynamic> _const_OpaqueToken_dynamic___NgValueAccessor___1_5;
222222
import14.NgControlName _NgControlName_1_6;
223223
var _expr_0;
224224
static RenderComponentType _renderType;
@@ -248,11 +248,11 @@ class ViewInputFormTest0 extends DebugAppView<import1.InputFormTest> {
248248
createAttr(_el_1, 'ngControl', 'login');
249249
createAttr(_el_1, 'type', 'text');
250250
_DefaultValueAccessor_1_4 = new import13.DefaultValueAccessor(_el_1);
251-
_const_OpaqueToken_ControlValueAccessor___NgValueAccessor___1_5 = [
251+
_const_OpaqueToken_dynamic___NgValueAccessor___1_5 = [
252252
_DefaultValueAccessor_1_4
253253
];
254254
_NgControlName_1_6 = new import14.NgControlName(_ControlContainer_0_5, null,
255-
_const_OpaqueToken_ControlValueAccessor___NgValueAccessor___1_5);
255+
_const_OpaqueToken_dynamic___NgValueAccessor___1_5);
256256
import8.appViewUtils.eventManager.addEventListener(
257257
_el_0, 'submit', eventHandler1(_NgFormModel_0_4.onSubmit));
258258
_el_1.addEventListener('input', eventHandler1(_handle_input_1_0));
@@ -268,10 +268,9 @@ class ViewInputFormTest0 extends DebugAppView<import1.InputFormTest> {
268268
if ((identical(token, import13.DefaultValueAccessor) && (1 == nodeIndex))) {
269269
return _DefaultValueAccessor_1_4;
270270
}
271-
if ((identical(token,
272-
const OpaqueToken<ControlValueAccessor>('NgValueAccessor')) &&
271+
if ((identical(token, const OpaqueToken<dynamic>('NgValueAccessor')) &&
273272
(1 == nodeIndex))) {
274-
return _const_OpaqueToken_ControlValueAccessor___NgValueAccessor___1_5;
273+
return _const_OpaqueToken_dynamic___NgValueAccessor___1_5;
275274
}
276275
if (((identical(token, import14.NgControlName) ||
277276
identical(token, import15.NgControl)) &&

_goldens/test_files/directives/directive_wrapper.template_release.golden

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class ViewInputFormTest0 extends AppView<import1.InputFormTest> {
178178
dynamic _ControlContainer_0_5;
179179
import2.InputElement _el_1;
180180
import10.DefaultValueAccessor _DefaultValueAccessor_1_4;
181-
List<dynamic> _const_OpaqueToken_ControlValueAccessor___NgValueAccessor___1_5;
181+
List<dynamic> _const_OpaqueToken_dynamic___NgValueAccessor___1_5;
182182
import11.NgControlName _NgControlName_1_6;
183183
var _expr_0;
184184
static RenderComponentType _renderType;
@@ -201,11 +201,11 @@ class ViewInputFormTest0 extends AppView<import1.InputFormTest> {
201201
createAttr(_el_1, 'ngControl', 'login');
202202
createAttr(_el_1, 'type', 'text');
203203
_DefaultValueAccessor_1_4 = new import10.DefaultValueAccessor(_el_1);
204-
_const_OpaqueToken_ControlValueAccessor___NgValueAccessor___1_5 = [
204+
_const_OpaqueToken_dynamic___NgValueAccessor___1_5 = [
205205
_DefaultValueAccessor_1_4
206206
];
207207
_NgControlName_1_6 = new import11.NgControlName(_ControlContainer_0_5, null,
208-
_const_OpaqueToken_ControlValueAccessor___NgValueAccessor___1_5);
208+
_const_OpaqueToken_dynamic___NgValueAccessor___1_5);
209209
import6.appViewUtils.eventManager.addEventListener(
210210
_el_0, 'submit', eventHandler1(_NgFormModel_0_4.onSubmit));
211211
_el_1.addEventListener('input', eventHandler1(_handle_input_1_0));
@@ -221,10 +221,9 @@ class ViewInputFormTest0 extends AppView<import1.InputFormTest> {
221221
if ((identical(token, import10.DefaultValueAccessor) && (1 == nodeIndex))) {
222222
return _DefaultValueAccessor_1_4;
223223
}
224-
if ((identical(token,
225-
const OpaqueToken<ControlValueAccessor>('NgValueAccessor')) &&
224+
if ((identical(token, const OpaqueToken<dynamic>('NgValueAccessor')) &&
226225
(1 == nodeIndex))) {
227-
return _const_OpaqueToken_ControlValueAccessor___NgValueAccessor___1_5;
226+
return _const_OpaqueToken_dynamic___NgValueAccessor___1_5;
228227
}
229228
if (((identical(token, import11.NgControlName) ||
230229
identical(token, import12.NgControl)) &&

_tests/test/di/directive_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void main() {
8686
expect(value1, 1);
8787
final value2 = fixture.assertOnlyInstance.injector.get(barTypedToken2);
8888
expect(value2, 2);
89-
});
89+
}, skip: 'Enable when supported in the ViewCompiler (again).');
9090

9191
group('should support optional values', () {
9292
NgTestBed<UsingInjectAndOptional> testBed;

angular/lib/src/source_gen/template_compiler/compile_metadata.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ class CompileTypeMetadataVisitor
327327
// type parameters in the source_gen compiler, refactor this out. We want
328328
// to get towards using code_builder anyways.
329329
final tokenHack = new _OpaqueToken(
330-
"const $className<${genericType.name}>('$description')",
330+
// TODO(matanl): Roll-forward to use the real generic type after fix.
331+
"const $className<dynamic>('$description')",
331332
);
332333
return new CompileTokenMetadata(value: tokenHack);
333334
}

0 commit comments

Comments
 (0)