|
| 1 | +# typed: true |
| 2 | + |
| 3 | +class A |
| 4 | + extend T::Sig |
| 5 | + sig do |
| 6 | + type_parameters(:U) |
| 7 | + .params(x: T.type_parameter(:U)) |
| 8 | + .void |
| 9 | + end |
| 10 | + def f1(x) |
| 11 | + T.reveal_type(x) # error: `T.type_parameter(:U) (of A#f1)` |
| 12 | + |
| 13 | + type = T::Array[x] |
| 14 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 15 | + T.reveal_type(type) # error: `Runtime object representing type: T::Array[T.untyped]` |
| 16 | + |
| 17 | + type = T.class_of(x) |
| 18 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 19 | + T.reveal_type(type) # error: `Runtime object representing type: T.untyped` |
| 20 | + |
| 21 | + type = T.any(x, x) |
| 22 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 23 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 24 | + T.reveal_type(type) # error: `Runtime object representing type: T.untyped` |
| 25 | + |
| 26 | + type = T.all(x, x) |
| 27 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 28 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 29 | + T.reveal_type(type) # error: `Runtime object representing type: T.untyped` |
| 30 | + |
| 31 | + type = T.nilable(x) |
| 32 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 33 | + T.reveal_type(type) # error: `Runtime object representing type: T.untyped` |
| 34 | + |
| 35 | + type = T.proc.params(arg0: x).void |
| 36 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 37 | + T.reveal_type(type) # error: `Runtime object representing type: T.proc.params(arg0: T.untyped).void` |
| 38 | + |
| 39 | + type = T.proc.returns(x) |
| 40 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f1)` value found in type position |
| 41 | + T.reveal_type(type) # error: `Runtime object representing type: T.proc.returns(T.untyped)` |
| 42 | + end |
| 43 | + |
| 44 | + sig do |
| 45 | + type_parameters(:U) |
| 46 | + .params(x: T.type_parameter(:U)) |
| 47 | + .void |
| 48 | + end |
| 49 | + def f2(x) |
| 50 | + T.reveal_type(x) # error: `T.type_parameter(:U) (of A#f2)` |
| 51 | + f = T.let( |
| 52 | + -> (x) { |
| 53 | + T.reveal_type(x) # error: `T.untyped` |
| 54 | + }, |
| 55 | + T.proc.params(arg0: x).void |
| 56 | + # ^ error: Unsupported type syntax |
| 57 | + # ^ error: Unexpected bare `T.type_parameter(:U) (of A#f2)` value found in type position |
| 58 | + ) |
| 59 | + T.reveal_type(f) # error: `T.proc.params(arg0: T.untyped).void` |
| 60 | + end |
| 61 | + |
| 62 | + sig do |
| 63 | + type_parameters(:U) |
| 64 | + .params(type: T::Types::Base) |
| 65 | + .void |
| 66 | + end |
| 67 | + def f3(type) |
| 68 | + T.nilable(type) |
| 69 | + # ^^^^ error: Unexpected bare `T::Types::Base` value found in type position |
| 70 | + T.nilable(T.unsafe(type)) |
| 71 | + end |
| 72 | +end |
| 73 | + |
0 commit comments