Skip to content

Commit 03ba8da

Browse files
authored
Merge pull request #48935 from JuliaLang/backports-release-1.9
Backports for 1.9.0-rc2
2 parents b1b388a + dd0ff75 commit 03ba8da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1092
-593
lines changed

Make.inc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ WITH_GC_DEBUG_ENV := 0
8989
# Enable DTrace support
9090
WITH_DTRACE := 0
9191

92+
# Enable ITTAPI integration
93+
WITH_ITTAPI := 0
94+
9295
# Prevent picking up $ARCH from the environment variables
9396
ARCH:=
9497

@@ -303,6 +306,9 @@ private_libdir := $(libdir)/julia
303306
endif
304307
build_private_libdir := $(build_libdir)/julia
305308

309+
private_libexecdir := $(libexecdir)/julia
310+
build_private_libexecdir := $(build_libexecdir)/julia
311+
306312
# A helper functions for dealing with lazily-evaluated, expensive operations.. Spinning
307313
# up a python process to, for exaxmple, parse a TOML file is expensive, and we must wait
308314
# until the TOML files are on-disk before we can parse them. This means that we cannot
@@ -327,7 +333,7 @@ define cache_rel_path
327333
$(1)_rel_eval = $(call rel_path,$(2),$($(1)))
328334
$(1)_rel = $$(call hit_cache,$(1)_rel_eval)
329335
endef
330-
$(foreach D,libdir private_libdir datarootdir libexecdir docdir sysconfdir includedir,$(eval $(call cache_rel_path,$(D),$(bindir))))
336+
$(foreach D,libdir private_libdir datarootdir libexecdir private_libexecdir docdir sysconfdir includedir,$(eval $(call cache_rel_path,$(D),$(bindir))))
331337
$(foreach D,build_libdir build_private_libdir,$(eval $(call cache_rel_path,$(D),$(build_bindir))))
332338

333339
# Save a special one: reverse_private_libdir_rel: usually just `../`, but good to be general:
@@ -733,7 +739,12 @@ ifeq ($(WITH_DTRACE), 1)
733739
JCXXFLAGS += -DUSE_DTRACE
734740
JCFLAGS += -DUSE_DTRACE
735741
DTRACE := dtrace
736-
else
742+
endif
743+
744+
ifeq ($(WITH_ITTAPI), 1)
745+
JCXXFLAGS += -DUSE_ITTAPI
746+
JCFLAGS += -DUSE_ITTAPI
747+
LIBITTAPI:=-littnotify
737748
endif
738749

739750
# ===========================================================================

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ endef
238238

239239
install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html
240240
@$(MAKE) $(QUIET_MAKE) $(JULIA_BUILD_MODE)
241-
@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(libexecdir); do \
241+
@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(private_libexecdir); do \
242242
mkdir -p $(DESTDIR)$$subdir; \
243243
done
244244

@@ -253,8 +253,8 @@ else ifeq ($(JULIA_BUILD_MODE),debug)
253253
-$(INSTALL_M) $(build_libdir)/libjulia-internal-debug.dll.a $(DESTDIR)$(libdir)/
254254
endif
255255

256-
# We have a single exception; we want 7z.dll to live in libexec, not bin, so that 7z.exe can find it.
257-
-mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(libexecdir)/
256+
# We have a single exception; we want 7z.dll to live in private_libexecdir, not bindir, so that 7z.exe can find it.
257+
-mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(private_libexecdir)/
258258
-$(INSTALL_M) $(build_bindir)/libopenlibm.dll.a $(DESTDIR)$(libdir)/
259259
-$(INSTALL_M) $(build_libdir)/libssp.dll.a $(DESTDIR)$(libdir)/
260260
# The rest are compiler dependencies, as an example memcpy is exported by msvcrt
@@ -311,14 +311,14 @@ endif
311311
done \
312312
done
313313
endif
314-
# Install `7z` into libexec/
315-
$(INSTALL_M) $(build_bindir)/7z$(EXE) $(DESTDIR)$(libexecdir)/
314+
# Install `7z` into private_libexecdir
315+
$(INSTALL_M) $(build_bindir)/7z$(EXE) $(DESTDIR)$(private_libexecdir)/
316316

