File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -1343,6 +1343,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1343
1343
1344
1344
def methodStr = err.refStr(methPart(tree).tpe)
1345
1345
1346
+ def missingArgs = errorTree(tree,
1347
+ d """ missing arguments for $methodStr
1348
+ |follow this method with `_' if you want to treat it as a partially applied function """ .stripMargin)
1349
+
1346
1350
def adaptOverloaded (ref : TermRef ) = {
1347
1351
val altDenots = ref.denot.alternatives
1348
1352
typr.println(i " adapt overloaded $ref with alternatives ${altDenots map (_.info)}%, % " )
@@ -1475,12 +1479,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1475
1479
else if (wtp.isImplicit)
1476
1480
err.typeMismatch(tree, pt)
1477
1481
else
1478
- errorTree(tree,
1479
- d """ missing arguments for $methodStr
1480
- |follow this method with `_' if you want to treat it as a partially applied function """ .stripMargin)
1482
+ missingArgs
1481
1483
case _ =>
1482
1484
if (tree.tpe <:< pt) tree
1483
1485
else if (ctx.mode is Mode .Pattern ) tree // no subtype check for pattern
1486
+ else if (wtp.isInstanceOf [MethodType ]) missingArgs
1484
1487
else {
1485
1488
typr.println(i " adapt to subtype ${tree.tpe} !<:< $pt" )
1486
1489
// typr.println(TypeComparer.explained(implicit ctx => tree.tpe <:< pt))
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ class tests extends CompilerTest {
158
158
@ Test def neg_i941 = compileFile(negDir, " i941" , xerrors = 3 )
159
159
@ Test def neg_finalSealed = compileFile(negDir, " final-sealed" , xerrors = 2 )
160
160
@ Test def neg_i705 = compileFile(negDir, " i705-inner-value-class" , xerrors = 7 )
161
+ @ Test def neg_i803 = compileFile(negDir, " i803" , xerrors = 2 )
161
162
@ Test def neg_i866 = compileFile(negDir, " i866" , xerrors = 2 )
162
163
@ Test def neg_i974 = compileFile(negDir, " i974" , xerrors = 2 )
163
164
@ Test def neg_moduleSubtyping = compileFile(negDir, " moduleSubtyping" , xerrors = 4 )
Original file line number Diff line number Diff line change
1
+ class Foo {
2
+ val default = this
3
+ def foo (a : Int )(b : Foo = default): b.type = b
4
+
5
+ def bar (b : Foo = default): b.type = b
6
+ val x : Foo = bar() // ok
7
+ val x2 : Foo = foo(1 )() // ok
8
+
9
+ val s : Foo = foo(1 ) // error
10
+ val s2 : default.type = foo(1 ) // error
11
+ }
You can’t perform that action at this time.
0 commit comments