File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -2258,7 +2258,7 @@ class Typer extends Namer
22582258
22592259 // If method has default params, fall back to regular application
22602260 // where all inferred implicits are passed as named args.
2261- if (tree.symbol.hasDefaultParams && ! propFail.isInstanceOf [AmbiguousImplicits ]) {
2261+ if (methPart( tree) .symbol.hasDefaultParams && ! propFail.isInstanceOf [AmbiguousImplicits ]) {
22622262 val namedArgs = (wtp.paramNames, args).zipped.flatMap { (pname, arg) =>
22632263 if (arg.tpe.isError) Nil else untpd.NamedArg (pname, untpd.TypedSplice (arg)) :: Nil
22642264 }
Original file line number Diff line number Diff line change 1+ import scala .language .dynamics
2+
3+ class ImplicitExample () extends Dynamic {
4+ def someMethod ()(implicit s : String = " World" ): String = s
5+ def applyDynamic (name : String )(args : Any * )(implicit s : String = " World" ): String = name + s
6+ }
7+
8+ class ImplicitTest {
9+ def t1 () = {
10+ new ImplicitExample ().someMethod()
11+ }
12+
13+ def t2 () = {
14+ implicit val s : String = " Hello"
15+ new ImplicitExample ().someMethod()
16+ }
17+
18+ def t3 () = {
19+ new ImplicitExample ().run()
20+ }
21+
22+ def t4 () = {
23+ implicit val s : String = " Hello"
24+ new ImplicitExample ().run()
25+ }
26+ }
27+
28+
29+ object Test {
30+ def main (args : Array [String ]) = {
31+ val it = new ImplicitTest
32+ assert(it.t1() == " World" )
33+ assert(it.t2() == " Hello" )
34+ assert(it.t3() == " runWorld" )
35+ assert(it.t4() == " runHello" )
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ class Foo (val config : String ) {
2+ case class Bar (val x : Int ) {
3+ def doThings : String = config // Do whatever here
4+ }
5+ }
6+
7+
8+ object Test {
9+ def test (foo : Foo )(bar : foo.Bar = foo.Bar (5 ))(implicit s : String = " ok" ) = s + foo.config + bar.x
10+
11+ def main (args : Array [String ]) = {
12+ val res = test(new Foo (" port" ))()
13+ assert(res == " okport5" )
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments