|
| 1 | +# Constructing functions for some concrete types. |
| 2 | +# |
| 3 | +# Meant to be used to improve inference, when the input arguments are not necessarily |
| 4 | +# precisely inferred. Partial workaround for issue #42372. |
| 5 | +module _ConstructingFunctions |
| 6 | + export |
| 7 | + _Bool, |
| 8 | + _Int, _Int8, _Int16, _Int32, _Int64, _Int128, |
| 9 | + _UInt, _UInt8, _UInt16, _UInt32, _UInt64, _UInt128, |
| 10 | + _Char, _String |
| 11 | + struct ConstructorStrict{F} <: Function end |
| 12 | + # Keyword arguments are not available at this point in bootstrap, so they're not |
| 13 | + # supported. |
| 14 | + function (::ConstructorStrict{F})(args::Vararg{Any, N}) where {F, N} |
| 15 | + @inline |
| 16 | + r = F(args...) |
| 17 | + r::F |
| 18 | + end |
| 19 | + const _Bool = ConstructorStrict{Bool}() |
| 20 | + const _Int = ConstructorStrict{Int}() |
| 21 | + const _Int8 = ConstructorStrict{Int8}() |
| 22 | + const _Int16 = ConstructorStrict{Int16}() |
| 23 | + const _Int32 = ConstructorStrict{Int32}() |
| 24 | + const _Int64 = ConstructorStrict{Int64}() |
| 25 | + const _Int128 = ConstructorStrict{Int128}() |
| 26 | + const _UInt = ConstructorStrict{UInt}() |
| 27 | + const _UInt8 = ConstructorStrict{UInt8}() |
| 28 | + const _UInt16 = ConstructorStrict{UInt16}() |
| 29 | + const _UInt32 = ConstructorStrict{UInt32}() |
| 30 | + const _UInt64 = ConstructorStrict{UInt64}() |
| 31 | + const _UInt128 = ConstructorStrict{UInt128}() |
| 32 | + const _Char = ConstructorStrict{Char}() |
| 33 | + const _String = ConstructorStrict{String}() |
| 34 | +end |
| 35 | + |
| 36 | +using ._ConstructingFunctions |
0 commit comments