File tree Expand file tree Collapse file tree 4 files changed +14
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -332,13 +332,17 @@ object Types {
332
332
/** Is this type produced as a repair for an error? */
333
333
final def isError (using Context ): Boolean = stripTypeVar.isInstanceOf [ErrorType ]
334
334
335
+ /** A conservative approximation whether a type might have errors.
336
+ * It's OK to predict "no errors" even though errors might be present.
337
+ * But one should never force or loop.
338
+ */
335
339
def hasErrors (using Context ): Boolean = widenDealias match
336
- case _ : NamedType => false
337
340
case AppliedType (tycon, args) => tycon.hasErrors || args.exists(_.hasErrors)
338
341
case RefinedType (parent, _, rinfo) => parent.hasErrors || rinfo.hasErrors
339
342
case TypeBounds (lo, hi) => lo.hasErrors || hi.hasErrors
340
343
case tp : AndOrType => tp.tp1.hasErrors || tp.tp2.hasErrors
341
- case tp : TypeProxy => tp.underlying.hasErrors
344
+ case tp : LambdaType => tp.resultType.hasErrors || tp.paramInfos.exists(_.hasErrors)
345
+ case WildcardType (optBounds) => optBounds.hasErrors
342
346
case _ : ErrorType => true
343
347
case _ => false
344
348
Original file line number Diff line number Diff line change @@ -473,7 +473,9 @@ trait Applications extends Compatibility {
473
473
def success : Boolean = ok
474
474
475
475
protected def methodType : MethodType = methType.asInstanceOf [MethodType ]
476
- private def methString : String = i " ${err.refStr(methRef)}: ${methType.show}"
476
+ private def methString : String =
477
+ def infoStr = if methType.hasErrors then " " else i " : $methType"
478
+ i " ${err.refStr(methRef)}$infoStr"
477
479
478
480
/** Re-order arguments to correctly align named arguments */
479
481
def reorder [T >: Untyped ](args : List [Trees .Tree [T ]]): List [Trees .Tree [T ]] = {
Original file line number Diff line number Diff line change @@ -954,6 +954,10 @@ trait Implicits:
954
954
assert(ctx.phase.allowsImplicitSearch,
955
955
if (argument.isEmpty) i " missing implicit parameter of type $pt after typer "
956
956
else i " type error: ${argument.tpe} does not conform to $pt${err.whyNoMatchStr(argument.tpe, pt)}" )
957
+
958
+ if pt.hasErrors || ! argument.isEmpty && argument.tpe.hasErrors then
959
+ return NoMatchingImplicitsFailure
960
+
957
961
val result0 =
958
962
try ImplicitSearch (pt, argument, span).bestImplicit
959
963
catch case ce : CyclicReference =>
Original file line number Diff line number Diff line change 1
1
def foo : Unit = {
2
2
val a = (x : Int , y : String ) => x + + y // error
3
3
implicit def f [X ](x : (X , String ) => String ) = (z : X ) => (z, null ) // error
4
- a(1 )
4
+ a(1 ) // error
5
5
}
You can’t perform that action at this time.
0 commit comments