Files
sdk/tests/language_2/vm/regression_32912_test.dart
T
Martin Kustermann dec268cfae [VM] Catch non-instantiated type arguments for constant partial instantiation expression
This makes us report the following error

  * in JIT:

  Unhandled exception:
  'test.dart': error: Type arguments must be instantiated in partial instantiation.
  #0      main (...)
  ...

  * in AOT:

  test.dart:7:28: Error: The type '#lib1::C::T' is not a constant, only instantiated types are ...
    const C({this.callback = _defaultCallback});
                           ^
  test.dart:7:17: Context: While analyzing:
    const C({this.callback = _defaultCallback});
                ^
  test.dart:5:37: Error: The type '#lib1::C::T' is not a constant, only instantiated types are ...
    void foo([dynamic Function(T) f = _defaultCallback]) {}
                                    ^
  test.dart:5:33: Context: While analyzing:
    void foo([dynamic Function(T) f = _defaultCallback]) {}
                                ^
  test.dart:11:38: Error: The type '#lib1::bar::T' is not a constant, only instantiated types are ...
  void bar<T>([dynamic Function(T) f = _defaultCallback]) {}
                                     ^
  test.dart:11:34: Context: While analyzing:
  void bar<T>([dynamic Function(T) f = _defaultCallback]) {}



Issue https://github.com/dart-lang/sdk/issues/32912

Change-Id: I05c7019119a50a9cc38939d9cb41aeaa06c853bc
Reviewed-on: https://dart-review.googlesource.com/c/81278
Auto-Submit: Martin Kustermann <kustermann@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-10-25 09:23:18 +00:00

24 lines
815 B
Dart

// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
dynamic _defaultCallback<T>(T t) => t;
void bar<T>([dynamic Function(T) f = _defaultCallback]) {} //# 01: compile-time error
class C<T> {
// Should be statically rejected
foo([dynamic Function(T) f = _defaultCallback]) {} //# 02: compile-time error
// Should be statically rejected
const C({this.callback = _defaultCallback}); //# 03: compile-time error
final dynamic Function(T) callback; //# 03: continued
}
void main() {
bar<int>(); //# 01: continued
print(new C<int>().foo()); //# 02: continued
print(new C<int>().callback); //# 03: continued
}