diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-18 19:29:02 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-12-20 18:33:44 +0100 |
commit | 7c5e36b80e111d17910dbf122c02a458377656d1 (patch) | |
tree | 210ba0cde3e81925aab1af83ab1353c6606a1331 /compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala | |
parent | 9c0df5aa3af3906913f6507e04078c32dd2a4742 (diff) | |
download | dotty-7c5e36b80e111d17910dbf122c02a458377656d1.tar.gz dotty-7c5e36b80e111d17910dbf122c02a458377656d1.tar.bz2 dotty-7c5e36b80e111d17910dbf122c02a458377656d1.zip |
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.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index ed6b95c3b..3c318a6af 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -250,6 +250,22 @@ object ProtoTypes { /** Somebody called the `tupled` method of this prototype */ def isTupled: Boolean = myTupled.isInstanceOf[FunProto] + /** If true, the application of this prototype was canceled. */ + private var toDrop: Boolean = false + + /** Cancel the application of this prototype. This can happen for a nullary + * application `f()` if `f` refers to a symbol that exists both in parameterless + * form `def f` and nullary method form `def f()`. A common example for such + * a method is `toString`. If in that case the type in the denotation is + * parameterless, we compensate by dropping the application. + */ + def markAsDropped() = { + assert(args.isEmpty) + toDrop = true + } + + def isDropped: Boolean = toDrop + override def toString = s"FunProto(${args mkString ","} => $resultType)" def map(tm: TypeMap)(implicit ctx: Context): FunProto = |