317-
# Install `lld` into libexec/
318-
$(INSTALL_M) $(build_depsbindir)/lld$(EXE) $(DESTDIR)$(libexecdir)/
317+
# Install `lld` into private_libexecdir
318+
$(INSTALL_M) $(build_depsbindir)/lld$(EXE) $(DESTDIR)$(private_libexecdir)/
319319

320-
# Install `dsymutil` into libexec/
321-
$(INSTALL_M) $(build_depsbindir)/dsymutil$(EXE) $(DESTDIR)$(libexecdir)/
320+
# Install `dsymutil` into private_libexecdir/
321+
$(INSTALL_M) $(build_depsbindir)/dsymutil$(EXE) $(DESTDIR)$(private_libexecdir)/
322322

323323
# Copy public headers
324324
cp -R -L $(build_includedir)/julia/* $(DESTDIR)$(includedir)/julia

THIRDPARTY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ own licenses:
2424
- [LLVM](https://releases.llvm.org/12.0.1/LICENSE.TXT) [APACHE 2.0 with LLVM Exception]
2525
- [UTF8PROC](https://github.com/JuliaStrings/utf8proc) [MIT]
2626

27+
and optionally:
28+
29+
- [ITTAPI](https://github.com/intel/ittapi/blob/master/LICENSES/BSD-3-Clause.txt) [BSD-3]
30+
2731
Julia's `stdlib` uses the following external libraries, which have their own licenses:
2832

2933
- [DSFMT](https://github.com/MersenneTwister-Lab/dSFMT/blob/master/LICENSE.txt) [BSD-3]

base/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ ifeq ($(OS),WINNT)
6666
@printf 'const LIBDIR = "%s"\n' '$(subst /,\\,$(libdir_rel))' >> $@
6767
@printf 'const LIBEXECDIR = "%s"\n' '$(subst /,\\,$(libexecdir_rel))' >> $@
6868
@printf 'const PRIVATE_LIBDIR = "%s"\n' '$(subst /,\\,$(private_libdir_rel))' >> $@
69+
@printf 'const PRIVATE_LIBEXECDIR = "%s"\n' '$(subst /,\\,$(private_libexecdir_rel))' >> $@
6970
@printf 'const INCLUDEDIR = "%s"\n' '$(subst /,\\,$(includedir_rel))' >> $@
7071
else
7172
@echo "const SYSCONFDIR = \"$(sysconfdir_rel)\"" >> $@
@@ -74,6 +75,7 @@ else
7475
@echo "const LIBDIR = \"$(libdir_rel)\"" >> $@
7576
@echo "const LIBEXECDIR = \"$(libexecdir_rel)\"" >> $@
7677
@echo "const PRIVATE_LIBDIR = \"$(private_libdir_rel)\"" >> $@
78+
@echo "const PRIVATE_LIBEXECDIR = \"$(private_libexecdir_rel)\"" >> $@
7779
@echo "const INCLUDEDIR = \"$(includedir_rel)\"" >> $@
7880
endif
7981
ifeq ($(DARWIN_FRAMEWORK), 1)

base/abstractarray.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,12 +1982,16 @@ julia> cat(1, [2], [3;;]; dims=Val(2))
19821982

19831983
# The specializations for 1 and 2 inputs are important
19841984
# especially when running with --inline=no, see #11158
1985+
# The specializations for Union{AbstractVecOrMat,Number} are necessary
1986+
# to have more specialized methods here than in LinearAlgebra/uniformscaling.jl
19851987
vcat(A::AbstractArray) = cat(A; dims=Val(1))
19861988
vcat(A::AbstractArray, B::AbstractArray) = cat(A, B; dims=Val(1))
19871989
vcat(A::AbstractArray...) = cat(A...; dims=Val(1))
1990+
vcat(A::Union{AbstractVecOrMat,Number}...) = cat(A...; dims=Val(1))
19881991
hcat(A::AbstractArray) = cat(A; dims=Val(2))
19891992
hcat(A::AbstractArray, B::AbstractArray) = cat(A, B; dims=Val(2))
19901993
hcat(A::AbstractArray...) = cat(A...; dims=Val(2))
1994+
hcat(A::Union{AbstractVecOrMat,Number}...) = cat(A...; dims=Val(2))
19911995

19921996
typed_vcat(T::Type, A::AbstractArray) = _cat_t(Val(1), T, A)
19931997
typed_vcat(T::Type, A::AbstractArray, B::AbstractArray) = _cat_t(Val(1), T, A, B)
@@ -2137,6 +2141,8 @@ end
21372141

21382142
hvcat(rows::Tuple{Vararg{Int}}, xs::Number...) = typed_hvcat(promote_typeof(xs...), rows, xs...)
21392143
hvcat(rows::Tuple{Vararg{Int}}, xs...) = typed_hvcat(promote_eltypeof(xs...), rows, xs...)
2144+
# the following method is needed to provide a more specific one compared to LinearAlgebra/uniformscaling.jl
2145+
hvcat(rows::Tuple{Vararg{Int}}, xs::Union{AbstractVecOrMat,Number}...) = typed_hvcat(promote_eltypeof(xs...), rows, xs...)
21402146

21412147
function typed_hvcat(::Type{T}, rows::Tuple{Vararg{Int}}, xs::Number...) where T
21422148
nr = length(rows)

base/array.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ function _unsetindex!(A::Array{T}, i::Int) where {T}
177177
t = @_gc_preserve_begin A
178178
p = Ptr{Ptr{Cvoid}}(pointer(A, i))
179179
if !allocatedinline(T)
180-
unsafe_store!(p, C_NULL)
180+
Intrinsics.atomic_pointerset(p, C_NULL, :monotonic)
181181
elseif T isa DataType
182182
if !datatype_pointerfree(T)
183-
for j = 1:(Core.sizeof(T) ÷ Core.sizeof(Ptr{Cvoid}))
184-
unsafe_store!(p, C_NULL, j)
183+
for j = 1:Core.sizeof(Ptr{Cvoid}):Core.sizeof(T)
184+
Intrinsics.atomic_pointerset(p + j - 1, C_NULL, :monotonic)
185185
end
186186
end
187187
end
@@ -1916,7 +1916,7 @@ function reverse!(v::AbstractVector, start::Integer, stop::Integer=lastindex(v))
19161916
return v
19171917
end
19181918

1919-
# concatenations of homogeneous combinations of vectors, horizontal and vertical
1919+
# concatenations of (in)homogeneous combinations of vectors, horizontal and vertical
19201920

19211921
vcat() = Vector{Any}()
19221922
hcat() = Vector{Any}()
@@ -1930,6 +1930,7 @@ function hcat(V::Vector{T}...) where T
19301930
end
19311931
return [ V[j][i]::T for i=1:length(V[1]), j=1:length(V) ]
19321932
end
1933+
hcat(A::Vector...) = cat(A...; dims=Val(2)) # more special than SparseArrays's hcat
19331934

19341935
function vcat(arrays::Vector{T}...) where T
19351936
n = 0
@@ -1946,6 +1947,19 @@ function vcat(arrays::Vector{T}...) where T
19461947
end
19471948
return arr
19481949
end
1950+
vcat(A::Vector...) = cat(A...; dims=Val(1)) # more special than SparseArrays's vcat
1951+
1952+
# disambiguation with LinAlg/special.jl
1953+
# Union{Number,Vector,Matrix} is for LinearAlgebra._DenseConcatGroup
1954+
# VecOrMat{T} is for LinearAlgebra._TypedDenseConcatGroup
1955+
hcat(A::Union{Number,Vector,Matrix}...) = cat(A...; dims=Val(2))
1956+
hcat(A::VecOrMat{T}...) where {T} = typed_hcat(T, A...)
1957+
vcat(A::Union{Number,Vector,Matrix}...) = cat(A...; dims=Val(1))
1958+
vcat(A::VecOrMat{T}...) where {T} = typed_vcat(T, A...)
1959+
hvcat(rows::Tuple{Vararg{Int}}, xs::Union{Number,Vector,Matrix}...) =
1960+
typed_hvcat(promote_eltypeof(xs...), rows, xs...)
1961+
hvcat(rows::Tuple{Vararg{Int}}, xs::VecOrMat{T}...) where {T} =
1962+
typed_hvcat(T, rows, xs...)
19491963

19501964
_cat(n::Integer, x::Integer...) = reshape([x...], (ntuple(Returns(1), n-1)..., length(x)))
19511965

base/compiler/abstractinterpretation.jl

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
204204
if seen napplicable
205205
# there is unanalyzed candidate, widen type and effects to the top
206206
rettype = Any
207-
all_effects = Effects()
207+
# there may be unanalyzed effects within unseen dispatch candidate,
208+
# but we can still ignore nonoverlayed effect here since we already accounted for it
209+
all_effects = merge_effects(all_effects, EFFECTS_UNKNOWN)
208210
elseif isa(matches, MethodMatches) ? (!matches.fullmatch || any_ambig(matches)) :
209211
(!all(matches.fullmatches) || any_ambig(matches))
210212
# Account for the fact that we may encounter a MethodError with a non-covered or ambiguous signature.
@@ -1304,21 +1306,32 @@ function ssa_def_slot(@nospecialize(arg), sv::InferenceState)
13041306
return arg
13051307
end
13061308

1309+
struct AbstractIterationResult
1310+
cti::Vector{Any}
1311+
info::MaybeAbstractIterationInfo
1312+
ai_effects::Effects
1313+
end
1314+
AbstractIterationResult(cti::Vector{Any}, info::MaybeAbstractIterationInfo) =
1315+
AbstractIterationResult(cti, info, EFFECTS_TOTAL)
1316+
13071317
# `typ` is the inferred type for expression `arg`.
13081318
# if the expression constructs a container (e.g. `svec(x,y,z)`),
13091319
# refine its type to an array of element types.
13101320
# Union of Tuples of the same length is converted to Tuple of Unions.
13111321
# returns an array of types
13121322
function precise_container_type(interp::AbstractInterpreter, @nospecialize(itft), @nospecialize(typ),
13131323
sv::Union{InferenceState, IRCode})
1314-
if isa(typ, PartialStruct) && typ.typ.name === Tuple.name
1315-
return typ.fields, nothing
1324+
if isa(typ, PartialStruct)
1325+
widet = typ.typ
1326+
if isa(widet, DataType) && widet.name === Tuple.name
1327+
return AbstractIterationResult(typ.fields, nothing)
1328+
end
13161329
end
13171330

13181331
if isa(typ, Const)
13191332
val = typ.val
13201333
if isa(val, SimpleVector) || isa(val, Tuple)
1321-
return Any[ Const(val[i]) for i in 1:length(val) ], nothing # avoid making a tuple Generator here!
1334+
return AbstractIterationResult(Any[ Const(val[i]) for i in 1:length(val) ], nothing) # avoid making a tuple Generator here!
13221335
end
13231336
end
13241337

@@ -1333,12 +1346,12 @@ function precise_container_type(interp::AbstractInterpreter, @nospecialize(itft)
13331346
if isa(tti, Union)
13341347
utis = uniontypes(tti)
13351348
if any(@nospecialize(t) -> !isa(t, DataType) || !(t <: Tuple) || !isknownlength(t), utis)
1336-
return Any[Vararg{Any}], nothing
1349+
return AbstractIterationResult(Any[Vararg{Any}], nothing, EFFECTS_UNKNOWN′)
13371350
end
13381351
ltp = length((utis[1]::DataType).parameters)
13391352
for t in utis
13401353
if length((t::DataType).parameters) != ltp
1341-
return Any[Vararg{Any}], nothing
1354+
return AbstractIterationResult(Any[Vararg{Any}], nothing)
13421355
end
13431356
end
13441357
result = Any[ Union{} for _ in 1:ltp ]
@@ -1349,12 +1362,12 @@ function precise_container_type(interp::AbstractInterpreter, @nospecialize(itft)
13491362
result[j] = tmerge(result[j], rewrap_unionall(tps[j], tti0))
13501363
end
13511364
end
1352-
return result, nothing
1365+
return AbstractIterationResult(result, nothing)
13531366
elseif tti0 <: Tuple
13541367
if isa(tti0, DataType)
1355-
return Any[ p for p in tti0.parameters ], nothing
1368+
return AbstractIterationResult(Any[ p for p in tti0.parameters ], nothing)
13561369
elseif !isa(tti, DataType)
1357-
return Any[Vararg{Any}], nothing
1370+
return AbstractIterationResult(Any[Vararg{Any}], nothing)
13581371
else
13591372
len = length(tti.parameters)
13601373
last = tti.parameters[len]
@@ -1363,12 +1376,14 @@ function precise_container_type(interp::AbstractInterpreter, @nospecialize(itft)
13631376
if va
13641377
elts[len] = Vararg{elts[len]}
13651378
end
1366-
return elts, nothing
1379+
return AbstractIterationResult(elts, nothing)
13671380
end
1368-
elseif tti0 === SimpleVector || tti0 === Any
1369-
return Any[Vararg{Any}], nothing
1381+
elseif tti0 === SimpleVector
1382+
return AbstractIterationResult(Any[Vararg{Any}], nothing)
1383+
elseif tti0 === Any
1384+
return AbstractIterationResult(Any[Vararg{Any}], nothing, EFFECTS_UNKNOWN′)
13701385
elseif tti0 <: Array
1371-
return Any[Vararg{eltype(tti0)}], nothing
1386+
return AbstractIterationResult(Any[Vararg{eltype(tti0)}], nothing)
13721387
else
13731388
return abstract_iteration(interp, itft, typ, sv)
13741389
end
@@ -1379,7 +1394,7 @@ function abstract_iteration(interp::AbstractInterpreter, @nospecialize(itft), @n
13791394
if isa(itft, Const)
13801395
iteratef = itft.val
13811396
else
1382-
return Any[Vararg{Any}], nothing
1397+
return AbstractIterationResult(Any[Vararg{Any}], nothing, EFFECTS_UNKNOWN′)
13831398
end
13841399
@assert !isvarargtype(itertype)
13851400
call = abstract_call_known(interp, iteratef, ArgInfo(nothing, Any[itft, itertype]), StmtInfo(true), sv)
@@ -1389,7 +1404,7 @@ function abstract_iteration(interp::AbstractInterpreter, @nospecialize(itft), @n
13891404
# WARNING: Changes to the iteration protocol must be reflected here,
13901405
# this is not just an optimization.
13911406
# TODO: this doesn't realize that Array, SimpleVector, Tuple, and NamedTuple do not use the iterate protocol
1392-
stateordonet === Bottom && return Any[Bottom], AbstractIterationInfo(CallMeta[CallMeta(Bottom, call.effects, info)])
1407+
stateordonet === Bottom && return AbstractIterationResult(Any[Bottom], AbstractIterationInfo(CallMeta[CallMeta(Bottom, call.effects, info)], true))
13931408
valtype = statetype = Bottom
13941409
ret = Any[]
13951410
calls = CallMeta[call]
@@ -1399,7 +1414,7 @@ function abstract_iteration(interp::AbstractInterpreter, @nospecialize(itft), @n
13991414
# length iterators, or interesting prefix
14001415
while true
14011416
if stateordonet_widened === Nothing
1402-
return ret, AbstractIterationInfo(calls)
1417+
return AbstractIterationResult(ret, AbstractIterationInfo(calls, true))
14031418
end
14041419
if Nothing <: stateordonet_widened || length(ret) >= InferenceParams(interp).MAX_TUPLE_SPLAT
14051420
break
@@ -1411,7 +1426,7 @@ function abstract_iteration(interp::AbstractInterpreter, @nospecialize(itft), @n
14111426
# If there's no new information in this statetype, don't bother continuing,
14121427
# the iterator won't be finite.
14131428
if (typeinf_lattice(interp), nstatetype, statetype)
1414-
return Any[Bottom], nothing
1429+
return AbstractIterationResult(Any[Bottom], AbstractIterationInfo(calls, false), EFFECTS_THROWS)
14151430
end
14161431
valtype = getfield_tfunc(typeinf_lattice(interp), stateordonet, Const(1))
14171432
push!(ret, valtype)
@@ -1441,7 +1456,7 @@ function abstract_iteration(interp::AbstractInterpreter, @nospecialize(itft), @n
14411456
# ... but cannot terminate
14421457
if !may_have_terminated
14431458
# ... and cannot have terminated prior to this loop
1444-
return Any[Bottom], nothing
1459+
return AbstractIterationResult(Any[Bottom], AbstractIterationInfo(calls, false), EFFECTS_UNKNOWN′)
14451460
else
14461461
# iterator may have terminated prior to this loop, but not during it
14471462
valtype = Bottom
@@ -1451,13 +1466,15 @@ function abstract_iteration(interp::AbstractInterpreter, @nospecialize(itft), @n
14511466
end
14521467
valtype = tmerge(valtype, nounion.parameters[1])
14531468
statetype = tmerge(statetype, nounion.parameters[2])
1454-
stateordonet = abstract_call_known(interp, iteratef, ArgInfo(nothing, Any[Const(iteratef), itertype, statetype]), StmtInfo(true), sv).rt
1469+
call = abstract_call_known(interp, iteratef, ArgInfo(nothing, Any[Const(iteratef), itertype, statetype]), StmtInfo(true), sv)
1470+
push!(calls, call)
1471+
stateordonet = call.rt
14551472
stateordonet_widened = widenconst(stateordonet)
14561473
end
14571474
if valtype !== Union{}
14581475
push!(ret, Vararg{valtype})
14591476
end
1460-
return ret, nothing
1477+
return AbstractIterationResult(ret, AbstractIterationInfo(calls, false))
14611478
end
14621479

14631480
# do apply(af, fargs...), where af is a function value
@@ -1488,13 +1505,9 @@ function abstract_apply(interp::AbstractInterpreter, argtypes::Vector{Any}, si::
14881505
infos′ = Vector{MaybeAbstractIterationInfo}[]
14891506
for ti in (splitunions ? uniontypes(aargtypes[i]) : Any[aargtypes[i]])
14901507
if !isvarargtype(ti)
1491-
cti_info = precise_container_type(interp, itft, ti, sv)
1492-
cti = cti_info[1]::Vector{Any}
1493-
info = cti_info[2]::MaybeAbstractIterationInfo
1508+
(;cti, info, ai_effects) = precise_container_type(interp, itft, ti, sv)
14941509
else
1495-
cti_info = precise_container_type(interp, itft, unwrapva(ti), sv)
1496-
cti = cti_info[1]::Vector{Any}
1497-
info = cti_info[2]::MaybeAbstractIterationInfo
1510+
(;cti, info, ai_effects) = precise_container_type(interp, itft, unwrapva(ti), sv)
14981511
# We can't represent a repeating sequence of the same types,
14991512
# so tmerge everything together to get one type that represents
15001513
# everything.
@@ -1507,6 +1520,12 @@ function abstract_apply(interp::AbstractInterpreter, argtypes::Vector{Any}, si::
15071520
end
15081521
cti = Any[Vararg{argt}]
15091522
end
1523+
effects = merge_effects(effects, ai_effects)
1524+
if info !== nothing
1525+
for call in info.each
1526+
effects = merge_effects(effects, call.effects)
1527+
end
1528+
end
15101529
if any(@nospecialize(t) -> t === Bottom, cti)
15111530
continue
15121531
end

base/compiler/inferencestate.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,18 @@ function sptypes_from_meth_instance(linfo::MethodInstance)
459459
v = sp[i]
460460
if v isa TypeVar
461461
fromArg = 0
462-
maybe_undef = !constrains_param(v, linfo.specTypes, #=covariant=#true)
462+
maybe_undef = !(let sig=sig
463+
# if the specialized signature `linfo.specTypes` doesn't contain any free
464+
# type variables, we can use it for a more accurate analysis of whether `v`
465+
# is constrained or not, otherwise we should use `def.sig` which always
466+
# doesn't contain any free type variables
467+
if !has_free_typevars(linfo.specTypes)
468+
sig = linfo.specTypes
469+
else
470+
@assert !has_free_typevars(sig)
471+
end
472+
constrains_param(v, sig, #=covariant=#true)
473+
end)
463474
temp = sig
464475
for j = 1:i-1
465476
temp = temp.body

0 commit comments

Comments
 (0)