Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect caching with dependent method parameters #21699

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ object Types extends TypeUtils {
!t.isPermanentlyInstantiated || test(t.permanentInst, theAcc)
case t: LazyRef =>
!t.completed || test(t.ref, theAcc)
case t: ParamRef =>
(t: Type).mightBeProvisional = false // break cycles
test(t.underlying, theAcc)
case _ =>
(if theAcc != null then theAcc else ProAcc()).foldOver(false, t)
end if
Expand Down
20 changes: 16 additions & 4 deletions tests/neg/i16842.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
-- Error: tests/neg/i16842.scala:24:7 ----------------------------------------------------------------------------------
24 | Liter(SemanticArray[SemanticInt.type], x) // error
| ^
| invalid new prefix (dim: Int): SemanticArray[SemanticInt.type] cannot replace ty.type in type ty.T
-- [E007] Type Mismatch Error: tests/neg/i16842.scala:24:8 -------------------------------------------------------------
24 | Liter(SemanticArray[SemanticInt.type], x) // error // error
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Found: Int => SemanticArray[SemanticInt.type]
| Required: SemanticArray[SemanticType]
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i16842.scala:24:41 ------------------------------------------------------------
24 | Liter(SemanticArray[SemanticInt.type], x) // error // error
| ^
| Found: (x : List[Expr2[SemanticInt.type]])
| Required: ty.T
| Note that implicit conversions were not tried because the result of an implicit conversion
| must be more specific than ty.T
|
| longer explanation available when compiling with `-explain`
2 changes: 1 addition & 1 deletion tests/neg/i16842.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ def typecheckArrayLiter(
a: ArrayLiter
): Liter[SemanticArray[SemanticType]] = {
val x: List[Expr2[SemanticInt.type]] = List()
Liter(SemanticArray[SemanticInt.type], x) // error
Liter(SemanticArray[SemanticInt.type], x) // error // error
}
9 changes: 9 additions & 0 deletions tests/pos/dep-poly-class.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
trait A:
type B

class CCPoly[T <: A](a: T, b: a.B)

object Test:
def test(): Unit =
val aa: A { type B = Int } = new A { type B = Int }
val x: CCPoly[aa.type] = CCPoly(aa, 1)