blob: b72028086924b341eb92a4481020fe312c7c753a [file] [log] [blame]
 // Copyright (c) 2017, 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. // Testing that the reserved word `void` is allowed to occur as a type, not // just as a return type. typedef F = void Function(Object); typedef F2 = void Function([Object]); typedef F3 = void Function({Object x}); typedef G = void Function(void); typedef G2 = void Function([void]); typedef G3 = void Function({void x}); typedef H = int Function(void); typedef H2 = int Function([void]); typedef H3 = int Function({void x}); class A { final T t; const A(this.t); } const void x1 = null; const A x2 = const A(null); final void x3 = null; final A x4 = new A(null); void x5 = null, x6; A x7 = new A(null), x8; void get g1 => null; A get g2 => new A(null); void set s1(void x) => null; void set s2(A x) => null; void m1(void x, [void y]) => null; void m2(void x, {void y}) => null; A m3(A x, [A y]) => new A(null); A m4(A x, {A y}) => new A(null); class B implements A { void get t => null; } class C extends A with B> { C() : super(null); static final void x1 = null; static final A x2 = new A(null); static const void x3 = null; static const A x4 = const A(null); final void x5 = null; final A x6 = new A(null); static void x7 = null, x8; static A x9 = new A(null), x10; covariant void x11 = null, x12; covariant A x13 = new A(null), x14; static void get g1 => null; static A get g2 => new A(null); static void set s1(void x) => null; static void set s2(A x) => null; static void m1(void x, [void y]) => null; static void m2(void x, {void y}) => null; static A m3(A x, [A y]) => null; static A m4(A x, {A y}) => null; void get g3 => null; A get g4 => new A(null); void set s3(void x) => null; void set s4(A x) => null; void m5(void x, [void y]) => null; void m6(void x, {void y}) => null; A m7(A x, [A y]) => null; A m8(A x, {A y}) => null; // Ensure that all members are used, and use `void` in expressions. void run() { x1; x2; x3; x4; x5; x6; x7; x8; x9; x10; x11; x12; x13; x14; g1; g2; g3; g4; s1 = null; s2 = new A(null); s3 = null; s4 = new A(null); m1(null, null); m2(null, y: null); m3(null, new A(null)); m4(null, y: new A(null)); m5(null, null); m6(null, y: null); m7(null, new A(null)); m8(null, y: new A(null)); void pretendToUse(dynamic x) => null; pretendToUse([]); pretendToUse({}); pretendToUse(>[]); pretendToUse(, A>{}); } } // Testing syntax, just enforce compilation. main() { // ignore x1; x2; x3; x4; x5; x6; x7; x8; g1; g2; s1 = null; s2 = new A(null); m1(null, null); m2(null, y: null); m3(null, null); m4(null, y: null); new C().run(); }