mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-87831 incorrect (invariant) variance on subtype
(cherry picked from commit c0254d65914f2e6fab1b69eecc6fc4e4837b6ce7) IJ-MR-192664 GitOrigin-RevId: b8d3a12e6774ccff04d368d30a0a49572e303e1e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2bf9d316a5
commit
80f38711ec
+1
@@ -107,6 +107,7 @@ object PyInferredVarianceJudgment {
|
||||
collector.usages.contains(COVARIANT) && collector.usages.contains(CONTRAVARIANT) -> INVARIANT
|
||||
collector.usages.contains(COVARIANT) -> COVARIANT
|
||||
collector.usages.contains(CONTRAVARIANT) -> CONTRAVARIANT
|
||||
collector.usages.contains(BIVARIANT) -> BIVARIANT
|
||||
else -> INVARIANT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,16 @@ internal class PyInferredVarianceJudgmentTest : PyTestCase() {
|
||||
""")
|
||||
}
|
||||
|
||||
fun `test Generic sub class unused`() {
|
||||
// see comment about bivariance in: PyInferredVarianceJudgment.doGetInferredVariance
|
||||
doTest("T", Variance.BIVARIANT, """
|
||||
class A[S]:
|
||||
...
|
||||
class B[T](A[T]):
|
||||
def method(self): pass
|
||||
""")
|
||||
}
|
||||
|
||||
fun `test Generic class unused TypeVar syntax`() {
|
||||
// see comment about bivariance in: PyInferredVarianceJudgment.doGetInferredVariance
|
||||
doTest("T])", Variance.BIVARIANT, PyReferenceExpression::class.java, """
|
||||
|
||||
Reference in New Issue
Block a user