|
| 1 | +package tests.validation.other.types.unionTypes.context |
| 2 | + |
| 3 | +annotation MyAnnotation( |
| 4 | + // $TEST$ no error "Union types must only be used for parameters of annotations, classes, and functions." |
| 5 | + p: »union<Int>«, |
| 6 | +) |
| 7 | + |
| 8 | +class MyClass<T>( |
| 9 | + // $TEST$ no error "Union types must only be used for parameters of annotations, classes, and functions." |
| 10 | + p: »union<Int>«, |
| 11 | +) { |
| 12 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 13 | + attr a: »union<Int>« |
| 14 | +} |
| 15 | + |
| 16 | +enum MyEnum { |
| 17 | + MyEnumVariant<T>( |
| 18 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 19 | + p: »union<Int>«, |
| 20 | + ) |
| 21 | +} |
| 22 | + |
| 23 | +fun myFunction( |
| 24 | + // $TEST$ no error "Union types must only be used for parameters of annotations, classes, and functions." |
| 25 | + p: »union<Int>«, |
| 26 | +) -> ( |
| 27 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 28 | + r: »union<Int>«, |
| 29 | +) |
| 30 | + |
| 31 | +segment mySegment1( |
| 32 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 33 | + p: »union<Int>«, |
| 34 | +) -> ( |
| 35 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 36 | + r: »union<Int>«, |
| 37 | +) {} |
| 38 | + |
| 39 | +segment mySegment2( |
| 40 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 41 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 42 | + c: (p: »union<Int>«) -> (r: »union<Int>«), |
| 43 | +) { |
| 44 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 45 | + ( |
| 46 | + p: »union<Int>«, |
| 47 | + ) {}; |
| 48 | + |
| 49 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 50 | + ( |
| 51 | + p: »union<Int>«, |
| 52 | + ) -> 1; |
| 53 | +} |
| 54 | + |
| 55 | +segment mySegment3( |
| 56 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 57 | + p1: MyClass<»union<Int>«>, |
| 58 | + |
| 59 | + // $TEST$ error "Union types must only be used for parameters of annotations, classes, and functions." |
| 60 | + p2: MyEnum.MyEnumVariant<»union<Int>«>, |
| 61 | +) {} |
0 commit comments