Comparing Refined Types can lead to invalid subtype reconstruction #15485
Labels
area:gadt
itype:soundness
Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)
Originally posted by @Linyxus in #15175 (comment)
Regarding the soundness holes caused by resetting approx state: yes, we have more soundness holes caused by this. Each time
isSubType(S, T)
(instead ofrecur(S, T)
) is called insideisSubType
, the approx state is reset, and it will be a potential soundness hole. For example, I find another callsite ofisSubType
here, and we can make a counter-example showing the unsoundness brought by this:In this example, we are trying to extract necessary constraint from
X <: Tag{type T <: B}
, whereX
is known to be a subtype ofTag{type T <: A}
. During this we will try upcasting LHS and compareTag{type T <: A} <: Tag{type T <: B}
with LHS approximated. Since when comparing the refinement info the approx state is reset, we derive the unsound constraintA <: B
.The text was updated successfully, but these errors were encountered: