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/typer/Typer.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/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 33a94f5c7..34be65591 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -1674,11 +1674,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def adaptType(tp: Type): Tree = { val tree1 = - if (pt != AnyTypeConstructorProto && tp.typeParamSymbols.nonEmpty) { - println(i"lam abs $tp with tparams ${tp.typeParamSymbols}%, %") - tree.withType(tree.tpe.EtaExpand(tp.typeParamSymbols)) - } - else tree + if ((pt eq AnyTypeConstructorProto) || tp.typeParamSymbols.isEmpty) tree + else tree.withType(tree.tpe.EtaExpand(tp.typeParamSymbols)) if ((ctx.mode is Mode.Pattern) || tree1.tpe <:< pt) tree1 else err.typeMismatch(tree1, pt) } |