Skip to content

Commit eabe551

Browse files
committed
More robust implementation of requiredMethod
Test types arguments for equality with =:= rather than ==. Also, better diagnostics for requiredSymbol
1 parent 11efb82 commit eabe551

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ object Denotations {
200200
}
201201
else NoSymbol
202202
case NoDenotation | _: NoQualifyingRef =>
203-
throw new TypeError(s"None of the alternatives of $this satisfies required predicate")
203+
throw new TypeError(i"None of the alternatives of $this satisfies required predicate")
204204
case denot =>
205205
denot.symbol
206206
}
@@ -210,10 +210,16 @@ object Denotations {
210210
def requiredMethodRef(name: PreName)(implicit ctx: Context): TermRef =
211211
requiredMethod(name).termRef
212212

213-
def requiredMethod(name: PreName, argTypes: List[Type])(implicit ctx: Context): TermSymbol =
214-
info.member(name.toTermName).requiredSymbol(x=>
215-
(x is Method) && x.info.paramInfoss == List(argTypes)
216-
).asTerm
213+
def requiredMethod(name: PreName, argTypes: List[Type])(implicit ctx: Context): TermSymbol = {
214+
info.member(name.toTermName).requiredSymbol { x =>
215+
(x is Method) && {
216+
x.info.paramInfoss match {
217+
case paramInfos :: Nil => paramInfos.corresponds(argTypes)(_ =:= _)
218+
case _ => false
219+
}
220+
}
221+
}.asTerm
222+
}
217223
def requiredMethodRef(name: PreName, argTypes: List[Type])(implicit ctx: Context): TermRef =
218224
requiredMethod(name, argTypes).termRef
219225

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ trait TypeAssigner {
413413
else wrongNumberOfTypeArgs(fn.tpe, pt.typeParams, args, tree.pos)
414414
}
415415
case _ =>
416+
//println(i"bad type: $fn: ${fn.symbol} / ${fn.symbol.isType} / ${fn.symbol.info}") // DEBUG
416417
errorType(err.takesNoParamsStr(fn, "type "), tree.pos)
417418
}
418419

0 commit comments

Comments
 (0)