From 98d7183067f6a48957988ba99d234f60ab0246be Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 15 Apr 2016 14:07:44 +0200 Subject: Create LambdaTraits referred to from Unpickler LambdaTraits are created on demand; we need to make sure they exist when referred to from Tasty. --- src/dotty/tools/dotc/core/NameOps.scala | 7 ++++++- src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala index 81240a9fc..b3b0982a4 100644 --- a/src/dotty/tools/dotc/core/NameOps.scala +++ b/src/dotty/tools/dotc/core/NameOps.scala @@ -116,7 +116,12 @@ object NameOps { name.drop(tpnme.hkArgPrefixLength).toString.toInt def isLambdaTraitName(implicit ctx: Context): Boolean = - name.startsWith(tpnme.hkLambdaPrefix) + name.isTypeName && name.startsWith(tpnme.hkLambdaPrefix) + + def lambdaTraitVariances(implicit ctx: Context): List[Int] = { + val vs = name.drop(tpnme.hkLambdaPrefix.length) + vs.map(c => tpnme.varianceSuffixes.indexOf(c) - 1).toList + } /** If the name ends with $nn where nn are * all digits, strip the $ and the digits. diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index b547862b4..3a9803346 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -252,6 +252,8 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { readPackageRef().termRef case TYPEREF => val name = readName().toTypeName + if (name.isLambdaTraitName) // Make sure curresponding lambda trait exists + defn.LambdaTrait(name.lambdaTraitVariances) TypeRef(readType(), name) case TERMREF => readNameSplitSig() match { -- cgit v1.2.3