From 7c5e36b80e111d17910dbf122c02a458377656d1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 18 Dec 2016 19:29:02 +0100 Subject: More lenient handling of mixed parameterless and nullary methods When faced with a denotation that combines parameterless and nullary method definitions (toString is a common example), ignore any redundant () applications. --- compiler/src/dotty/tools/dotc/core/Types.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/src/dotty/tools/dotc/core') diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 069b4f60d..df1e68944 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -217,6 +217,14 @@ object Types { case _ => false } + /** Is this the type of a method with a leading empty parameter list? + */ + def isNullaryMethod(implicit ctx: Context): Boolean = this match { + case MethodType(Nil, _) => true + case tp: PolyType => tp.resultType.isNullaryMethod + case _ => false + } + /** Is this an alias TypeBounds? */ def isAlias: Boolean = this.isInstanceOf[TypeAlias] -- cgit v1.2.3