Skip to content

Tweak parameter dependency test when typing applications #23346

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

Merged
merged 1 commit into from
Jun 11, 2025
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
13 changes: 8 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -726,11 +726,14 @@ trait Applications extends Compatibility {
def addTyped(arg: Arg): List[Type] =
if !formal.isRepeatedParam then checkNoVarArg(arg)
addArg(typedArg(arg, formal), formal)
if methodType.isParamDependent && typeOfArg(arg).exists then
// `typeOfArg(arg)` could be missing because the evaluation of `arg` produced type errors
formals1.mapconserve(safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg)))
else
formals1
if methodType.looksParamDependent
// need to handle also false dependencies since we generate TypeTrees from
// formal parameters in makeVarArg. These are not de-aliased, so they might contain
// stray parameter references. Test case is i23266.scala.
&& typeOfArg(arg).exists
// `typeOfArg(arg)` could be missing because the evaluation of `arg` produced type errors
then formals1.mapconserve(safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg)))
else formals1

def missingArg(n: Int): Unit =
fail(MissingArgument(methodType.paramNames(n), methString))
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/pos-test-pickling.excludelist
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ parsercombinators-new-syntax.scala
hylolib-deferred-given
hylolib-cb
hylolib
i23266.scala

# typecheckErrors method unpickling
i21415.scala
20 changes: 4 additions & 16 deletions tests/neg/i16842.check
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
-- [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`
-- 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
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 // error
Liter(SemanticArray[SemanticInt.type], x) // error
}
17 changes: 17 additions & 0 deletions tests/pos/i23266.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

def kek(t: Table, ids: t.Id*) = ???

trait Table {
type Id = String
}

object Table1 extends Table {
val id: Id = "table1_id"
}

class Table2() extends Table {
val id: Id = "table2_id"
}

val x = kek(Table1, Table1.id)
val y = kek(Table2(), Table2().id)
Loading