File tree 3 files changed +45
-1
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -2250,6 +2250,12 @@ class Typer extends Namer
2250
2250
untpd.Apply (tree, args).withType(propFail)
2251
2251
}
2252
2252
2253
+ // lifting may result in blocks, see tests/pos/i4600b.scala
2254
+ def methSymbol : Symbol = tree match {
2255
+ case Block (_, expr) => expr.symbol
2256
+ case _ => tree.symbol
2257
+ }
2258
+
2253
2259
if (propFail.exists) {
2254
2260
// If there are several arguments, some arguments might already
2255
2261
// have influenced the context, binding variables, but later ones
@@ -2258,7 +2264,7 @@ class Typer extends Namer
2258
2264
2259
2265
// If method has default params, fall back to regular application
2260
2266
// where all inferred implicits are passed as named args.
2261
- if (tree.symbol .hasDefaultParams && ! propFail.isInstanceOf [AmbiguousImplicits ]) {
2267
+ if (methSymbol .hasDefaultParams && ! propFail.isInstanceOf [AmbiguousImplicits ]) {
2262
2268
val namedArgs = (wtp.paramNames, args).zipped.flatMap { (pname, arg) =>
2263
2269
if (arg.tpe.isError) Nil else untpd.NamedArg (pname, untpd.TypedSplice (arg)) :: Nil
2264
2270
}
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 (): Unit = {
10
+ new ImplicitExample ().someMethod()
11
+ }
12
+
13
+ def t2 (): Unit = {
14
+ implicit val s : String = " Hello"
15
+ new ImplicitExample ().someMethod()
16
+ }
17
+
18
+ def t3 (): Unit = {
19
+ new ImplicitExample ().run()
20
+ }
21
+
22
+ def t4 (): Unit = {
23
+ implicit val s : String = " Hello"
24
+ new ImplicitExample ().run()
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ class Foo (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" ) = ???
10
+
11
+ test(new Foo (" port" ))()
12
+ }
You can’t perform that action at this time.
0 commit comments