You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sealedtraitTP:typePfinalclassFooextendsTP:enumP:caseA, BobjectBarextendsTP:enumP:caseA, B, C// Works
summon[Foo#P<:<TP#P]
vala:TP#P=Foo().P.A// These fail
summon[Bar.type#P<:<TP#P]
summon[Bar.P<:<TP#P]
valb:TP#P=Bar.P.A
Output
--Error:-----------------------------------------------------------------------------------------------------------------------------------------------------17|summon[Bar.type#P<:<TP#P]
|^|Cannot prove that Bar.P<:<TP#P.
--Error:-----------------------------------------------------------------------------------------------------------------------------------------------------18|summon[Bar.P<:<TP#P]
|^|Cannot prove that Bar.P<:<TP#P.
-- [E007] TypeMismatchError:--------------------------------------------------------------------------------------------------------------------------------19|valb:TP#P=Bar.P.A|^^^^^^^|Found: (Bar.P.A:Bar.P)
|Required:TP#P²
||where: P is a classinobjectBar|P² is a typeintraitTP
The same (wrong) behavior is present in 3.1.3, 3.2.0-RC4 and 3.2.1-RC1-bin-20220828-8a7c84c-NIGHTLY.
I tried to use --explain to get why the last assignment is failing and I got:
| Tree: Bar.P.A
| I tried to show that
| (Bar.P.A : Bar.P)
| conforms to
| TP#P
| but the comparison trace ended with `false`:
|
| ==> (Bar.P.A : Bar.P) <: TP#P
| ==> Bar.P <: TP#P (left is approximated)
| <== Bar.P <: TP#P (left is approximated) = false
| <== (Bar.P.A : Bar.P) <: TP#P = false
|
| The tests were made under a constraint with:
| uninstantiated variables: A
| constrained types: [A] => A =:= A
| bounds:
| A >: Foo#P <: TP#P
| ordering:
A >: Foo#P <: TP#P Part is interesting here.
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Sep 3, 2022
Compiler version
3.1.3
Minimized code
Output
Expectation
Code should compile.
Scastie link
Discussion at Discord channel
Context
Regardless of the concrete instance of
TP
I want to:TP#P
TP#P
and be able to pass it either an instance of Foo.P or Bar.type.P.The text was updated successfully, but these errors were encountered: