File tree Expand file tree Collapse file tree 5 files changed +35
-4
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 5 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -1799,6 +1799,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1799
1799
*/
1800
1800
def tryInsertApplyOrImplicit (tree : Tree , pt : ProtoType )(fallBack : => Tree )(implicit ctx : Context ): Tree = {
1801
1801
1802
+ def isMethod (tree : Tree ) = tree.tpe match {
1803
+ case ref : TermRef => ref.denot.alternatives.forall(_.info.widen.isInstanceOf [MethodicType ])
1804
+ case _ => false
1805
+ }
1806
+
1802
1807
def isSyntheticApply (tree : Tree ): Boolean = tree match {
1803
1808
case tree : Select => tree.getAttachment(InsertedApply ).isDefined
1804
1809
case Apply (fn, _) => fn.getAttachment(InsertedApply ).isDefined
@@ -1821,7 +1826,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1821
1826
pt.markAsDropped()
1822
1827
tree
1823
1828
case _ =>
1824
- if (isApplyProto(pt) || isSyntheticApply(tree)) tryImplicit
1829
+ if (isApplyProto(pt) || isMethod(tree) || isSyntheticApply(tree)) tryImplicit
1825
1830
else tryEither(tryApply(_))((_, _) => tryImplicit)
1826
1831
}
1827
1832
}
Original file line number Diff line number Diff line change
1
+ class C {
2
+ def apply : C
3
+ }
4
+ object Test {
5
+ (new C )(22 ) // error: does not take parameters
6
+ }
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ class C {
3
+ def foo (x : Int ) = 1
4
+ def foo (x : Double ) = 2
5
+ }
6
+
7
+ implicit class COps (val x : C ) {
8
+ def foo (x : String ) = 3
9
+ }
10
+
11
+ def test : Unit = {
12
+ (new C ).foo(" Hello" )
13
+ }
14
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ class Test [A ](action : A => A ) {
2
+ def this () = this (a => a)
3
+ def go (x : A ) = action(x)
4
+ }
5
+
6
+ object Test extends App {
7
+ assert(new Test [Int ]().go(3 ) == 3 )
8
+ }
9
+
You can’t perform that action at this time.
0 commit comments