Support invocation inference across narrowing reference conversions#8
Support invocation inference across narrowing reference conversions#8biboudis wants to merge 1 commit into
Conversation
| !targetType.hasTag(NONE) && | ||
| !targetType.hasTag(ERROR) && | ||
| targetType.isReference() && | ||
| !targetInferenceContext.free(targetType) && |
There was a problem hiding this comment.
Maybe this can be replaced by targetType.hasTag(CLASS)
There was a problem hiding this comment.
(e.g. the issue here is that a type variable might erase to a class type, which might lead you to lift more cases than needed. E.g. if we lift T to C<...> where T was an inference variable, we kind of lose T).
There was a problem hiding this comment.
not sure I follow, erasure during inference?
There was a problem hiding this comment.
It's the check in the line below -- which checks if |T| <: |R| where T is the target type and R is the return type. Basically, we're checking here if the relationship is "the wrong way around", and, if so, lift T to the same height as R. That's because with the new narrowing sealing conversion you can have legit cases of |T| <: |R| that are valid assignments.
| private Type resultCompatibilityTarget(Type returnType, Type targetType, | ||
| InferenceContext inferenceContext, InferenceContext targetInferenceContext) { | ||
| if (returnType.hasTag(CLASS) && | ||
| returnType.getTypeArguments().stream() |
There was a problem hiding this comment.
inferenceContext.free(returnType)?
| } | ||
|
|
||
| private Type lift(Type targetType, Type returnType) { | ||
| return types.asSuper(targetType, returnType.tsym); |
There was a problem hiding this comment.
what if we are dealing with arrays? better to use Infer::asSuper
| } | ||
| Type qtype = inferenceContext.asUndetVar(from); | ||
| Type to = resultInfo.pt; | ||
| Type to = resultCompatibilityTarget(mt.getReturnType(), resultInfo.pt, |
There was a problem hiding this comment.
probably the highest risk of semantic change is when qtype is an UndetVar, we need to test that case and look for any possible semantic change
No description provided.