Skip to content

Commit 0fca562

Browse files
authored
Merge pull request #14849 from dotty-staging/fix-14842
Don't issue implicit errors if parameter has default value
2 parents d8e50f2 + 484c9c6 commit 0fca562

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3539,14 +3539,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
35393539
val namedArgs = wtp.paramNames.lazyZip(args).flatMap { (pname, arg) =>
35403540
if (arg.tpe.isError) Nil else untpd.NamedArg(pname, untpd.TypedSplice(arg)) :: Nil
35413541
}
3542-
tryEither {
3543-
val app = cpy.Apply(tree)(untpd.TypedSplice(tree), namedArgs)
3544-
if (wtp.isContextualMethod) app.setApplyKind(ApplyKind.Using)
3545-
typr.println(i"try with default implicit args $app")
3546-
typed(app, pt, locked)
3547-
} { (_, _) =>
3548-
issueErrors()
3549-
}
3542+
val app = cpy.Apply(tree)(untpd.TypedSplice(tree), namedArgs)
3543+
if (wtp.isContextualMethod) app.setApplyKind(ApplyKind.Using)
3544+
typr.println(i"try with default implicit args $app")
3545+
typed(app, pt, locked)
35503546
else issueErrors()
35513547
}
35523548
else tree match {

tests/neg/i14772.check

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,3 @@
44
| Overloaded or recursive method impl needs return type
55
|
66
| longer explanation available when compiling with `-explain`
7-
-- Error: tests/neg/i14772.scala:8:12 ----------------------------------------------------------------------------------
8-
8 | Expr(()) // error
9-
| ^
10-
| no given instance of type quoted.ToExpr[Unit] was found for parameter x$2 of method apply in object Expr.
11-
| I found:
12-
|
13-
| quoted.ToExpr.ClassToExpr[T]
14-
|
15-
| But given instance ClassToExpr in object ToExpr does not match type quoted.ToExpr[Unit].

tests/neg/i14772.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ object A {
55

66
def impl(a: Expr[Any])(using Quotes)/*: Expr[Any]*/ = {
77
foo(a) // error
8-
Expr(()) // error
8+
???
99
}
1010
}

tests/neg/i14842.check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- [E007] Type Mismatch Error: tests/neg/i14842.scala:11:35 ------------------------------------------------------------
2+
11 | val x: Either[Int, Any] = node.as[Any] // error
3+
| ^^^^^^^^^^^^
4+
| Found: Either[String, Any]
5+
| Required: Either[Int, Any]
6+
|
7+
| longer explanation available when compiling with `-explain`

tests/neg/i14842.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Dummy
2+
object Dummy:
3+
val empty = new Dummy
4+
5+
sealed trait Node:
6+
def as[T](using d: Dummy = Dummy.empty): Either[String, T] = ???
7+
8+
object Sample extends App {
9+
val node: Node = ???
10+
11+
val x: Either[Int, Any] = node.as[Any] // error
12+
}

0 commit comments

Comments
 (0)