[FIR] Fix Definitely Not Null type substitution

This commit is contained in:
Simon Ogorodnik
2019-11-28 16:16:05 +03:00
parent e5f60253f7
commit 2f9c94bd9e
3 changed files with 6 additions and 7 deletions
@@ -87,7 +87,7 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() {
}
private fun ConeDefinitelyNotNullType.substituteOriginal(): ConeDefinitelyNotNullType? {
return ConeDefinitelyNotNullType.create(substituteType(original)?.withNullability(ConeNullability.NOT_NULL) ?: original)
return ConeDefinitelyNotNullType.create(substituteOrNull(original)?.withNullability(ConeNullability.NOT_NULL) ?: original)
}
private fun ConeFlexibleType.substituteBounds(): ConeFlexibleType? {
@@ -32,8 +32,7 @@ public class DiagnosticFactory<D extends EmptyDiagnostic> {
}
// FILE: DiagnosticFactory0.java
public class DiagnosticFactory0<E extends Element> extends DiagnosticFactory<Diagnostic> {}
public class DiagnosticFactory0<E extends Element> extends DiagnosticFactory<Diagnostic<E>> {}
// FILE: test.kt
@@ -54,5 +53,5 @@ private val DERIVED_FACTORY = DiagnosticFactory0<DerivedElement>()
fun createViaFactory(d: EmptyDiagnostic) {
val casted = DERIVED_FACTORY.cast(d)
val element = casted.element
<!INAPPLICABLE_CANDIDATE!>Fix<!>(element)
Fix(element)
}
@@ -16,7 +16,7 @@ FILE: test.kt
private final val DERIVED_FACTORY: R|DiagnosticFactory0<DerivedElement>| = R|/DiagnosticFactory0.DiagnosticFactory0|<R|DerivedElement|>()
private get(): R|DiagnosticFactory0<DerivedElement>|
public final fun createViaFactory(d: R|EmptyDiagnostic|): R|kotlin/Unit| {
lval casted: R|Diagnostic<*>!| = R|/DERIVED_FACTORY|.R|FakeOverride</DiagnosticFactory.cast: R|Diagnostic<*>!|>|(R|<local>/d|)
lval element: R|Element!| = R|<local>/casted|.R|/Diagnostic.element|
<Inapplicable(INAPPLICABLE): [/Fix.Fix]>#(R|<local>/element|)
lval casted: R|Diagnostic<DerivedElement>!| = R|/DERIVED_FACTORY|.R|FakeOverride</DiagnosticFactory.cast: R|Diagnostic<DerivedElement>!|>|(R|<local>/d|)
lval element: R|DerivedElement!| = R|<local>/casted|.R|/Diagnostic.element|
R|/Fix.Fix|(R|<local>/element|)
}