diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-29 19:46:39 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:01 +0200 |
commit | 0a5f8394a4a226bd3dcf9c966495e653a25ed7d2 (patch) | |
tree | 278a5a4d717bab8a60fcafca02af7563b69e9599 /src/dotty/tools/dotc/core/TypeApplications.scala | |
parent | 463e99a48996fbf7148aa62ec6d2f8b28000d2d4 (diff) | |
download | dotty-0a5f8394a4a226bd3dcf9c966495e653a25ed7d2.tar.gz dotty-0a5f8394a4a226bd3dcf9c966495e653a25ed7d2.tar.bz2 dotty-0a5f8394a4a226bd3dcf9c966495e653a25ed7d2.zip |
Avoid infinite recursion when comparing recursive types.
The previous scheme goes into an infinite recursion if the recursive type
does not contain a reference to itself.
Also, make typeParams more defensive
The problematic case is something like
{ z => CC { type hk$0 = z.hk$0; type(param) hk$0 }
Here $hk0 becomes a type parameter through CC and the type lambda.
It's true that such types are eliminated later on. But we want to
avoid mispredictions at all points.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 6fc1fb9dc..fc8876d09 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -364,9 +364,9 @@ class TypeApplications(val self: Type) extends AnyVal { val sym = self.parent.classSymbol if (sym.isLambdaTraitOBS) return sym.typeParams } - val precedingParams = self.parent.typeParams + val precedingParams = self.parent.typeParams.filterNot(_.memberName == self.refinedName) if (Config.newHK && self.isTypeParam) precedingParams :+ self - else precedingParams.filterNot(_.memberName == self.refinedName) + else precedingParams case self: RecType => self.parent.typeParams case self: SingletonType => |